Skip to content

Instantly share code, notes, and snippets.

@wen-long
Forked from lifesign/update.php
Created January 14, 2016 15:07
Show Gist options
  • Save wen-long/a3bb8c3839377710b677 to your computer and use it in GitHub Desktop.
Save wen-long/a3bb8c3839377710b677 to your computer and use it in GitHub Desktop.
纯真数据库自动更新
<?php
/*
纯真数据库自动更新原理实现
示例代码使用php实现,从copywrite.rar中读取解密需要的一个key,然后解密qqwry.rar头0x200字节数据,随后使用zlib解压数据即可得到qqwry.dat文件
通过此代码的实现,你应该可以自行实现一个纯真数据库更新工具。copywrite.rar中还有一些更多的数据,没有一一列出,比如版本号、qqwry.rar文件大小。
collect from https://github.com/shuax/QQWryUpdate/blob/master/update.php
*/
$copywrite = file_get_contents("http://update.cz88.net/ip/copywrite.rar");
$qqwry = file_get_contents("http://update.cz88.net/ip/qqwry.rar");
$key = unpack("V6", $copywrite)[6];
for($i=0; $i<0x200; $i++)
{
$key *= 0x805;
$key ++;
$key = $key & 0xFF;
$qqwry[$i] = chr( ord($qqwry[$i]) ^ $key );
}
$qqwry = gzuncompress($qqwry);
$fp = fopen("qqwry.dat", "wb");
if($fp)
{
fwrite($fp, $qqwry);
fclose($fp);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment