Advertisement
Guest User

alles

a guest
Jun 28th, 2010
745
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.13 KB | None | 0 0
  1. /** IP Protected */
  2. $IP_ALLOW = array();
  3.  
  4. /** configuration define */
  5. define('PHP_FIREWALL_LANGUAGE', 'english' );
  6. define('PHP_FIREWALL_ADMIN_MAIL', '' );
  7. define('PHP_FIREWALL_PUSH_MAIL', false );
  8. define('PHP_FIREWALL_LOG_FILE', 'logs' );
  9. define('PHP_FIREWALL_PROTECTION_UNSET_GLOBALS', true );
  10. define('PHP_FIREWALL_PROTECTION_RANGE_IP_DENY', true );
  11. define('PHP_FIREWALL_PROTECTION_RANGE_IP_SPAM', false );
  12. define('PHP_FIREWALL_PROTECTION_URL', true );
  13. define('PHP_FIREWALL_PROTECTION_REQUEST_SERVER', true );
  14. define('PHP_FIREWALL_PROTECTION_SANTY', true );
  15. define('PHP_FIREWALL_PROTECTION_BOTS', true );
  16. define('PHP_FIREWALL_PROTECTION_REQUEST_METHOD', true );
  17. define('PHP_FIREWALL_PROTECTION_DOS', true );
  18. define('PHP_FIREWALL_PROTECTION_UNION_SQL', true );
  19. define('PHP_FIREWALL_PROTECTION_CLICK_ATTACK', true );
  20. define('PHP_FIREWALL_PROTECTION_XSS_ATTACK', true );
  21. define('PHP_FIREWALL_PROTECTION_COOKIES', false );
  22. define('PHP_FIREWALL_PROTECTION_POST', false );
  23. define('PHP_FIREWALL_PROTECTION_GET', false );
  24. define('PHP_FIREWALL_PROTECTION_SERVER_OVH', true );
  25. define('PHP_FIREWALL_PROTECTION_SERVER_KIMSUFI', true );
  26. define('PHP_FIREWALL_PROTECTION_SERVER_DEDIBOX', true );
  27. define('PHP_FIREWALL_PROTECTION_SERVER_DIGICUBE', true );
  28. define('PHP_FIREWALL_PROTECTION_SERVER_OVH_BY_IP', true );
  29. define('PHP_FIREWALL_PROTECTION_SERVER_KIMSUFI_BY_IP', true );
  30. define('PHP_FIREWALL_PROTECTION_SERVER_DEDIBOX_BY_IP', true );
  31. define('PHP_FIREWALL_PROTECTION_SERVER_DIGICUBE_BY_IP', true );
  32. /** end configuration */
  33.  
  34. /** IPS PROTECTED */
  35. if ( count( $IP_ALLOW ) > 0 ) {
  36. if ( in_array( $_SERVER['REMOTE_ADDR'], $IP_ALLOW ) ) return;
  37. }
  38. /** END IPS PROTECTED */
  39.  
  40.  
  41. /** LANGUAGE */
  42. if ( PHP_FIREWALL_LANGUAGE === 'french' ) {
  43. define('_PHPF_PROTECTION_DEDIBOX', 'Protection contre les serveurs DEDIBOX active, cette IP range n\'est pas autorisée !');
  44. define('_PHPF_PROTECTION_DEDIBOX_IP', 'Protection contre les serveurs DEDIBOX active, cette IP range n\'est pas autorisée !');
  45.  
  46. define('_PHPF_PROTECTION_DIGICUBE', 'Protection contre les serveurs DIGICUBE active, this IP range is not allowed !');
  47. define('_PHPF_PROTECTION_DIGICUBE_IP', 'Protection contre les serveurs DIGICUBE active, cette IP n\'est pas autorisée !');
  48.  
  49. define('_PHPF_PROTECTION_KIMSUFI', 'Protection contre les serveurs KIMSUFI active, cette IP range n\'est pas autorisée !');
  50. define('_PHPF_PROTECTION_OVH', 'Protection contre les serveurs OVH active, cette IP range n\'est pas autorisée !');
  51.  
  52. define('_PHPF_PROTECTION_BOTS', 'Attaque Bot détectée ! stop it ...');
  53. define('_PHPF_PROTECTION_CLICK', 'Click attaque détectée ! stop it .....');
  54. define('_PHPF_PROTECTION_DOS', 'Invalide user agent ! Stop it ...');
  55. define('_PHPF_PROTECTION_OTHER_SERVER', 'Poster depuis un autre serveur est interdit !');
  56. define('_PHPF_PROTECTION_REQUEST', 'Méthode de requête interdite ! Stop it ...');
  57. define('_PHPF_PROTECTION_SANTY', 'Attaque Santy detectée ! Stop it ...');
  58. define('_PHPF_PROTECTION_SPAM', 'Protection SPAM IPs active, cette IP range n\'est pas autorisée !');
  59. define('_PHPF_PROTECTION_SPAM_IP', 'Protection SPAM IPs active, cette IP range n\'est pas autorisée !');
  60. define('_PHPF_PROTECTION_UNION', 'Attaque Union détectée ! stop it ......');
  61. define('_PHPF_PROTECTION_URL', 'Protection url active, string non autorisée !');
  62. define('_PHPF_PROTECTION_XSS', 'Attaque XSS détectée ! stop it ...');
  63. } else {
  64. define('_PHPF_PROTECTION_DEDIBOX', 'Protection DEDIBOX Server active, this IP range is not allowed !');
  65. define('_PHPF_PROTECTION_DEDIBOX_IP', 'Protection DEDIBOX Server active, this IP is not allowed !');
  66.  
  67. define('_PHPF_PROTECTION_DIGICUBE', 'Protection DIGICUBE Server active, this IP range is not allowed !');
  68. define('_PHPF_PROTECTION_DIGICUBE_IP', 'Protection DIGICUBE Server active, this IP is not allowed !');
  69.  
  70. define('_PHPF_PROTECTION_KIMSUFI', 'Protection KIMSUFI Server active, this IP range is not allowed !');
  71. define('_PHPF_PROTECTION_OVH', 'Protection OVH Server active, this IP range is not allowed !');
  72.  
  73. define('_PHPF_PROTECTION_BOTS', 'Bot attack detected ! stop it ...');
  74. define('_PHPF_PROTECTION_CLICK', 'Click attack detected ! stop it .....');
  75. define('_PHPF_PROTECTION_DOS', 'Invalid user agent ! Stop it ...');
  76. define('_PHPF_PROTECTION_OTHER_SERVER', 'Posting from another server not allowed !');
  77. define('_PHPF_PROTECTION_REQUEST', 'Invalid request method check ! Stop it ...');
  78. define('_PHPF_PROTECTION_SANTY', 'Attack Santy detected ! Stop it ...');
  79. define('_PHPF_PROTECTION_SPAM', 'Protection SPAM IPs active, this IP range is not allowed !');
  80. define('_PHPF_PROTECTION_SPAM_IP', 'Protection died IPs active, this IP range is not allowed !');
  81. define('_PHPF_PROTECTION_UNION', 'Union attack detected ! stop it ......');
  82. define('_PHPF_PROTECTION_URL', 'Protection url active, string not allowed !');
  83. define('_PHPF_PROTECTION_XSS', 'XSS attack detected ! stop it ...');
  84. }
  85. /** END LANGUAGE*/
  86.  
  87.  
  88. if ( PHP_FIREWALL_ACTIVATION === true ) {
  89.  
  90. FUNCTION PHP_FIREWALL_unset_globals() {
  91. if ( ini_get('register_globals') ) {
  92. $allow = array('_ENV' => 1, '_GET' => 1, '_POST' => 1, '_COOKIE' => 1, '_FILES' => 1, '_SERVER' => 1, '_REQUEST' => 1, 'GLOBALS' => 1);
  93. foreach ($GLOBALS as $key => $value) {
  94. if ( ! isset( $allow[$key] ) ) unset( $GLOBALS[$key] );
  95. }
  96. }
  97. }
  98.  
  99. if ( PHP_FIREWALL_PROTECTION_UNSET_GLOBALS === true ) PHP_FIREWALL_unset_globals();
  100.  
  101. /** fonctions de base */
  102. FUNCTION PHP_FIREWALL_get_env($st_var) {
  103. global $HTTP_SERVER_VARS;
  104. if(isset($_SERVER[$st_var])) {
  105. return strip_tags( $_SERVER[$st_var] );
  106. } elseif(isset($_ENV[$st_var])) {
  107. return strip_tags( $_ENV[$st_var] );
  108. } elseif(isset($HTTP_SERVER_VARS[$st_var])) {
  109. return strip_tags( $HTTP_SERVER_VARS[$st_var] );
  110. } elseif(getenv($st_var)) {
  111. return strip_tags( getenv($st_var) );
  112. } elseif(function_exists('apache_getenv') && apache_getenv($st_var, true)) {
  113. return strip_tags( apache_getenv($st_var, true) );
  114. }
  115. return '';
  116. }
  117.  
  118. FUNCTION PHP_FIREWALL_get_referer() {
  119. if( PHP_FIREWALL_get_env('HTTP_REFERER') )
  120. return PHP_FIREWALL_get_env('HTTP_REFERER');
  121. return 'no referer';
  122. }
  123.  
  124. FUNCTION PHP_FIREWALL_get_ip() {
  125. if ( PHP_FIREWALL_get_env('HTTP_X_FORWARDED_FOR') ) {
  126. return PHP_FIREWALL_get_env('HTTP_X_FORWARDED_FOR');
  127. } elseif ( PHP_FIREWALL_get_env('HTTP_CLIENT_IP') ) {
  128. return PHP_FIREWALL_get_env('HTTP_CLIENT_IP');
  129. } else {
  130. return PHP_FIREWALL_get_env('REMOTE_ADDR');
  131. }
  132. }
  133. FUNCTION PHP_FIREWALL_get_user_agent() {
  134. if(PHP_FIREWALL_get_env('HTTP_USER_AGENT'))
  135. return PHP_FIREWALL_get_env('HTTP_USER_AGENT');
  136. return 'none';
  137. }
  138.  
  139. FUNCTION PHP_FIREWALL_get_query_string() {
  140. if( PHP_FIREWALL_get_env('QUERY_STRING') )
  141. return str_replace('%09', '%20', PHP_FIREWALL_get_env('QUERY_STRING'));
  142. return '';
  143. }
  144. FUNCTION PHP_FIREWALL_get_request_method() {
  145. if(PHP_FIREWALL_get_env('REQUEST_METHOD'))
  146. return PHP_FIREWALL_get_env('REQUEST_METHOD');
  147. return 'none';
  148. }
  149. FUNCTION PHP_FIREWALL_gethostbyaddr() {
  150. if ( PHP_FIREWALL_PROTECTION_SERVER_OVH === true OR PHP_FIREWALL_PROTECTION_SERVER_KIMSUFI === true OR PHP_FIREWALL_PROTECTION_SERVER_DEDIBOX === true OR PHP_FIREWALL_PROTECTION_SERVER_DIGICUBE === true ) {
  151. if ( @ empty( $_SESSION['PHP_FIREWALL_gethostbyaddr'] ) ) {
  152. return $_SESSION['PHP_FIREWALL_gethostbyaddr'] = @gethostbyaddr( PHP_FIREWALL_get_ip() );
  153. } else {
  154. return strip_tags( $_SESSION['PHP_FIREWALL_gethostbyaddr'] );
  155. }
  156. }
  157. }
  158.  
  159. /** bases define */
  160. define('PHP_FIREWALL_GET_QUERY_STRING', strtolower( PHP_FIREWALL_get_query_string() ) );
  161. define('PHP_FIREWALL_USER_AGENT', PHP_FIREWALL_get_user_agent() );
  162. define('PHP_FIREWALL_GET_IP', PHP_FIREWALL_get_ip() );
  163. define('PHP_FIREWALL_GET_HOST', PHP_FIREWALL_gethostbyaddr() );
  164. define('PHP_FIREWALL_GET_REFERER', PHP_FIREWALL_get_referer() );
  165. define('PHP_FIREWALL_GET_REQUEST_METHOD', PHP_FIREWALL_get_request_method() );
  166. define('PHP_FIREWALL_REGEX_UNION','#\w?\s?union\s\w*?\s?(select|all|distinct|insert|update|drop|delete)#is');
  167. FUNCTION PHP_FIREWALL_push_email( $subject, $msg ) {
  168. $headers = "From: PHP Firewall: ".PHP_FIREWALL_ADMIN_MAIL." <".PHP_FIREWALL_ADMIN_MAIL.">\r\n"
  169. ."Reply-To: ".PHP_FIREWALL_ADMIN_MAIL."\r\n"
  170. ."Priority: urgent\r\n"
  171. ."Importance: High\r\n"
  172. ."Precedence: special-delivery\r\n"
  173. ."Organization: PHP Firewall\r\n"
  174. ."MIME-Version: 1.0\r\n"
  175. ."Content-Type: text/plain\r\n"
  176. ."Content-Transfer-Encoding: 8bit\r\n"
  177. ."X-Priority: 1\r\n"
  178. ."X-MSMail-Priority: High\r\n"
  179. ."X-Mailer: PHP/" . phpversion() ."\r\n"
  180. ."X-PHPFirewall: 1.0 by PHPFirewall\r\n"
  181. ."Date:" . date("D, d M Y H:s:i") . " +0100\n";
  182. if ( PHP_FIREWALL_ADMIN_MAIL != '' )
  183. @mail( PHP_FIREWALL_ADMIN_MAIL, $subject, $msg, $headers );
  184. }
  185.  
  186. FUNCTION PHP_FIREWALL_LOGS( $type ) {
  187. $f = fopen( dirname(__FILE__).'/'.PHP_FIREWALL_LOG_FILE.'.txt', 'a');
  188. $msg = date('j-m-Y H:i:s')." | $type | IP: ".PHP_FIREWALL_GET_IP." ] | DNS: ".gethostbyaddr(PHP_FIREWALL_GET_IP)." | Agent: ".PHP_FIREWALL_USER_AGENT." | URL: ".PHP_FIREWALL_REQUEST_URI." | Referer: ".PHP_FIREWALL_GET_REFERER."\n\n";
  189. fputs($f, $msg);
  190. fclose($f);
  191. if ( PHP_FIREWALL_PUSH_MAIL === true ) {
  192. PHP_FIREWALL_push_email( 'Alert PHP Firewall '.strip_tags( $_SERVER['SERVER_NAME'] ) , "PHP Firewall logs of ".strip_tags( $_SERVER['SERVER_NAME'] )."\n".str_replace('|', "\n", $msg ) );
  193. }
  194. }
  195.  
  196. if ( PHP_FIREWALL_PROTECTION_SERVER_OVH === true ) {
  197. if ( stristr( PHP_FIREWALL_GET_HOST ,'ovh') ) {
  198. PHP_FIREWALL_LOGS( 'OVH Server list' );
  199. die( _PHPF_PROTECTION_OVH );
  200. }
  201. }
  202.  
  203. if ( PHP_FIREWALL_PROTECTION_SERVER_OVH_BY_IP === true ) {
  204. $ip = explode('.', PHP_FIREWALL_GET_IP );
  205. if ( $ip[0].'.'.$ip[1] == '87.98' or $ip[0].'.'.$ip[1] == '91.121' or $ip[0].'.'.$ip[1] == '94.23' or $ip[0].'.'.$ip[1] == '213.186' or $ip[0].'.'.$ip[1] == '213.251' ) {
  206. PHP_FIREWALL_LOGS( 'OVH Server IP' );
  207. die( _PHPF_PROTECTION_OVH );
  208. }
  209. }
  210.  
  211. if ( PHP_FIREWALL_PROTECTION_SERVER_KIMSUFI === true ) {
  212. if ( stristr( PHP_FIREWALL_GET_HOST ,'kimsufi') ) {
  213. PHP_FIREWALL_LOGS( 'KIMSUFI Server list' );
  214. die( _PHPF_PROTECTION_KIMSUFI );
  215. }
  216. }
  217.  
  218. if ( PHP_FIREWALL_PROTECTION_SERVER_DEDIBOX === true ) {
  219. if ( stristr( PHP_FIREWALL_GET_HOST ,'dedibox') ) {
  220. PHP_FIREWALL_LOGS( 'DEDIBOX Server list' );
  221. die( _PHPF_PROTECTION_DEDIBOX );
  222. }
  223. }
  224.  
  225. if ( PHP_FIREWALL_PROTECTION_SERVER_DEDIBOX_BY_IP === true ) {
  226. $ip = explode('.', PHP_FIREWALL_GET_IP );
  227. if ( $ip[0].'.'.$ip[1] == '88.191' ) {
  228. PHP_FIREWALL_LOGS( 'DEDIBOX Server IP' );
  229. die( _PHPF_PROTECTION_DEDIBOX_IP );
  230. }
  231. }
  232.  
  233. if ( PHP_FIREWALL_PROTECTION_SERVER_DIGICUBE === true ) {
  234. if ( stristr( PHP_FIREWALL_GET_HOST ,'digicube') ) {
  235. PHP_FIREWALL_LOGS( 'DIGICUBE Server list' );
  236. die( _PHPF_PROTECTION_DIGICUBE );
  237. }
  238. }
  239.  
  240. if ( PHP_FIREWALL_PROTECTION_SERVER_DIGICUBE_BY_IP === true ) {
  241. $ip = explode('.', PHP_FIREWALL_GET_IP );
  242. if ( $ip[0].'.'.$ip[1] == '95.130' ) {
  243. PHP_FIREWALL_LOGS( 'DIGICUBE Server IP' );
  244. die( _PHPF_PROTECTION_DIGICUBE_IP );
  245. }
  246. }
  247.  
  248. if ( PHP_FIREWALL_PROTECTION_RANGE_IP_SPAM === true ) {
  249. $ip_array = array('24', '186', '189', '190', '200', '201', '202', '209', '212', '213', '217', '222' );
  250. $range_ip = explode('.', PHP_FIREWALL_GET_IP );
  251. if ( in_array( $range_ip[0], $ip_array ) ) {
  252. PHP_FIREWALL_LOGS( 'IPs Spam list' );
  253. die( _PHPF_PROTECTION_SPAM );
  254. }
  255. }
  256.  
  257. if ( PHP_FIREWALL_PROTECTION_RANGE_IP_DENY === true ) {
  258. $ip_array = array('0', '1', '2', '5', '10', '14', '23', '27', '31', '36', '37', '39', '42', '46', '49', '50', '100', '101', '102', '103', '104', '105', '106', '107', '114', '172', '176', '177', '179', '181', '185', '192', '223', '224' );
  259. $range_ip = explode('.', PHP_FIREWALL_GET_IP );
  260. if ( in_array( $range_ip[0], $ip_array ) ) {
  261. PHP_FIREWALL_LOGS( 'IPs reserved list' );
  262. die( _PHPF_PROTECTION_SPAM_IP );
  263. }
  264. }
  265.  
  266. if ( PHP_FIREWALL_PROTECTION_COOKIES === true ) {
  267. $ct_rules = Array('applet', 'base', 'bgsound', 'blink', 'embed', 'expression', 'frame', 'javascript', 'layer', 'link', 'meta', 'object', 'onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavailable', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterchange', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowenter', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload', 'script', 'style', 'title', 'vbscript', 'xml');
  268. if ( PHP_FIREWALL_PROTECTION_COOKIES === true ) {
  269. foreach($_COOKIE as $value) {
  270. $check = str_replace($ct_rules, '*', $value);
  271. if( $value != $check ) {
  272. PHP_FIREWALL_LOGS( 'Cookie protect' );
  273. unset( $value );
  274. }
  275. }
  276. }
  277. if ( PHP_FIREWALL_PROTECTION_POST === true ) {
  278. foreach( $_POST as $value ) {
  279. $check = str_replace($ct_rules, '*', $value);
  280. if( $value != $check ) {
  281. PHP_FIREWALL_LOGS( 'POST protect' );
  282. unset( $value );
  283. }
  284. }
  285. }
  286. if ( PHP_FIREWALL_PROTECTION_GET === true ) {
  287. foreach( $_GET as $value ) {
  288. $check = str_replace($ct_rules, '*', $value);
  289. if( $value != $check ) {
  290. PHP_FIREWALL_LOGS( 'GET protect' );
  291. unset( $value );
  292. }
  293. }
  294. }
  295. }
  296.  
  297. /** protection de l'url */
  298. if ( PHP_FIREWALL_PROTECTION_URL === true ) {
  299. $ct_rules = array( 'absolute_path', 'ad_click', 'alert(', 'alert%20', ' and ', 'basepath', 'bash_history', '.bash_history', 'cgi-', 'chmod(', 'chmod%20', '%20chmod', 'chmod=', 'chown%20', 'chgrp%20', 'chown(', '/chown', 'chgrp(', 'chr(', 'chr=', 'chr%20', '%20chr', 'chunked', 'cookie=', 'cmd', 'cmd=', '%20cmd', 'cmd%20', '.conf', 'configdir', 'config.php', 'cp%20', '%20cp', 'cp(', 'diff%20', 'dat?', 'db_mysql.inc', 'document.location', 'document.cookie', 'drop%20', 'echr(', '%20echr', 'echr%20', 'echr=', '}else{', '.eml', 'esystem(', 'esystem%20', '.exe', 'exploit', 'file\://', 'fopen', 'fwrite', '~ftp', 'ftp:', 'ftp.exe', 'getenv', '%20getenv', 'getenv%20', 'getenv(', 'grep%20', '_global', 'global_', 'global[', 'http:', '_globals', 'globals_', 'globals[', 'grep(', 'g\+\+', 'halt%20', '.history', '?hl=', '.htpasswd', 'http_', 'http-equiv', 'http/1.', 'http_php', 'http_user_agent', 'http_host', '&icq', 'if{', 'if%20{', 'img src', 'img%20src', '.inc.php', '.inc', 'insert%20into', 'ISO-8859-1', 'ISO-', 'javascript\://', '.jsp', '.js', 'kill%20', 'kill(', 'killall', '%20like', 'like%20', 'locate%20', 'locate(', 'lsof%20', 'mdir%20', '%20mdir', 'mdir(', 'mcd%20', 'motd%20', 'mrd%20', 'rm%20', '%20mcd', '%20mrd', 'mcd(', 'mrd(', 'mcd=', 'mod_gzip_status', 'modules/', 'mrd=', 'mv%20', 'nc.exe', 'new_password', 'nigga(', '%20nigga', 'nigga%20', '~nobody', 'org.apache', '+outfile+', '%20outfile%20', '*/outfile/*',' outfile ','outfile', 'password=', 'passwd%20', '%20passwd', 'passwd(', 'phpadmin', 'perl%20', '/perl', 'phpbb_root_path','*/phpbb_root_path/*','p0hh', 'ping%20', '.pl', 'powerdown%20', 'rm(', '%20rm', 'rmdir%20', 'mv(', 'rmdir(', 'phpinfo()', '<?php', 'reboot%20', '/robot.txt' , '~root', 'root_path', 'rush=', '%20and%20', '%20xorg%20', '%20rush', 'rush%20', 'secure_site, ok', 'select%20', 'select from', 'select%20from', '_server', 'server_', 'server[', 'server-info', 'server-status', 'servlet', 'sql=', '<script', '<script>', '</script','script>','/script', 'switch{','switch%20{', '.system', 'system(', 'telnet%20', 'traceroute%20', '.txt', 'union%20', '%20union', 'union(', 'union=', 'vi(', 'vi%20', 'wget', 'wget%20', '%20wget', 'wget(', 'window.open', 'wwwacl', ' xor ', 'xp_enumdsn', 'xp_availablemedia', 'xp_filelist', 'xp_cmdshell', '$_request', '$_get', '$request', '$get', '&aim', '/etc/password','/etc/shadow', '/etc/groups', '/etc/gshadow', '/bin/ps', 'uname\x20-a', '/usr/bin/id', '/bin/echo', '/bin/kill', '/bin/', '/chgrp', '/usr/bin', 'bin/python', 'bin/tclsh', 'bin/nasm', '/usr/x11r6/bin/xterm', '/bin/mail', '/etc/passwd', '/home/ftp', '/home/www', '/servlet/con', '?>', '.txt');
  300. $check = str_replace($ct_rules, '*', PHP_FIREWALL_GET_QUERY_STRING );
  301. if( PHP_FIREWALL_GET_QUERY_STRING != $check ) {
  302. PHP_FIREWALL_LOGS( 'URL protect' );
  303. die( _PHPF_PROTECTION_URL );
  304. }
  305. }
  306.  
  307. /** Posting from other servers in not allowed */
  308. if ( PHP_FIREWALL_PROTECTION_REQUEST_SERVER === true ) {
  309. if ( PHP_FIREWALL_GET_REQUEST_METHOD == 'POST' ) {
  310. if (isset($_SERVER['HTTP_REFERER'])) {
  311. if ( ! stripos( $_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'], 0 ) ) {
  312. PHP_FIREWALL_LOGS( 'Posting another server' );
  313. die( _PHPF_PROTECTION_OTHER_SERVER );
  314. }
  315. }
  316. }
  317. }
  318.  
  319. /** protection contre le vers santy */
  320. if ( PHP_FIREWALL_PROTECTION_SANTY === true ) {
  321. $ct_rules = array('rush','highlight=%','perl','chr(','pillar','visualcoder','sess_');
  322. $check = str_replace($ct_rules, '*', strtolower(PHP_FIREWALL_REQUEST_URI) );
  323. if( strtolower(PHP_FIREWALL_REQUEST_URI) != $check ) {
  324. PHP_FIREWALL_LOGS( 'Santy' );
  325. die( _PHPF_PROTECTION_SANTY );
  326. }
  327. }
  328.  
  329. /** protection bots */
  330. if ( PHP_FIREWALL_PROTECTION_BOTS === true ) {
  331. $ct_rules = array( '@nonymouse', 'addresses.com', 'ideography.co.uk', 'adsarobot', 'ah-ha', 'aktuelles', 'alexibot', 'almaden', 'amzn_assoc', 'anarchie', 'art-online', 'aspseek', 'assort', 'asterias', 'attach', 'atomz', 'atspider', 'autoemailspider', 'backweb', 'backdoorbot', 'bandit', 'batchftp', 'bdfetch', 'big.brother', 'black.hole', 'blackwidow', 'blowfish', 'bmclient', 'boston project', 'botalot', 'bravobrian', 'buddy', 'bullseye', 'bumblebee ', 'builtbottough', 'bunnyslippers', 'capture', 'cegbfeieh', 'cherrypicker', 'cheesebot', 'chinaclaw', 'cicc', 'civa', 'clipping', 'collage', 'collector', 'copyrightcheck', 'cosmos', 'crescent', 'custo', 'cyberalert', 'deweb', 'diagem', 'digger', 'digimarc', 'diibot', 'directupdate', 'disco', 'dittospyder', 'download accelerator', 'download demon', 'download wonder', 'downloader', 'drip', 'dsurf', 'dts agent', 'dts.agent', 'easydl', 'ecatch', 'echo extense', 'efp@gmx.net', 'eirgrabber', 'elitesys', 'emailsiphon', 'emailwolf', 'envidiosos', 'erocrawler', 'esirover', 'express webpictures', 'extrac', 'eyenetie', 'fastlwspider', 'favorg', 'favorites sweeper', 'fetch', 'fezhead', 'filehound', 'filepack.superbr.org', 'flashget', 'flickbot', 'fluffy', 'frontpage', 'foobot', 'galaxyBot', 'generic', 'getbot ', 'getleft', 'getright', 'getsmart', 'geturl', 'getweb', 'gigabaz', 'girafabot', 'go-ahead-got-it', 'go!zilla', 'gornker', 'grabber', 'grabnet', 'grafula', 'green research', 'harvest', 'havindex', 'hhjhj@yahoo', 'hloader', 'hmview', 'homepagesearch', 'htmlparser', 'hulud', 'http agent', 'httpconnect', 'httpdown', 'http generic', 'httplib', 'httrack', 'humanlinks', 'ia_archiver', 'iaea', 'ibm_planetwide', 'image stripper', 'image sucker', 'imagefetch', 'incywincy', 'indy', 'infonavirobot', 'informant', 'interget', 'internet explore', 'infospiders', 'internet ninja', 'internetlinkagent', 'interneteseer.com', 'ipiumbot', 'iria', 'irvine', 'jbh', 'jeeves', 'jennybot', 'jetcar', 'joc web spider', 'jpeg hunt', 'justview', 'kapere', 'kdd explorer', 'kenjin.spider', 'keyword.density', 'kwebget', 'lachesis', 'larbin', 'laurion(dot)com', 'leechftp', 'lexibot', 'lftp', 'libweb', 'links aromatized', 'linkscan', 'link*sleuth', 'linkwalker', 'libwww', 'lightningdownload', 'likse', 'lwp','mac finder', 'mag-net', 'magnet', 'marcopolo', 'mass', 'mata.hari', 'mcspider', 'memoweb', 'microsoft url control', 'microsoft.url', 'midown', 'miixpc', 'minibot', 'mirror', 'missigua', 'mister.pix', 'mmmtocrawl', 'moget', 'mozilla/2', 'mozilla/3.mozilla/2.01', 'mozilla.*newt', 'multithreaddb', 'munky', 'msproxy', 'nationaldirectory', 'naverrobot', 'navroad', 'nearsite', 'netants', 'netcarta', 'netcraft', 'netfactual', 'netmechanic', 'netprospector', 'netresearchserver', 'netspider', 'net vampire', 'newt', 'netzip', 'nicerspro', 'npbot', 'octopus', 'offline.explorer', 'offline explorer', 'offline navigator', 'opaL', 'openfind', 'opentextsitecrawler', 'orangebot', 'packrat', 'papa foto', 'pagegrabber', 'pavuk', 'pbwf', 'pcbrowser', 'personapilot', 'pingalink', 'pockey', 'program shareware', 'propowerbot/2.14', 'prowebwalker', 'proxy', 'psbot', 'psurf', 'puf', 'pushsite', 'pump', 'qrva', 'quepasacreep', 'queryn.metasearch', 'realdownload', 'reaper', 'recorder', 'reget', 'replacer', 'repomonkey', 'rma', 'robozilla', 'rover', 'rpt-httpclient', 'rsync', 'rush=', 'searchexpress', 'searchhippo', 'searchterms.it', 'second street research', 'seeker', 'shai', 'sitecheck', 'sitemapper', 'sitesnagger', 'slysearch', 'smartdownload', 'snagger', 'spacebison', 'spankbot', 'spanner', 'spegla', 'spiderbot', 'spiderengine', 'sqworm', 'ssearcher100', 'star downloader', 'stripper', 'sucker', 'superbot', 'surfwalker', 'superhttp', 'surfbot', 'surveybot', 'suzuran', 'sweeper', 'szukacz/1.4', 'tarspider', 'takeout', 'teleport', 'telesoft', 'templeton', 'the.intraformant', 'thenomad', 'tighttwatbot', 'titan', 'tocrawl/urldispatcher','toolpak', 'traffixer', 'true_robot', 'turingos', 'turnitinbot', 'tv33_mercator', 'uiowacrawler', 'urldispatcherlll', 'url_spider_pro', 'urly.warning ', 'utilmind', 'vacuum', 'vagabondo', 'vayala', 'vci', 'visualcoders', 'visibilitygap', 'vobsub', 'voideye', 'vspider', 'w3mir', 'webauto', 'webbandit', 'web.by.mail', 'webcapture', 'webcatcher', 'webclipping', 'webcollage', 'webcopier', 'webcopy', 'webcraft@bea', 'web data extractor', 'webdav', 'webdevil', 'webdownloader', 'webdup', 'webenhancer', 'webfetch', 'webgo', 'webhook', 'web.image.collector', 'web image collector', 'webinator', 'webleacher', 'webmasters', 'webmasterworldforumbot', 'webminer', 'webmirror', 'webmole', 'webreaper', 'websauger', 'websaver', 'website.quester', 'website quester', 'websnake', 'websucker', 'web sucker', 'webster', 'webreaper', 'webstripper', 'webvac', 'webwalk', 'webweasel', 'webzip', 'wget', 'widow', 'wisebot', 'whizbang', 'whostalking', 'wonder', 'wumpus', 'wweb', 'www-collector-e', 'wwwoffle', 'wysigot', 'xaldon', 'xenu', 'xget', 'x-tractor', 'zeus' );
  332. $check = str_replace($ct_rules, '*', strtolower(PHP_FIREWALL_USER_AGENT) );
  333. if( strtolower(PHP_FIREWALL_USER_AGENT) != $check ) {
  334. PHP_FIREWALL_LOGS( 'Bots attack' );
  335. die( _PHPF_PROTECTION_BOTS );
  336. }
  337. }
  338.  
  339. /** Invalid request method check */
  340. if ( PHP_FIREWALL_PROTECTION_REQUEST_METHOD === true ) {
  341. if(strtolower(PHP_FIREWALL_GET_REQUEST_METHOD)!='get' AND strtolower(PHP_FIREWALL_GET_REQUEST_METHOD)!='head' AND strtolower(PHP_FIREWALL_GET_REQUEST_METHOD)!='post' AND strtolower(PHP_FIREWALL_GET_REQUEST_METHOD)!='put') {
  342. PHP_FIREWALL_LOGS( 'Invalid request' );
  343. die( _PHPF_PROTECTION_REQUEST );
  344. }
  345. }
  346.  
  347. /** protection dos attaque */
  348. if ( PHP_FIREWALL_PROTECTION_DOS === true ) {
  349. if ( !defined('PHP_FIREWALL_USER_AGENT') || PHP_FIREWALL_USER_AGENT == '-' ) {
  350. PHP_FIREWALL_LOGS( 'Dos attack' );
  351. die( _PHPF_PROTECTION_DOS );
  352. }
  353. }
  354.  
  355. /** protection union sql attaque */
  356. if ( PHP_FIREWALL_PROTECTION_UNION_SQL === true ) {
  357. $stop = 0;
  358. $ct_rules = array( '*/from/*', '*/insert/*', '+into+', '%20into%20', '*/into/*', ' into ', 'into', '*/limit/*', 'not123exists*', '*/radminsuper/*', '*/select/*', '+select+', '%20select%20', ' select ', '+union+', '%20union%20', '*/union/*', ' union ', '*/update/*', '*/where/*' );
  359. $check = str_replace($ct_rules, '*', PHP_FIREWALL_GET_QUERY_STRING );
  360. if( PHP_FIREWALL_GET_QUERY_STRING != $check ) $stop++;
  361. if (preg_match(PHP_FIREWALL_REGEX_UNION, PHP_FIREWALL_GET_QUERY_STRING)) $stop++;
  362. if (preg_match('/([OdWo5NIbpuU4V2iJT0n]{5}) /', rawurldecode( PHP_FIREWALL_GET_QUERY_STRING ))) $stop++;
  363. if (strstr(rawurldecode( PHP_FIREWALL_GET_QUERY_STRING ) ,'*')) $stop++;
  364. if ( !empty( $stop ) ) {
  365. PHP_FIREWALL_LOGS( 'Union attack' );
  366. die( _PHPF_PROTECTION_UNION );
  367. }
  368. }
  369.  
  370. /** protection click attack */
  371. if ( PHP_FIREWALL_PROTECTION_CLICK_ATTACK === true ) {
  372. $ct_rules = array( '/*', 'c2nyaxb0', '/*' );
  373. if( PHP_FIREWALL_GET_QUERY_STRING != str_replace($ct_rules, '*', PHP_FIREWALL_GET_QUERY_STRING ) ) {
  374. PHP_FIREWALL_LOGS( 'Click attack' );
  375. die( _PHPF_PROTECTION_CLICK );
  376. }
  377. }
  378.  
  379. /** protection XSS attack */
  380. if ( PHP_FIREWALL_PROTECTION_XSS_ATTACK === true ) {
  381. $ct_rules = array( 'http\:\/\/', 'https\:\/\/', 'cmd=', '&cmd', 'exec', 'concat', './', '../', 'http:', 'h%20ttp:', 'ht%20tp:', 'htt%20p:', 'http%20:', 'https:', 'h%20ttps:', 'ht%20tps:', 'htt%20ps:', 'http%20s:', 'https%20:', 'ftp:', 'f%20tp:', 'ft%20p:', 'ftp%20:', 'ftps:', 'f%20tps:', 'ft%20ps:', 'ftp%20s:', 'ftps%20:', '.php?url=' );
  382. $check = str_replace($ct_rules, '*', PHP_FIREWALL_GET_QUERY_STRING );
  383. if( PHP_FIREWALL_GET_QUERY_STRING != $check ) {
  384. PHP_FIREWALL_LOGS( 'XSS attack' );
  385. die( _PHPF_PROTECTION_XSS );
  386. }
  387. }
  388.  
  389. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement