parent
b75fe92b18
commit
ea755600ad
2 changed files with 3425 additions and 1275 deletions
|
|
@ -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)
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -644,7 +644,6 @@ class frontend{
|
|||
"google_cse" => "Google CSE",
|
||||
"yahoo_japan" => "Yahoo! JAPAN",
|
||||
"startpage" => "Startpage",
|
||||
"qwant" => "Qwant",
|
||||
"yep" => "Yep",
|
||||
"mwmbl" => "Mwmbl",
|
||||
"mojeek" => "Mojeek",
|
||||
|
|
@ -671,7 +670,6 @@ class frontend{
|
|||
"google_cse" => "Google CSE",
|
||||
"yahoo_japan" => "Yahoo! JAPAN",
|
||||
"startpage" => "Startpage",
|
||||
"qwant" => "Qwant",
|
||||
"naver" => "Naver",
|
||||
"baidu" => "Baidu",
|
||||
"solofield" => "Solofield",
|
||||
|
|
@ -705,7 +703,6 @@ class frontend{
|
|||
"google" => "Google",
|
||||
"yahoo_japan" => "Yahoo! JAPAN",
|
||||
"startpage" => "Startpage",
|
||||
"qwant" => "Qwant",
|
||||
"naver" => "Naver",
|
||||
"baidu" => "Baidu",
|
||||
"coccoc" => "Cốc Cốc",
|
||||
|
|
@ -724,7 +721,6 @@ class frontend{
|
|||
"google" => "Google",
|
||||
"yahoo_japan" => "Yahoo! JAPAN",
|
||||
"startpage" => "Startpage",
|
||||
"qwant" => "Qwant",
|
||||
//"mojeek" => "Mojeek",
|
||||
"baidu" => "Baidu"
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in a new issue