Advertisement
Guest User

Untitled

a guest
Aug 1st, 2009
333
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. if (count($_SERVER['argv']) != 4) {
  4.     die("\n\n" . "Check your arugments. Must start like:" . "\n" . "file.php cod4server cod4serverport key" . "\n\n");
  5. }
  6.  
  7. //generates a random string, in our case the fake players' names
  8. function random_letters ($numofletters=8) {
  9.         $v="";
  10.         for($i=0;$i<$numofletters;$i++) $v.=chr(rand(65,90));
  11.         return $v;
  12. }
  13.  
  14. // parse server reply for current player count
  15. function getcurrentplayers($serverreply){
  16.     if(strstr($serverreply, "\\clients\\") == TRUE){
  17.         $exploded = explode("\\", $serverreply);
  18.         $arraypos = array_search("clients", $exploded) + 1;
  19.         return $exploded[$arraypos];
  20.     } else {
  21.         return 0;
  22.     }
  23. }
  24.  
  25.    $cod4masterserver = "cod4master.activision.com";
  26.    $cod4masterserverport = "20800";
  27.    $cod4server = $argv[1];
  28.    $cod4serverport = $argv[2];
  29.    $cod4key = $argv[3];
  30.    $first16key = substr($cod4key, 0, 16);
  31.    
  32.    //path to the executable that calculates the guid from the cdkey. be sure to change this to fit your needs.
  33.    //you can also just use $pbguid = "YOURGUIDHERE"; if you dont want to use an executable
  34.    $pbguid = exec("/home/user/cod4key2guid " . $first16key);
  35.    $masterstring = "\xff\xff\xff\xffgetKeyAuthorize 0 " . $first16key . " PB " . $pbguid;
  36.    $serverstring = "\xff\xff\xff\xff" . 'getchallenge 0 "' . $pbguid . '"';
  37.  
  38.    //Send master server the key once. If needed again, it will be sent again automatically
  39.    $udpmaster = fsockopen("udp://" . $cod4masterserver, $cod4masterserverport);
  40.    fwrite($udpmaster, $masterstring);
  41.  
  42. //begin sending infinite fake players. "stop" never changes from 0, so the loop continues forever (until you hit ctrl+c)
  43. $stop = 0;
  44. while($stop == 0){
  45.  
  46.     //get the current player count
  47.     $querydata = "\xff\xff\xff\xff\x67\x65\x74\x69\x6e\x66\x6f\x20\x78\x78\x78";
  48.     $getplayercountsocket = fsockopen("udp://" . $cod4server, $cod4serverport);
  49.     fwrite($getplayercountsocket, $querydata);
  50.     stream_set_timeout($getplayercountsocket, 1);
  51.     $getplayercountsocketresponse = ''.fread($getplayercountsocket, 1400);
  52.     $getplayercountsocketinfo = stream_get_meta_data($getplayercountsocket);
  53.    
  54.     //if the server doesn't reply with a player count, we timeout and echo "c". no fake player is added.
  55.    if ($getplayercountsocketinfo['timed_out']) {
  56.       echo("c");
  57.    } else {
  58.     //the server did reply with a player count like it should. we continue normally
  59.     $currentplayers = getcurrentplayers($getplayercountsocketresponse);
  60.    
  61.     //if there are less than 10 current players, we will add a fake player. otherwise, we won't do anything except echo "q"
  62.     if($currentplayers < 10){
  63.    
  64.    
  65.    $fakeplayer = random_letters();
  66.    $udpserverfirst = fsockopen("udp://" . $cod4server, $cod4serverport);
  67.    fwrite($udpserverfirst, $serverstring);
  68.    stream_set_timeout($udpserverfirst, 1);
  69.    $udpserverfirstresponse = ''.fread($udpserverfirst, 1400);
  70.    $udpserverfirstinfo = stream_get_meta_data($udpserverfirst);
  71.    if ($udpserverfirstinfo['timed_out']) {
  72.       echo("c");
  73.    } else {
  74.       if(substr($udpserverfirstresponse, 0, 21) != "\xff\xff\xff\xffchallengeResponse"){
  75.          if($udpserverfirstresponse == "\xff\xff\xff\xffneedcdkey"){
  76.             fwrite($udpmaster, $masterstring);
  77.             echo ("n");
  78.          } else {
  79.             if($udpserverfirstresponse == "\xff\xff\xff\xfferror\x0aEXE_ERR_CDKEY_IN_USE"){
  80.             echo ("b");
  81.          } else {
  82.             echo("u");
  83.          }}
  84.       } else {
  85.          $challenge = substr($udpserverfirstresponse, 22, 20);
  86.          $connectstring = ("\xff\xff\xff\xff" . 'connect "\\cg_predictItems\\1\\cl_anonymous\\0\\cl_punkbuster\\1\\cl_voice\\1\\cl_wwwDownload\\1\\rate\\25000\\snaps\\20\\name\\' . $fakeplayer . '\\protocol\\6\\challenge\\' . $challenge . '\\qport\\' . rand(10000, 65534) . '"');
  87.          fwrite($udpserverfirst, $connectstring);
  88.          $finalresponse = ''.fread($udpserverfirst, 1400);
  89.          if ($finalresponse != "\xff\xff\xff\xffconnectResponse\x20"){
  90.             if($finalresponse == "\xff\xff\xff\xfferror\x0aEXE_SERVERISFULL"){
  91.             echo("f");
  92.             } else {
  93.             echo("v");
  94.             }
  95.          } else {
  96.             echo ".";
  97.          }}}
  98.       } else {
  99.         sleep(1);
  100.         echo("q");
  101.       }
  102.     }
  103. }
  104. ?>
Advertisement
RAW Paste Data Copied
Advertisement