Raised This Month: $ Target: $400
 0% 

Checking if VAC is working


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
KoST
Senior Member
Join Date: Jul 2005
Old 04-10-2006 , 15:07  
Reply With Quote #4

i wrote this php script to query my server via rcon, and modified it a bit:

its output:
"SERVER SECURE !!"
or
"SERVER NOT SECURE !!"

just enter the ip and port of the server you want to query below:
Code:
<?php
	// set the ip and port of server:
   define (RCON_PORT,27015); // server port
   define (RCON_IP,"111.222.333.444"); // server ip
	//-------------------------------------------------------------------------------
   
   define (A2S_SERVERQUERY_GETCHALLENGE,toStream(array(0xFF,0xFF,0xFF,0xFF,0x57)));
   define (A2S_INFO,toStream(array(0xFF,
   0xFF,0xFF,0xFF,0x54,0x53,0x6F,0x75,0x72,0x63,0x65,0x20,0x45,
   0x6E,0x67,0x69,0x6E,0x65,0x20,0x51,0x75,0x65,0x72,0x79,0x00)));
   define (A2S_PLAYER,toStream(array(0xFF,0xFF,0xFF,0xFF,0x55)));
   define (A2S_RULES,toStream(array(0xFF,0xFF,0xFF,0xFF,0x56)));

   $info=array();   
   $players=array();

   $raw=QueryServer(A2S_SERVERQUERY_GETCHALLENGE);
   $raw=QueryServer(A2S_INFO);
   $raw=QueryServer(A2S_PLAYER.$info['challenge']);
   $raw=QueryServer(A2S_RULES.$info['challenge']);
   
   //print_r($info);                  
   if ($info["Secure"]==1){
	   echo "SERVER SECURE !!";
   }else{
   	   echo "SERVER NOT SECURE !!";
   }




   
   function Rcon($command){
       return trim(QueryServer(toStream(array(0xFF,0xFF,0xFF,0xFF)).$command,true));
   }
   
   function QueryServer($request,$isRconCommand=false){
      global $players,$info;
      $fp = fsockopen("udp://".RCON_IP,RCON_PORT, $errno, $errstr);
      if (!$fp) {
       echo "Fehler: $errno - $errstr
\n";
         return false;   
      } else {
         fwrite($fp,$request);
         $result=fread($fp, 100000);
         fclose($fp);

         $type=substr($result,4,1);
         
         $result=substr($result,5);
         if ($isRconCommand){
            //echo "[RCON]->".$result;
            return $result;
            switch ($type){
            
            }
         }


            switch ($type){
               case 'A':
                  //echo "challenge number:".$result[0]+$result[0]*256+$result[0]*256*256+$result[0]*256*256*256;
                  $info['challenge']=$result;
               break;
               case 'm':

                  $info['ip']=GetResultVal($result,'string');
                  $info['hostname']=GetResultVal($result,'string');
                  $info['map']=GetResultVal($result,'string');
                  $info['game']=GetResultVal($result,'string');
                  $info['description']=GetResultVal($result,'string');
   
                  $info['numPlayers']=GetResultVal($result);
                  $info['maxPlayers']=GetResultVal($result);
                  $info['version']=GetResultVal($result);
                  if (GetResultVal($result)==ord('d')){
                     $info['dedicated']=true;
                  }else{
                     $info['dedicated']=false;
                  }
                  if (GetResultVal($result)==ord('l')){
                     $info['os']='Linux';
                  }else{
                     $info['os']='Windows';
                  }
                  if (GetResultVal($result)==1){
                     $info['pwd']=true;
                  }else{
                     $info['pwd']=false;
                  }
                  if (GetResultVal($result)==1){
                     $info['IsMod']=true;
                  }else{
                     $info['IsMod']=false;
                  }
                  
   
                  $info['URLInfo']=GetResultVal($result,'string');
                  $info['URLDL']=GetResultVal($result,'string');
                  $info['Unused']=GetResultVal($result,'string');
                  $info['ModVersion1']=GetResultVal($result);
                  $info['ModVersion2']=GetResultVal($result);
                  $info['ModVersion3']=GetResultVal($result);
                  $info['ModVersion4']=GetResultVal($result);
                  $info['ModSize1']=GetResultVal($result);
                  $info['ModSize2']=GetResultVal($result);
                  $info['ModSize3']=GetResultVal($result);
                  $info['ModSize4']=GetResultVal($result);
                  
                  $info['SvOnly']=GetResultVal($result);
   
   
   
                  $info['ClDLL']=GetResultVal($result);   
   
                  $info['Secure']=GetResultVal($result);
                  $info['numBots']=GetResultVal($result);
                  $info['realPlayers']=$info['numPlayers']-$info['numBots'];
   
      
   
               break;
   
               case 'D':
                  $n=GetResultVal($result);
                  if ($n!=$info['numPlayers']){
                     echo "sombody joining...";
                  }
                  $players=array();
                  for ($s=0;$s<$n;$s++){
                     $index=GetResultVal($result);
                     $cur=&$players[$index];
                     $cur['name']=GetResultVal($result,'string');
                     $cur['frags']=GetResultVal($result);
                     $frags=GetResultVal($result);
                     $frags=GetResultVal($result);
                     $frags=GetResultVal($result);
   
                     $time=GetResultVal($result);
                     $time=GetResultVal($result);
                     $time=GetResultVal($result);
                     $time=GetResultVal($result);
                  }
               break;
   
               case 'y':
                  //echo "LKJ";
                  $val1=GetResultVal($result);
                  $val1=GetResultVal($result);
                  $n=$val1+$val2*256;
                  for ($s=0;$s>$n;$s++){
                     echo "rule: ".GetResult($result,'string')."
";
                     echo " val: ".GetResult($result,'string')."
";
                  }
               break;
               
               default:
                  //echo "TAPE: ".$type;
               break;
            }
         return true;
      }

      return false;   
   }

   function toStream($arr){
      $tmp="";
      foreach ($arr as $val){
         $tmp.=chr($val);
      }
      return $tmp;
   }


   function GetResultVal(&$result,$mode='byte'){
      if ($mode=='byte'){
         $tmp=ord(substr($result,0,1));
         $result=substr($result,1);
         return $tmp;
      } else if ($mode=='string'){
         $a=explode(chr(0),$result,2);
         $result=$a[1];
         return $a[0];
      }
   }    
   
?>
KoST is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:33.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode