| @@ 1204-1248 (lines=45) @@ | ||
| 1201 | 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix($this->mydirname . '_access') |
|
| 1202 | . " WHERE ip={$ip4sql} AND request_uri={$uri4sql}"); |
|
| 1203 | list($f5_count) = $xoopsDB->fetchRow($result); |
|
| 1204 | if ($f5_count > $this->_conf['dos_f5count']) { |
|
| 1205 | ||
| 1206 | // delayed insert |
|
| 1207 | $xoopsDB->queryF($sql4insertlog); |
|
| 1208 | ||
| 1209 | // extends the expires of the IP with 5 minutes at least (pending) |
|
| 1210 | // $result = $xoopsDB->queryF( "UPDATE ".$xoopsDB->prefix($this->mydirname.'_access')." SET expire=UNIX_TIMESTAMP()+300 WHERE ip='$ip4sql' AND expire<UNIX_TIMESTAMP()+300" ) ; |
|
| 1211 | ||
| 1212 | // call the filter first |
|
| 1213 | $ret = $this->call_filter('f5attack_overrun'); |
|
| 1214 | ||
| 1215 | // actions for F5 Attack |
|
| 1216 | $this->_done_dos = true; |
|
| 1217 | $this->last_error_type = 'DoS'; |
|
| 1218 | switch ($this->_conf['dos_f5action']) { |
|
| 1219 | default : |
|
| 1220 | case 'exit' : |
|
| 1221 | $this->output_log($this->last_error_type, $uid, true, 16); |
|
| 1222 | exit; |
|
| 1223 | case 'none' : |
|
| 1224 | $this->output_log($this->last_error_type, $uid, true, 16); |
|
| 1225 | ||
| 1226 | return true; |
|
| 1227 | case 'biptime0' : |
|
| 1228 | if ($can_ban) { |
|
| 1229 | $this->register_bad_ips(time() + $this->_conf['banip_time0']); |
|
| 1230 | } |
|
| 1231 | break; |
|
| 1232 | case 'bip' : |
|
| 1233 | if ($can_ban) { |
|
| 1234 | $this->register_bad_ips(); |
|
| 1235 | } |
|
| 1236 | break; |
|
| 1237 | case 'hta' : |
|
| 1238 | if ($can_ban) { |
|
| 1239 | $this->deny_by_htaccess(); |
|
| 1240 | } |
|
| 1241 | break; |
|
| 1242 | case 'sleep' : |
|
| 1243 | sleep(5); |
|
| 1244 | break; |
|
| 1245 | } |
|
| 1246 | ||
| 1247 | return false; |
|
| 1248 | } |
|
| 1249 | ||
| 1250 | // Check its Agent |
|
| 1251 | if (trim($this->_conf['dos_crsafe']) != '' && preg_match($this->_conf['dos_crsafe'], @$_SERVER['HTTP_USER_AGENT'])) { |
|
| @@ 1267-1305 (lines=39) @@ | ||
| 1264 | // delayed insert |
|
| 1265 | $xoopsDB->queryF($sql4insertlog); |
|
| 1266 | ||
| 1267 | if ($crawler_count > $this->_conf['dos_crcount']) { |
|
| 1268 | ||
| 1269 | // call the filter first |
|
| 1270 | $ret = $this->call_filter('crawler_overrun'); |
|
| 1271 | ||
| 1272 | // actions for bad Crawler |
|
| 1273 | $this->_done_dos = true; |
|
| 1274 | $this->last_error_type = 'CRAWLER'; |
|
| 1275 | switch ($this->_conf['dos_craction']) { |
|
| 1276 | default : |
|
| 1277 | case 'exit' : |
|
| 1278 | $this->output_log($this->last_error_type, $uid, true, 16); |
|
| 1279 | exit; |
|
| 1280 | case 'none' : |
|
| 1281 | $this->output_log($this->last_error_type, $uid, true, 16); |
|
| 1282 | ||
| 1283 | return true; |
|
| 1284 | case 'biptime0' : |
|
| 1285 | if ($can_ban) { |
|
| 1286 | $this->register_bad_ips(time() + $this->_conf['banip_time0']); |
|
| 1287 | } |
|
| 1288 | break; |
|
| 1289 | case 'bip' : |
|
| 1290 | if ($can_ban) { |
|
| 1291 | $this->register_bad_ips(); |
|
| 1292 | } |
|
| 1293 | break; |
|
| 1294 | case 'hta' : |
|
| 1295 | if ($can_ban) { |
|
| 1296 | $this->deny_by_htaccess(); |
|
| 1297 | } |
|
| 1298 | break; |
|
| 1299 | case 'sleep' : |
|
| 1300 | sleep(5); |
|
| 1301 | break; |
|
| 1302 | } |
|
| 1303 | ||
| 1304 | return false; |
|
| 1305 | } |
|
| 1306 | ||
| 1307 | return true; |
|
| 1308 | } |
|