Skip to content
This repository has been archived by the owner on Jan 31, 2023. It is now read-only.

Commit

Permalink
Added array for known bad ips
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler J committed Aug 8, 2017
1 parent 9944d0a commit d4ce654
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"require": {
"php": ">=5.3.0"
},
Expand Down
25 changes: 25 additions & 0 deletions src/NoBadBots/BeGone.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
class BeGone {

public static $uas = ['headlesschrome','gotnoheadeua','nikto','sqlmap','curl','planetwork','purebot','pycurl','skygrid','sucker','turnit','vikspid','zmeu','zune','dotbot','feedfinder','flicky','ia_archiver','kmccrew','libwww','nutch','binlar','casper','checkprivacy','cmsworldmap','comodo','curious','diavol','doco','ZmEu','python'];
public static $bips = ['178.79.138.22'];

public static $badness = 0;

Expand All @@ -24,6 +25,16 @@ public static function shoo() {
}
}

if(!empty($_SERVER['REMOTE_ADDR'])){
foreach(self::$bips as $ip){
if(self::getUserIP() == $ua) {
self::$badness++;
}
}
} else {
self::$badness++;
}

return self::$badness;
}

Expand All @@ -34,4 +45,18 @@ public static function bomb(){
if (ob_get_level()) ob_end_clean();
readfile('10G.gzip');
}

public static function getUserIP() {
if( array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ) {
if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',')>0) {
$addr = explode(",",$_SERVER['HTTP_X_FORWARDED_FOR']);
return trim($addr[0]);
} else {
return $_SERVER['HTTP_X_FORWARDED_FOR'];
}
}
else {
return $_SERVER['REMOTE_ADDR'];
}
}
}

0 comments on commit d4ce654

Please sign in to comment.