function UnMunge($packet) {
$MungeTable2 = array(0x05, 0x61, 0x7A, 0xED, 0x1B, 0xCA, 0x0D, 0x9B, 0x4A, 0xF1, 0x64, 0xC7, 0xB5, 0x8E, 0xDF, 0xA0);
$z = ord($packet[0]);
$packet = substr($packet, 8);
$length = strlen($packet);
$res = "";
$count = 0;
if ($length < 1) {
return null;
}
$notz = ~$z;
$length = $length >> 2;
$zBytes = pack("L", $z);
$notzBytes = pack("L", $notz);
$x = 0;
while ($length--) {
$part = substr($packet, $count * 4, 4);
for ($i = 0; $i < 4; $i++) {
$part[$i] = chr(ord($part[$i]) ^ ord($zBytes[$i]));
}
for ($i = 0; $i < 4; $i++) {
$part[$i] = chr(ord($part[$i]) ^ ((($MungeTable2[($count + $i) & 0x0F] | ($i << $i)) | $i) | 0xA5));
}
$s = "0000";
for ($i = 0, $i2 = 3; $i < 4; $i++, $i2--) {
$s[$i] = chr(ord($part[$i2]) ^ ord($notzBytes[$i]));
}
$res .= $s;
$count++;
}
return $res;
}
$a = '010000c0010000805a18010051001041032a40016001014124660f377e3933737948106f908fd021c1b8c0812ba8c0f3a5c8f4919b99d1d0f48083908120e091d1d881be8becc0b48a99d1bfcbb0c0c3d1ab90b3c2fdc0f4411a71ca';
$a = hex2bin($a);
var_dump(UnMunge($a));
string(84) "J:Asv_version* Права доступа предоставлены! "