Guest User

RF

a guest
May 28th, 2010
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.46 KB | None | 0 0
  1. <?php
  2.  
  3.     function fwrite_stream($fp, $string) {
  4.         for ($written = 0; $written < strlen($string); $written += $fwrite) {
  5.             $fwrite = fwrite($fp, substr($string, $written));
  6.             if ($fwrite === false) {
  7.                 return $written;
  8.             }
  9.         }
  10.         return $written;
  11.     }
  12.    
  13.     function strhex($string) {
  14.         $hexstr = unpack('H*', $string);
  15.         return trim(array_shift($hexstr));
  16.     }
  17.    
  18.     function hexstr($hexstr) {
  19.       $hexstr = str_replace(' ', '', $hexstr);
  20.       return trim(pack('H*', $hexstr));
  21.     }  
  22.  
  23.     function toPacket($hex)
  24.     {
  25.         $hex = str_replace(" ", "", $hex);
  26.         return pack("H*",$hex);
  27.     }
  28.    
  29.     function sendData($hex)
  30.     {
  31.         $fp = stream_socket_client("tcp://67.159.44.212:10001", $errno, $errstr, 5, STREAM_CLIENT_CONNECT);
  32.         if (!$fp)
  33.         {
  34.             echo "$errstr ($errno)<br />\n";
  35.         }
  36.         else
  37.         {
  38.             fwrite_stream($fp, toPacket($hex));
  39.             $return = fread($fp, 1024);
  40.             fclose($fp);
  41.         }
  42.        
  43.         return strhex($return);
  44.     }
  45.    
  46.     function XORDecrypt($InputString, $KeyPhrase, $plus)
  47.     {
  48.         $KeyPhrase = chr(ord($KeyPhrase) + 3);
  49.         $KeyPhraseLength = strlen($KeyPhrase);
  50.        
  51.         $plus += 1;    
  52.    
  53.         // Loop trough input string
  54.         for ($i = 0; $i < strlen($InputString); $i++){
  55.      
  56.             // Get key phrase character position
  57.             $rPos = $i % $KeyPhraseLength;
  58.      
  59.             // Magic happens here:
  60.             $r  = (ord($InputString[$i]) ^ ord($KeyPhrase[$rPos])) - $plus;
  61.  
  62.             // Replace characters
  63.             $InputString[$i] = chr($r);
  64.         }
  65.      
  66.         return $InputString;
  67.     }      
  68.    
  69.     function XOREncrypt($InputString, $KeyPhrase, $plus){
  70.      
  71.         $InputString = str_pad($InputString, 13, chr(0x00));
  72.        
  73.         $KeyPhrase = chr(ord($KeyPhrase) + 3);
  74.         $KeyPhraseLength = strlen($KeyPhrase);
  75.        
  76.         $plus += 1;
  77.      
  78.         // Loop trough input string
  79.         for ($i = 0; $i < strlen($InputString); $i++){
  80.      
  81.             // Get key phrase character position
  82.             $rPos = $i % $KeyPhraseLength;
  83.      
  84.             // Magic happens here:
  85.             $r = (ord($InputString[$i]) + $plus) ^ ord($KeyPhrase[$rPos]);
  86.      
  87.             // Replace characters
  88.             $InputString[$i] = chr($r);
  89.         }
  90.        
  91.         return $InputString;
  92.     }
  93.    
  94.  
  95.  
  96.     $fp = stream_socket_client("tcp://67.159.44.212:10001", $errno, $errstr, 100, STREAM_CLIENT_CONNECT);
  97.     if (!$fp)
  98.     {
  99.            echo "$errstr ($errno)<br />\n";
  100.     }
  101.     else
  102.     {
  103.         fwrite_stream($fp, toPacket('05 00 15 0C FF'));
  104.         $requestKey = strhex(fread($fp, 7));
  105.        
  106.         $plus = $requestKey[8].$requestKey[9];
  107.         $loginKey = $requestKey[10].$requestKey[11].$requestKey[12].$requestKey[13];
  108.        
  109.         $user = strhex(XOREncrypt("!admin", hexstr($loginKey), $plus));
  110.         $pass = strhex(XOREncrypt("test123", hexstr($loginKey), $plus));
  111.        
  112.         $loginPacket = $user.$pass.' 00';
  113.  
  114.         fwrite_stream($fp, toPacket('1F 00 15 03 '.$loginPacket));
  115.         $loginStatus = fread($fp, 7+14);
  116.        
  117.         fwrite_stream($fp, toPacket('08 00 15 05 00 00 00 00'));
  118.         $serverList = fread($fp, 7+14+28);
  119.        
  120.         fwrite_stream($fp, toPacket('06 00 15 07 00 00'));
  121.         $getConfirm = fread($fp, 7+14+28+44);
  122.        
  123.         fclose($fp);
  124.     }  
  125.    
  126.     echo "<pre>";
  127.     if(isset($loginKey)) echo "Login Key: ".$loginKey." \n";
  128.     if(isset($loginStatus)) echo "Login Status: ".strhex($loginStatus)." \n";
  129.     if(isset($loginStatus)) echo "Server List: ".strhex($serverList)." \n";
  130.     if(isset($loginStatus)) echo "Confirm Selection: ".strhex($getConfirm)." \n";
  131.     echo "</pre>";
  132.    
  133.     $decrypt = XORDecrypt(hexstr($loginPacket), hexstr($loginKey), $plus);
  134.    
  135.     echo $decrypt;
  136. ?>
Advertisement
Add Comment
Please, Sign In to add comment