以下是文本:
import os
def decode_dat_to_image(dat_path, output_path, xor_value=0x38):
"""
解密微信.dat文件并保存为图片。
:param dat_path: .dat文件的路径
:param output_path: 输出图片的路径
:param xor_value: 异或值,默认为0x38
"""
try:
# 读取.dat文件
with open(dat_path, "rb") as dat_file:
data = bytearray(dat_file.read)
# 使用异或值解密整个文件
decoded_data = bytearray(b ^ xor_value for b in data)
# 保存为图片文件
with open(output_path, "wb") as img_file:
img_file.write(decoded_data)
print(f"解密成功!图片已保存到 {output_path}")
return True
except Exception as e:
print(f"解密失败:{e}")
return False
if __name__ == "__main__":
# 当前脚本所在文件夹路径
current_folder = os.path.dirname(os.path.abspath(__file__))
# 获取当前文件夹中所有.dat文件
dat_files = [f for f in os.listdir(current_folder) if f.endswith(".dat")]
if not dat_files:
print("当前文件夹中没有找到任何.dat文件。")
else:
print(f"开始批量解密 {len(dat_files)} 个.dat文件...")
for dat_file in dat_files:
dat_file_path = os.path.join(current_folder, dat_file)
output_image_path = os.path.join(current_folder, dat_file.replace(".dat", ".jpg"))
success = decode_dat_to_image(dat_file_path, output_image_path)
if not success:
print(f"跳过文件 {dat_file},可能无法解密或文件损坏。")
print("解码完成!")
input("按任意键退出...")
© 版权声明
本网站上的所有资源均来源于本网站,所有网址和文章版权均归原作者所有。如有侵权行为,请将相关证明发送至以下电子邮件地址:dxsen@qq.com