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 ++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/curlproxy.php | 5 + lib/frontend.php | 26 ++++- lib/nextpage.php | 2 +- 4 files changed, 356 insertions(+), 2 deletions(-) create mode 100644 lib/captcha_gen.php (limited to 'lib') 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(); + } +} diff --git a/lib/curlproxy.php b/lib/curlproxy.php index 93cdbdc..ef9085b 100644 --- a/lib/curlproxy.php +++ b/lib/curlproxy.php @@ -127,6 +127,11 @@ class proxy{ throw new Exception("Too many redirects"); } + if($url == "https://i.imgur.com/removed.png"){ + + throw new Exception("Encountered imgur 404"); + } + // sanitize URL if($this->validateurl($url) === false){ diff --git a/lib/frontend.php b/lib/frontend.php index 4c5e232..97c8c5b 100644 --- a/lib/frontend.php +++ b/lib/frontend.php @@ -901,7 +901,11 @@ class frontend{ "ddg" => "DuckDuckGo", "yandex" => "Yandex", "brave" => "Brave", - "google" => "Google" + "google" => "Google", + "yep" => "Yep", + //"pinterest" => "Pinterest", + "imgur" => "Imgur", + "ftm" => "FindThatMeme" ] ]; break; @@ -1011,10 +1015,30 @@ class frontend{ $lib = new wiby(); break; + case "yep": + include "scraper/yep.php"; + $lib = new yep(); + break; + case "sc": include "scraper/sc.php"; $lib = new sc(); break; + + case "pinterest": + include "scraper/pinterest.php"; + $lib = new pinterest(); + break; + + case "imgur": + include "scraper/imgur.php"; + $lib = new imgur(); + break; + + case "ftm": + include "scraper/ftm.php"; + $lib = new ftm(); + break; } // set scraper on $_GET diff --git a/lib/nextpage.php b/lib/nextpage.php index 3fab855..7516667 100644 --- a/lib/nextpage.php +++ b/lib/nextpage.php @@ -26,7 +26,7 @@ class nextpage{ apcu_store( $page . "." . $this->scraper . - (string)($key), + (string)$key, gzdeflate($salt.$iv.$out.$tag), 900 // cache information for 15 minutes blaze it ); -- cgit v1.2.3