Skip to content

Commit

Permalink
failing to pass challenge 10 times results in a 1 hr ban
Browse files Browse the repository at this point in the history
  • Loading branch information
cvweiss committed Aug 20, 2018
1 parent ff79c66 commit b407466
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions index.php
Expand Up @@ -9,11 +9,6 @@
$isApiRequest = substr($uri, 0, 5) == "/api/";


/*if (substr($uri, 0, 12) == "/api/killID/") {
header("HTTP/1.1 400 Disabling /api/killID/ because of abuse.");
die();
}*/

if ($uri == "/kill/-1/") {
header("Location: /keepstar1.html");
exit();
Expand Down Expand Up @@ -57,7 +52,7 @@
$ip = $ipE[0];

if ($redis->get("IP:ban:$ip") == "true") {
header('HTTP/1.1 403 IP has been temporarily banned due to excessive errors');
header('HTTP/1.1 403 IP has been temporarily banned due to excessive errors or failure to pass challenge.');
return;
}

Expand All @@ -79,6 +74,13 @@
// Scrape Checker
$ipKey = "ip::$ip";
if ($redis->get("ip::redirect::$ip") != null) {
$redis->incr("ip::redirect::$ip:challenges");
$redis->expire("ip::redirect::$ip:challenges", 3600);
if ($redis->get("ip::redirect::$ip:challenges" > 10)) {
Log::log("Banning $ip for failing to pass challenges");
$redis->setex("IP:ban:$ip", 9600, "true");
return;
}
header("Location: /challenge/", true, 302);
return;
}
Expand Down

0 comments on commit b407466

Please sign in to comment.