Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function fwrite_stream($fp, $string) {
- for ($written = 0; $written < strlen($string); $written += $fwrite) {
- $fwrite = fwrite($fp, substr($string, $written));
- if ($fwrite === false) {
- return $written;
- }
- }
- return $written;
- }
- function strhex($string) {
- $hexstr = unpack('H*', $string);
- return trim(array_shift($hexstr));
- }
- function hexstr($hexstr) {
- $hexstr = str_replace(' ', '', $hexstr);
- return trim(pack('H*', $hexstr));
- }
- function toPacket($hex)
- {
- $hex = str_replace(" ", "", $hex);
- return pack("H*",$hex);
- }
- function sendData($hex)
- {
- $fp = stream_socket_client("tcp://67.159.44.212:10001", $errno, $errstr, 5, STREAM_CLIENT_CONNECT);
- if (!$fp)
- {
- echo "$errstr ($errno)<br />\n";
- }
- else
- {
- fwrite_stream($fp, toPacket($hex));
- $return = fread($fp, 1024);
- fclose($fp);
- }
- return strhex($return);
- }
- function XORDecrypt($InputString, $KeyPhrase, $plus)
- {
- $KeyPhrase = chr(ord($KeyPhrase) + 3);
- $KeyPhraseLength = strlen($KeyPhrase);
- $plus += 1;
- // Loop trough input string
- for ($i = 0; $i < strlen($InputString); $i++){
- // Get key phrase character position
- $rPos = $i % $KeyPhraseLength;
- // Magic happens here:
- $r = (ord($InputString[$i]) ^ ord($KeyPhrase[$rPos])) - $plus;
- // Replace characters
- $InputString[$i] = chr($r);
- }
- return $InputString;
- }
- function XOREncrypt($InputString, $KeyPhrase, $plus){
- $InputString = str_pad($InputString, 13, chr(0x00));
- $KeyPhrase = chr(ord($KeyPhrase) + 3);
- $KeyPhraseLength = strlen($KeyPhrase);
- $plus += 1;
- // Loop trough input string
- for ($i = 0; $i < strlen($InputString); $i++){
- // Get key phrase character position
- $rPos = $i % $KeyPhraseLength;
- // Magic happens here:
- $r = (ord($InputString[$i]) + $plus) ^ ord($KeyPhrase[$rPos]);
- // Replace characters
- $InputString[$i] = chr($r);
- }
- return $InputString;
- }
- $fp = stream_socket_client("tcp://67.159.44.212:10001", $errno, $errstr, 100, STREAM_CLIENT_CONNECT);
- if (!$fp)
- {
- echo "$errstr ($errno)<br />\n";
- }
- else
- {
- fwrite_stream($fp, toPacket('05 00 15 0C FF'));
- $requestKey = strhex(fread($fp, 7));
- $plus = $requestKey[8].$requestKey[9];
- $loginKey = $requestKey[10].$requestKey[11].$requestKey[12].$requestKey[13];
- $user = strhex(XOREncrypt("!admin", hexstr($loginKey), $plus));
- $pass = strhex(XOREncrypt("test123", hexstr($loginKey), $plus));
- $loginPacket = $user.$pass.' 00';
- fwrite_stream($fp, toPacket('1F 00 15 03 '.$loginPacket));
- $loginStatus = fread($fp, 7+14);
- fwrite_stream($fp, toPacket('08 00 15 05 00 00 00 00'));
- $serverList = fread($fp, 7+14+28);
- fwrite_stream($fp, toPacket('06 00 15 07 00 00'));
- $getConfirm = fread($fp, 7+14+28+44);
- fclose($fp);
- }
- echo "<pre>";
- if(isset($loginKey)) echo "Login Key: ".$loginKey." \n";
- if(isset($loginStatus)) echo "Login Status: ".strhex($loginStatus)." \n";
- if(isset($loginStatus)) echo "Server List: ".strhex($serverList)." \n";
- if(isset($loginStatus)) echo "Confirm Selection: ".strhex($getConfirm)." \n";
- echo "</pre>";
- $decrypt = XORDecrypt(hexstr($loginPacket), hexstr($loginKey), $plus);
- echo $decrypt;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment