From 3aa01807741ffad103b9f6a74d878e58f2e828e8 Mon Sep 17 00:00:00 2001 From: lolcat Date: Mon, 16 Oct 2023 02:30:43 -0400 Subject: captcha and imgur, findthatmeme, yep imagesearch --- lib/captcha_gen.php | 325 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 325 insertions(+) create mode 100644 lib/captcha_gen.php (limited to 'lib/captcha_gen.php') diff --git a/lib/captcha_gen.php b/lib/captcha_gen.php new file mode 100644 index 0000000..2ae824b --- /dev/null +++ b/lib/captcha_gen.php @@ -0,0 +1,325 @@ += 102){ + + // reached limit, delete and give captcha + apcu_delete($_COOKIE["pass"]); + }else{ + + // the cookie is OK! dont die() and give results + if($output === true){ + $frontend->loadheader( + $get, + $filters, + $page + ); + } + return; + } + } + } + + if($output === false){ + + echo json_encode([ + "status" => "The \"pass\" token in your cookies is missing or has expired!!" + ]); + die(); + } + + /* + Validate form data + */ + $lines = + explode( + "\r\n", + file_get_contents("php://input") + ); + + $invalid = false; + $answers = []; + $key = false; + $error = ""; + + foreach($lines as $line){ + + $line = explode("=", $line, 2); + + if(count($line) !== 2){ + + $invalid = true; + break; + } + + preg_match( + '/^c\[([0-9]+)\]$/', + $line[0], + $regex + ); + + if( + $line[1] != "on" || + !isset($regex[0][1]) + ){ + + // check if its k + if( + $line[0] == "k" && + strpos($line[1], "c.") === 0 + ){ + + $key = apcu_fetch($line[1]); + apcu_delete($line[1]); + } + break; + } + + $regex = (int)$regex[1]; + + if( + $regex >= 16 || + $regex <= -1 + ){ + + $invalid = true; + break; + } + + $answers[] = $regex; + } + + if( + !$invalid && + $key !== false + ){ + $check = $key[1]; + + // validate answer + for($i=0; $i time() + 86400, // expires in 24 hours + "samesite" => "Strict", + "path" => "/" + ] + ); + + $frontend->loadheader( + $get, + $filters, + $page + ); + return; + + }else{ + + $error = "
You were kicked out of Mensa. Please try again.
"; + } + } + + /* + Generate random grid data to pass to captcha.php + */ + $dataset = [ + ["birds", 2263], + ["fumo_plushies", 1006], + ["minecraft", 848] + ]; + + // get the positions for the answers + // will return between 3 and 6 answer positions + $range = range(0, 15); + $answer_pos = []; + + array_splice($range, 0, 1); + + for($i=0; $i "", + "right-left" => "", + "right-right" => "", + "left" => + '
' . + '

IQ test

' . + 'Due to getting hit with 20,000 bot requests per day, I had to put this up. Sorry.

' . + 'Solving this captcha will allow you to make 100 searches today. I will add a way for legit users to bypass the captcha later. Sorry /g/tards!!' . + $error . + '
' . + '
' . + '
' . + 'Captcha image' . + '
' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '' . + '
' . + '
' . + '
' . + '' . + '' . + '
' . + '
' + ]; + + http_response_code(429); // too many reqs + $frontend->loadheader( + $get, + $filters, + "web" + ); + + echo $frontend->load("search.html", $payload); + die(); + } +} -- cgit v1.2.3