Hey Guys,
I've written a PHP Ban checker which was going to to be part of my automated key manager.
It's mostly finished except for 2 things:
1) Interpret the return from BattlEye which is the variable $buf and see if it contains "Global Ban"
2) Convert the encoded hex style key like C6-17-4D-88-6F-AD-2D-44-C1-6F-04-1B-D5-60-73 to it's CD Key format like F32V-LBRRF-BG9LN-LMK3R-AXDG0
Which is partly why I am sharing this.
I am hoping that by sharing it up here someone might be able to provide me with the algorithm that converts the encoded hex style CD keys to standard format.
I AM NOT looking for someone to post me a link to Darky's or any other key changer that does this, I require the actual algorithm that does the conversion.
Any help greatly appreciated!
Code:
<?php
$HEXDCDKEY = "C6-17-4D-88-6F-AD-2D-44-C1-6F-04-1B-D5-60-73";
/* Need to convert $HEXDCDKEY to $cdkey */
$cdkey = "F32V-LBRRF-BG9LN-LMK3R-AXDG0";
$GameGUID = md5($cdkey);
$BEGUID = md5("BE".$GameGUID);
$BEGUIDHEX = strhex($BEGUID);
echo $cdkey . "\n";
echo $GameGUID . "\n";
echo $BEGUID . "\n";
echo $BEGUIDHEX . "\n";
// UDP Message to be Sent
$msg = hextobin("b1fbe207".$BEGUIDHEX);
// Get BattlEye Servers IP
$battleip = gethostbyname ( "arma2oa1.battleye.com" );
// Open the UDP Socket
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
// Get the Message Length
$len = strlen($msg);
// Bind the socket to a specific port for BattlEye on the local IP
socket_bind($sock,'192.168.0.56', 57374);
// Send the message to BattlEye Server
socket_sendto($sock, $msg, $len, 0, $battleip, 2324);
// Listen for response on bound socket
socket_recv($sock, $buf, 100, 0);
// Echo Result
echo $buf . "\n";
// Close the socket like a good boy!
socket_close($sock);
// Function to convert Hex to Binary
function hextobin($hexstr)
{
$n = strlen($hexstr);
$sbin="";
$i=0;
while($i<$n)
{
$a =substr($hexstr,$i,2);
$c = pack("H*",$a);
if ($i==0){$sbin=$c;}
else {$sbin.=$c;}
$i+=2;
}
return $sbin;
}
function strhex($string) {
$hexstr = unpack('H*', $string);
return array_shift($hexstr);
}
?>
Krankie