X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=libs%2Flib_detector.php;h=a59ae07a0cb6e6618fc558c38bd47913196f451c;hb=cc993d57663d9bbe81417c6f7f2db2c8f2c5bb98;hp=e08a49744de036b9a36348032552d5d41d26a102;hpb=3c3bc512b4ddf0ab8327f76649dd20981fafaa6a;p=ctracker.git diff --git a/libs/lib_detector.php b/libs/lib_detector.php index e08a497..a59ae07 100644 --- a/libs/lib_detector.php +++ b/libs/lib_detector.php @@ -2,11 +2,11 @@ /** * Detector library * - * @author Roland Haeder + * @author Roland Haeder * @version 3.0.0 * @copyright Copyright (c) 2009 Cracker Tracker Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,12 +33,14 @@ function initCrackerTrackerArrays () { @error_reporting(0); } + // Base path + $GLOBALS['ctracker_base_path'] = dirname(dirname(__FILE__)); + // Whitelist some absolute query strings (see below) $GLOBALS['ctracker_whitelist'] = array( - 'cmd=new', // LinPHA - 'cmd=edit', // LinPHA - 'cmd=lostpw', // LinPHA - 'secure_session=1', // Mantis Bug Tracker + 'cmd=new', // LinPHA + 'cmd=edit', // LinPHA + 'cmd=lostpw', // LinPHA ); // Attacks we should detect and block @@ -49,7 +51,7 @@ function initCrackerTrackerArrays () { 'union(', 'union=', // $GLOBAL/$_SERVER array elements - 'HTTP_USER_AGENT', 'HTTP_HOST', 'HTTP_PHP', '_SESSION','CFG_ROOT', + 'HTTP_USER_AGENT', 'HTTP_HOST', 'HTTP_PHP', '_SESSION', 'CFG_ROOT', 'DOCUMENT_ROOT', '_SERVER', // Sensitive files @@ -60,8 +62,8 @@ function initCrackerTrackerArrays () { // Other Linux/FreeBSD/??? programs (sometimes with space) 'traceroute ', 'ping ', 'bin/xterm', 'bin/./xterm', 'lsof ', - 'telnet ', 'wget ', 'bin/id', 'uname\x20', 'uname ', 'killall', - 'diff ', 'kill ', 'locate ', 'grep ', 'vi ', 'mv ', + 'telnet ', 'wget ', 'bin/perl', 'bin/id', 'uname\x20', 'uname ', + 'killall', 'diff ', 'kill ', 'locate ', 'grep ', 'vi ', 'mv ', 'rmdir ', 'mcd ', 'mrd ', 'rm ', ' mcd', ' mrd', ' rm', 'passwd ', ' passwd', 'mdir ', ' mdir', 'cp ', ' cp', 'esystem ', 'chr ', ' chr', 'wget ', ' wget', ' cmd', @@ -71,7 +73,7 @@ function initCrackerTrackerArrays () { // Other Linux programs (+ brace) 'locate(', 'grep(', 'kill(', 'mcd(', 'mrd(', 'rm(', 'mv(', 'rmdir(', 'chmod(', 'chmod(', 'chown(', 'chgrp(', 'passwd(', 'vi(', 'cp(', - 'mdir(', 'esystem(', 'chr(', 'wget(', 'rush(', 'echr(', + 'mdir(', 'system(', 'chr(', 'wget(', 'rush(', 'echr(', // Other Linux programs (+ equal) 'mcd=', 'mrd=', 'chmod=', 'chr=', 'rush=', 'echr=', @@ -89,13 +91,20 @@ function initCrackerTrackerArrays () { 'bin/./tclsh', 'bin/nasm', 'bin/./nasm', '/perl', 'perl ', 'cmd.exe', 'nc.exe', 'ftp.exe', + // php.ini settings + 'allow_url_fopen', 'allow_url_include', 'auto_prepend_file', 'disable_functions', 'safe_mode', + // PHP commands/scripts - 'fopen', 'fwrite', 'phpinfo()', '\', + 'fopen', 'fwrite', 'phpinfo()', '\', 'base64_decode', 'file_put_contents', + 'set_magic_quotes_runtime', 'set_magic_quotes_runtime', 'display_errors', 'passthru', // Typical PHP script remote-inclusions and typical include file names '.inc.php', '.lib.php', '.class.php', 'config.php', '.inc', '_php', 'php_', 'class_', '_class.php', 'db_mysql.inc', + // PHP arrays + '_PHPLIB', + // Generic remote inclusion '=http://', '=https://', 'path=', 'sql=', @@ -123,6 +132,18 @@ function initCrackerTrackerArrays () { // Windows XP (?) hacks 'xp_enumdsn', 'xp_availablemedia', 'xp_filelist', 'xp_cmdshell', + // Attempts to insert links into a badly secured URL + '%3E%3C', + + // Request header being inserted + 'content-type', + + // /proc/ and other forbidden paths + 'proc/self/environ', + + // MySQL internal functions + 'name_const', + // @TODO Misc/unsorted 'cgi-', '.eml', '$_request', '$_get', '$request', '$get', '.system', '&aim', 'new_password', '&icq', '.conf', 'motd ', 'HTTP/1.', @@ -130,7 +151,7 @@ function initCrackerTrackerArrays () { 'wwwacl', '.js', '.jsp', 'server-info', 'server-status', 'secure_site, ok', 'chunked', 'org.apache', '/servlet/con', ' determineCrackerTrackerRealRemoteAddress(), - 'check_worm' => $GLOBALS['ctracker_checkworm'], + 'proxy_addr' => getenv('REMOTE_ADDR'), + 'check_worm' => $GLOBALS['ctracker_checked_get'], 'server_name' => crackerTrackerServerName() ); @@ -261,13 +294,13 @@ function sendCrackerTrackerPostMail () { Remote-IP : '.determineCrackerTrackerRealRemoteAddress().' User-Agent : '.crackerTrackerUserAgent().' Request-string : '.crackerTrackerQueryString().' -Filtered string : '.$GLOBALS['ctracker_checkworm'].' +Filtered string : '.$GLOBALS['ctracker_checked_get'].' Server : '.crackerTrackerServerName().' Script : '.crackerTrackerScriptName().' Referrer : '.crackerTrackerReferer().' ----------------------------------------------------- POST string : '.$GLOBALS['ctracker_post_track'].' -Filtered POST string : '.$GLOBALS['ctracker_check_post'].' +Filtered POST string : '.$GLOBALS['ctracker_checked_post'].' ----------------------------------------------------- '; @@ -317,17 +350,19 @@ function crackerTrackerLogAttack () { // Prepare array for database insert $rowData = array( - 'remote_addr' => determineCrackerTrackerRealRemoteAddress(), - 'user_agent' => crackerTrackerUserAgent(), - 'get_data' => crackerTrackerQueryString(), - 'post_data' => $GLOBALS['ctracker_post_track'], - 'check_worm' => $GLOBALS['ctracker_checkworm'], - 'check_post' => $GLOBALS['ctracker_check_post'], - 'server_name' => crackerTrackerServerName(), - 'script_name' => crackerTrackerScriptName(), - 'referer' => crackerTrackerReferer(), - 'proxy_used' => $proxyUsed, - 'first_attempt' => 'NOW()' + 'remote_addr' => determineCrackerTrackerRealRemoteAddress(), + 'proxy_addr' => getenv('REMOTE_ADDR'), + 'user_agent' => crackerTrackerUserAgent(), + 'get_data' => crackerTrackerQueryString(), + 'post_data' => $GLOBALS['ctracker_post_track'], + 'check_worm' => $GLOBALS['ctracker_checked_get'], + 'check_post' => $GLOBALS['ctracker_checked_post'], + 'server_name' => crackerTrackerServerName(), + 'script_name' => crackerTrackerScriptName(), + 'referer' => crackerTrackerReferer(), + 'request_method' => crackerTrackerRequestMethod(), + 'proxy_used' => $proxyUsed, + 'first_attempt' => 'NOW()' ); // Insert the array in database @@ -340,20 +375,8 @@ function crackerTrackerAlertCurrentUser () { if (isset($GLOBALS['ctracker_last_suspicious_entry'])) { // Does the user have a ticket? if (ifCrackerTrackerIpHasTicket()) { - // Should we continue? - if (isset($_POST['ctracker_continue'])) { - // Set cookie - sendCrackerTrackerCookie(); - - // And redirect to same URL - crackerTrackerRedirectSameUrl(); - } elseif (ifCrackerTrackerCookieIsSet()) { - // Return here to normal program - return; - } else { - // Load "Thank you" template - crackerTrackerLoadTemplate('add_ticket_thanks'); - } + // Load "Thank you" template + crackerTrackerLoadTemplate('add_ticket_thanks'); } elseif ((isset($_POST['ctracker_add_ticket'])) && (!empty($_POST['name'])) && (!empty($_POST['email']))) { // Add the ticket addCrackerTrackerTicket($_POST);