From 01d46386871b41a37fdbcbcf205f9915d192c198 Mon Sep 17 00:00:00 2001 From: lolcat Date: Fri, 14 Aug 2026 19:54:26 -0400 Subject: [PATCH] maybe i should push the anubis code first you fucking moron --- lib/anubis.php | 13 ++++++++----- scraper/startpage.php | 38 +++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/lib/anubis.php b/lib/anubis.php index 2bd6d90..97efc73 100644 --- a/lib/anubis.php +++ b/lib/anubis.php @@ -45,15 +45,15 @@ class anubis{ if( !isset($script["challenge"]) || + !is_string($script["challenge"]["randomData"]) || !isset($script["rules"]["difficulty"]) || - !is_int($script["rules"]["difficulty"]) || - !is_string($script["challenge"]) + !is_int($script["rules"]["difficulty"]) ){ throw new Exception("Found invalid challenge data"); } - return $this->rape($script["challenge"], $script["rules"]["difficulty"]); + return $this->rape($script["challenge"]["id"], $script["challenge"]["randomData"], $script["rules"]["difficulty"]); } private function is_valid_hash($hash, $difficulty){ @@ -74,9 +74,10 @@ class anubis{ return true; } - public function rape($data, $difficulty = 5){ + public function rape($id, $data, $difficulty = 5){ $nonce = 0; + $microtime = microtime(true); while(true){ @@ -87,10 +88,12 @@ class anubis{ $hash_hex = bin2hex($hash_binary); return [ + "id" => $id, "response" => $hash_hex, //"data" => $data, //"difficulty" => $difficulty, - "nonce" => $nonce + "nonce" => $nonce, + "elapsedTime" => round((microtime(true) - $microtime) * 1000) ]; } diff --git a/scraper/startpage.php b/scraper/startpage.php index df31766..a721574 100644 --- a/scraper/startpage.php +++ b/scraper/startpage.php @@ -12,6 +12,7 @@ class startpage{ include "lib/anubis.php"; $this->anubis = new anubis(); + $this->anubis_error = "all gucci"; } public function getfilters($page){ @@ -391,7 +392,7 @@ class startpage{ if($get["npt"]){ - $anubis_error = "Not ran on pagination"; + $this->anubis_error = "Not ran on pagination"; [$post, $proxy] = $this->backend->get($get["npt"], "web"); $post = json_decode($post, true); @@ -485,7 +486,7 @@ class startpage{ ); }catch(Exception $error){ - throw new Exception("Failed to re-fetch search page"); + throw new Exception("Failed to re-fetch search page. Anubis error: {$this->anubis_error}"); } } } @@ -503,14 +504,14 @@ class startpage{ ) === 0 ){ - throw new Exception("Failed to grep JSON object. Anubis error: $anubis_error"); + throw new Exception("Failed to grep JSON object. Anubis error: {$this->anubis_error}"); } $json = json_decode($matches[1], true); if($json === null){ - throw new Exception("Failed to decode JSON. Anubis error: $anubis_error"); + throw new Exception("Failed to decode JSON. Anubis error: {$this->anubis_error}"); } //print_r($json); @@ -741,7 +742,7 @@ class startpage{ if($get["npt"]){ - $anubis_error = "Not ran on pagination"; + $this->anubis_error = "Not ran on pagination"; [$post, $proxy] = $this->backend->get($get["npt"], "images"); $post = json_decode($post, true); @@ -865,7 +866,7 @@ class startpage{ ); }catch(Exception $error){ - throw new Exception("Failed to re-fetch search page"); + throw new Exception("Failed to re-fetch search page. Anubis error: {$this->anubis_error}"); } } } @@ -886,14 +887,14 @@ class startpage{ ) === 0 ){ - throw new Exception("Failed to grep JSON object"); + throw new Exception("Failed to grep JSON object. Anubis error: {$this->anubis_error}"); } $json = json_decode($matches[1], true); if($json === null){ - throw new Exception("Failed to decode JSON object"); + throw new Exception("Failed to decode JSON object. Anubis error: {$this->anubis_error}"); } // get npt @@ -936,7 +937,7 @@ class startpage{ if($get["npt"]){ - $anubis_error = "Not ran on pagination"; + $this->anubis_error = "Not ran on pagination"; [$post, $proxy] = $this->backend->get($get["npt"], "videos"); $post = json_decode($post, true); @@ -1030,7 +1031,7 @@ class startpage{ ); }catch(Exception $error){ - throw new Exception("Failed to re-fetch search page"); + throw new Exception("Failed to re-fetch search page. Anubis error: {$this->anubis_error}"); } } } @@ -1045,14 +1046,14 @@ class startpage{ ) === 0 ){ - throw new Exception("Failed to get JSON object"); + throw new Exception("Failed to get JSON object. Anubis error: {$this->anubis_error}"); } $json = json_decode($matches[1], true); if($json === null){ - throw new Exception("Failed to decode JSON object"); + throw new Exception("Failed to decode JSON object. Anubis error: {$this->anubis_error}"); } $out = [ @@ -1122,7 +1123,7 @@ class startpage{ if($get["npt"]){ - $anubis_error = "Not ran on pagination"; + $this->anubis_error = "Not ran on pagination"; [$post, $proxy] = $this->backend->get($get["npt"], "news"); $post = json_decode($post, true); @@ -1182,7 +1183,7 @@ class startpage{ ); }catch(Exception $error){ - throw new Exception("Failed to fetch search page"); + throw new Exception("Failed to fetch search page. Anubis error: {$this->anubis_error}"); } //$html = file_get_contents("scraper/startpage.html"); @@ -1211,7 +1212,7 @@ class startpage{ ); }catch(Exception $error){ - throw new Exception("Failed to re-fetch search page"); + throw new Exception("Failed to re-fetch search page. Anubis error: {$this->anubis_error}"); } } } @@ -1226,14 +1227,14 @@ class startpage{ ) === 0 ){ - throw new Exception("Failed to get JSON object"); + throw new Exception("Failed to get JSON object. Anubis error: {$this->anubis_error}"); } $json = json_decode($matches[1], true); if($json === null){ - throw new Exception("Failed to decode JSON object"); + throw new Exception("Failed to decode JSON object. Anubis error: {$this->anubis_error}"); } $out = [ @@ -1466,7 +1467,6 @@ class startpage{ // // solve anubis challenge, if theres one // - $anubis_error = "all gucci"; $res = null; $cookies = []; @@ -1476,7 +1476,7 @@ class startpage{ }catch(Exception $error){ // do nothang - $anubis_error = $error->getMessage(); + $this->anubis_error = $error->getMessage(); } if($res !== null){