Created
August 13, 2017 23:07
-
-
Save Q0/8fe28d6e311bf473df33df7433e70800 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class XORFUNC | |
{ | |
public static function XOR_encrypt($message, $key) | |
{ | |
$ml = strlen($message); | |
$kl = strlen($key); | |
$newmsg = ""; | |
for ($i = 0; $i < $ml; $i++) { | |
$newmsg = $newmsg . ($message[$i] ^ $key[$i % $kl]); | |
} | |
return base64_encode($newmsg); | |
} | |
public static function XOR_decrypt($encrypted_message, $key) | |
{ | |
$msg = base64_decode($encrypted_message); | |
$ml = strlen($msg); | |
$kl = strlen($key); | |
$newmsg = ""; | |
for ($i = 0; $i < $ml; $i++) { | |
$newmsg = $newmsg . ($msg[$i] ^ $key[$i % $kl]); | |
} | |
return $newmsg; | |
} | |
} | |
function initme($vkid, $key, $botid) | |
{ | |
$getuid = file_get_contents('http://iii.ru/api/2.0/json/Chat.init/' . $botid . '/' . $vkid); | |
$jsonparam = json_decode(base64_decode(XORFUNC::XOR_decrypt($getuid, $key))); | |
return $jsonparam; | |
} | |
$config['botid'] = "970c8b3d-2e25-471d-8aab-efc87bcb7155"; | |
$config['url'] = 'http://' . $_SERVER['HTTP_HOST']; | |
$config['key'] = "some very-very long string without any non-latin characters due to different string representations inside of variable programming languages"; | |
$klush = md5($_SERVER["REMOTE_ADDR"]); | |
if (!file_exists($klush)) { | |
$fp = fopen($klush, "w"); | |
$data = initme(12, $config['key'], $config['botid']); | |
file_put_contents($klush, $data->result->cuid); | |
} | |
$session = file_get_contents($klush); | |
$vopros = "Привет!"; | |
$whattosend = '["' . $session . '","' . urldecode($vopros) . '"]'; | |
$hashed = XORFUNC::XOR_encrypt(base64_encode($whattosend), $config['key']); | |
$myCurl = curl_init(); | |
curl_setopt_array($myCurl, array( | |
CURLOPT_URL => 'http://iii.ru/api/2.0/json/Chat.request', | |
CURLOPT_RETURNTRANSFER => true, | |
CURLOPT_POST => true, | |
CURLOPT_POSTFIELDS => $hashed | |
)); | |
$response = curl_exec($myCurl); | |
curl_close($myCurl); | |
$answer = json_decode(base64_decode(XORFUNC::XOR_decrypt($response, $config['key']))); | |
$otvet = $answer->result->text->value; | |
echo $otvet; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment