but y have a probleme with the encryption packet...
for the moment i get : the list of server like this one
79.110.84.251:4014:0:4.5.S4-Nexus
but after i know i should send the first packet to 79.110.84.251:4014
i've this encryption function :
PHP Code:
function EncryptGamePacket($str)
{
$encrypted_string ="";
$length = strlen($str);
$secondlength = round($length / 122);
$compteur = 0;
for ($i = 0 ; $i < $length; $i++)
{
if($i == (122 * $compteur))
{
if($secondlength == 0)
{
$encrypted_string .= chr(abs((((round($length / 122)) * 122) - $length)));
} else
{
$encrypted_string .= chr(0x7A);
$secondlength--;
$compteur++;
}
}
$encrypted_string .= chr(ord($str[$i]) ^ (int)0xFF);
}
$encrypted_string .= chr(0xFF);
return $encrypted_string;
}
but this is encryption stage 2...
it's the oposite of this one
Code:
public static string DecryptGamePacket2(byte[] str)
{
string decrypted_string = "";
char[] table = { ' ', '-', '.', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'n' };
int count = 0;
for (count = 0; count < str.Length-1; )
{
if (str[count] <= 0x7A)
{
byte len = str[count];
for (int i = 0; i < (int)len; i++)
{
count++;
decrypted_string += Function.getextendedascii((count < str.Length ? str[count] : 0) ^ 0xFF);
}
int x = decrypted_string[1];
count++;
}
else
{
byte len = (byte)str[count];
len &= (byte)0x7F;
for (int i = 0; i < (int)len; )
{
count++;
byte highbyte = str[count];
highbyte &= 0xF0;
highbyte >>= 0x4;
byte lowbyte = str[count];
lowbyte &= 0x0F;
if (highbyte != 0x0 && highbyte != 0xF)
{
decrypted_string += table[highbyte - 1];
i++;
}
if (lowbyte != 0x0 && lowbyte != 0xF)
{
decrypted_string += table[lowbyte - 1];
i++;
}
}
count++;
}
}
return decrypted_string;
}
but i know the first packet
NUMBER ID NUMBER+1 PASSWORD
should be encrypt with this function
Code:
public static string DecryptGamePacket( int session_id, byte[] str, int length )
{
string encrypted_string = "";
byte session_key = (byte)(session_id & 0xFF);
byte session_number = (byte)(session_id >> 6);
session_number &= (byte)0xFF;
session_number &= unchecked((byte)0x80000003);
switch (session_number)
{
case 0:
for (int i = 0; i < length; i++)
{
byte firstbyte = (byte)(session_key + 0x40);
byte highbyte = (byte)(str[i] - firstbyte);
encrypted_string += highbyte + " ";
}
break;
case 1:
for (int i = 0; i < length; i++)
{
byte firstbyte = (byte)(session_key + 0x40);
byte highbyte = (byte)(str[i] + firstbyte);
encrypted_string += highbyte + " ";
}
break;
case 2:
for (int i = 0; i < length; i++)
{
byte firstbyte = (byte)(session_key + 0x40);
byte highbyte = (byte)(str[i] - firstbyte ^ 0xC3);
encrypted_string += highbyte + " ";
}
break;
case 3:
for (int i = 0; i < length; i++)
{
byte firstbyte = (byte)(session_key + 0x40);
byte highbyte = (byte)(str[i] + firstbyte ^ 0xC3);
encrypted_string += highbyte+ " ";
}
break;
default:
encrypted_string += 0xF;
break;
}
/* string[] var2 = encrypted_string.Split(' ');
byte[] bytes = new byte[var2.Length-1];
for (int i = 0; i < bytes.Length; i++)
{
bytes[i] = Byte.Parse(var2[i]);
}
string save = "";
save += DecryptGamePacket2(bytes);
*/
string[] var2 = encrypted_string.Split(new string[] { "255 " }, StringSplitOptions.None);// return string less 255 (2 strings)
byte[][] bytes = new byte[var2.Length -1][];
for (int i = 0; i < bytes.Length; i++)
{
string[] temp = var2[i].Split(' ');
bytes[i] = new byte[temp.Length-1];
for (int j = 0; j < bytes[i].Length; j++)
{
bytes[i][j] = Byte.Parse(temp[j]);
}
}
string save = "";
for (int i = 0; i < bytes.Length; i++)
{
save += DecryptGamePacket2(bytes[i]);
save += (char)0xFF;
}
return save;
}
that's why i post this in order to know if someone know the crypto to encrypt packet stage 1
Thank you in advance.






