@@ 977-1019 (lines=43) @@ | ||
974 | // F5 attack check (High load & same URI) |
|
975 | $result = $db->query("SELECT COUNT(*) FROM " . $db->prefix($this->mydirname . "_access") . " WHERE ip='$ip4sql' AND request_uri='$uri4sql'"); |
|
976 | list($f5_count) = $db->fetchRow($result); |
|
977 | if ($f5_count > $this->_conf['dos_f5count']) { |
|
978 | ||
979 | // delayed insert |
|
980 | $db->queryF($sql4insertlog); |
|
981 | ||
982 | // extends the expires of the IP with 5 minutes at least (pending) |
|
983 | // $result = $xoopsDB->queryF( "UPDATE ".$xoopsDB->prefix($this->mydirname."_access")." SET expire=UNIX_TIMESTAMP()+300 WHERE ip='$ip4sql' AND expire<UNIX_TIMESTAMP()+300" ) ; |
|
984 | ||
985 | // call the filter first |
|
986 | $ret = $this->call_filter('f5attack_overrun'); |
|
987 | ||
988 | // actions for F5 Attack |
|
989 | $this->_done_dos = true; |
|
990 | $this->last_error_type = 'DoS'; |
|
991 | switch ($this->_conf['dos_f5action']) { |
|
992 | default : |
|
993 | case 'exit' : |
|
994 | $this->output_log($this->last_error_type, $uid, true, 16); |
|
995 | exit; |
|
996 | case 'none' : |
|
997 | $this->output_log($this->last_error_type, $uid, true, 16); |
|
998 | return true; |
|
999 | case 'biptime0' : |
|
1000 | if ($can_ban) { |
|
1001 | $this->register_bad_ips(time() + $this->_conf['banip_time0']); |
|
1002 | } |
|
1003 | break; |
|
1004 | case 'bip' : |
|
1005 | if ($can_ban) { |
|
1006 | $this->register_bad_ips(); |
|
1007 | } |
|
1008 | break; |
|
1009 | case 'hta' : |
|
1010 | if ($can_ban) { |
|
1011 | $this->deny_by_htaccess(); |
|
1012 | } |
|
1013 | break; |
|
1014 | case 'sleep' : |
|
1015 | sleep(5); |
|
1016 | break; |
|
1017 | } |
|
1018 | return false; |
|
1019 | } |
|
1020 | ||
1021 | // Check its Agent |
|
1022 | if (trim($this->_conf['dos_crsafe']) != '' && preg_match($this->_conf['dos_crsafe'], @$_SERVER['HTTP_USER_AGENT'])) { |
|
@@ 1035-1071 (lines=37) @@ | ||
1032 | // delayed insert |
|
1033 | $db->queryF($sql4insertlog); |
|
1034 | ||
1035 | if ($crawler_count > $this->_conf['dos_crcount']) { |
|
1036 | ||
1037 | // call the filter first |
|
1038 | $ret = $this->call_filter('crawler_overrun'); |
|
1039 | ||
1040 | // actions for bad Crawler |
|
1041 | $this->_done_dos = true; |
|
1042 | $this->last_error_type = 'CRAWLER'; |
|
1043 | switch ($this->_conf['dos_craction']) { |
|
1044 | default : |
|
1045 | case 'exit' : |
|
1046 | $this->output_log($this->last_error_type, $uid, true, 16); |
|
1047 | exit; |
|
1048 | case 'none' : |
|
1049 | $this->output_log($this->last_error_type, $uid, true, 16); |
|
1050 | return true; |
|
1051 | case 'biptime0' : |
|
1052 | if ($can_ban) { |
|
1053 | $this->register_bad_ips(time() + $this->_conf['banip_time0']); |
|
1054 | } |
|
1055 | break; |
|
1056 | case 'bip' : |
|
1057 | if ($can_ban) { |
|
1058 | $this->register_bad_ips(); |
|
1059 | } |
|
1060 | break; |
|
1061 | case 'hta' : |
|
1062 | if ($can_ban) { |
|
1063 | $this->deny_by_htaccess(); |
|
1064 | } |
|
1065 | break; |
|
1066 | case 'sleep' : |
|
1067 | sleep(5); |
|
1068 | break; |
|
1069 | } |
|
1070 | return false; |
|
1071 | } |
|
1072 | ||
1073 | return true; |
|
1074 | } |