本帖最后由 diary 于 2023-10-29 23:09 编辑
贴一个可行的解码的脚本代码,拿到存档可以直接破解
[PHP] 纯文本查看 复制代码 <?php
//存档解密
function xor_crypt($ciphertext, $password)
{
for ($i = 0; $i < strlen($ciphertext); ++$i) {
$ciphertext[$i] = chr(ord($ciphertext[$i]) ^ ord($password[$i % strlen($password)]) ^ $i % 15 * ($i % 5) % 92);
}
return $ciphertext;
}
function des_crypt($ciphortext, $password, $encrypt = false)
{
$iv = str_pad(substr(xor_crypt(hex2bin("112035352023"), "PASSWORD"), 0, 8), 8, hex2bin("00"));
if ($encrypt) {
return base64_encode(openssl_encrypt($ciphortext, "des-ede3-cbc", $password, OPENSSL_RAW_DATA, $iv));
} else {
return openssl_decrypt(base64_decode($ciphortext), "des-ede3-cbc", $password, OPENSSL_RAW_DATA, $iv);
}
}
$keys = [];
$keys["game"] = "smg";
$keys["data"] = "iambo";
$keys["statistic"] = "crstl";
// 获取外部终端输入的文件路径
if (!isset($argv[1])) {
die("请输入文件路径,例如:php sk.php file/game.data\n");
}
$file_path = $argv[1];
// 根据文件名来判断使用哪种解密方法
$name = pathinfo($file_path, PATHINFO_FILENAME); // 获取不带扩展名的文件名
$content = file_get_contents($file_path);
$decrypted_data = '';
switch ($name) {
case "game":
echo "Using XOR mode with game key.\n";
$decrypted_data = xor_crypt($content, $keys["game"]);
break;
case "task_*_":
case "item_data_*_":
case "season_data_*_":
case "moonrise_data_*_":
case "mall_reload_data_*_":
echo "Using DES mode with data key.\n";
$decrypted_data = des_crypt($content, $keys["data"]);
break;
case "statistic_*_":
case "statistic":
echo "Using DES mode with statistic key.\n";
$decrypted_data = des_crypt($content, $keys["statistic"]);
break;
default:
echo "\033[32mFile is plaintext, nothing to do.\033[0m\n";
exit;
}
$output_directory = './data_new/';
if (!file_exists($output_directory)) {
mkdir($output_directory, 0777, true);
}
// Save the decrypted content to .txt and .json files
file_put_contents($output_directory . $name . ".txt", $decrypted_data);
// file_put_contents($output_directory . $name . "_diff.json", $decrypted_data);
// file_put_contents($output_directory . $name . ".json", $decrypted_data);
echo "Decryption completed and saved as .txt!\n";
?> |