使用python之后越来越觉得他的实用性无处不在了-_-||,想恢复一下微信聊天记录中的文件,都要借助我的好伙伴。
小编的手机空间比较有限,于是微信baba清除了之前所有的聊天记录,一致依赖于“查找聊天内容”功能的我,陷入了困境。
于是我想到了在电脑上试试找一下呢。
1、找到(windows)微信的内容存储地址
C:\Users\hp\Documents\WeChat Files\***\FileStorage\Image\2019-12
2、发现我的图像内容是这样的
微信加密图片.png
3、python写一份代码在cmd运行一下,用异或byte的方法解码dat文件,并且存储到新的文件夹中
import os
import sys
def imageDecode(f,out):
dat = open(f, 'rb')
png = open(out, 'wb')
for now in dat:
for nowByte in now:
newByte = nowByte ^ 0xb3 #修改为自己的解密码
png.write(bytes([newByte]))
dat.close()
png.close()
wechat_path = 'C:/Users/hp/Documents/WeChat Files/***/FileStorage/Image/2019-12/'
for dir, folder, file in os.walk(wechat_path):
for i in file:
f = "%s%s"%(dir,i)
fn = "%s%s"%(dir.replace('2019-12', '2019-12-png'),i.replace('.dat','.png'))
print(f, '\n', fn)
# sys.exit(0)
imageDecode(f, fn)
4、这里解密码的计算方法
用wxMEdit软件打开dat后缀的文件
dat图像内容.png
查看00行前四个字符,和(jpeg图片的开头两个16进制的值)FFD8异或计算,我这里得到的是B3B3,在代码中写成“0xb3”即可。
网友评论