diff --git a/README.md b/README.md index 14db20f..8ea6fb3 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ * 更新日志(如果有[version_list.json](./Program/version_list.json)缺少的版本,请帮忙添加。) - * 2023.09.28 增加了数据库部分解析 - * 2023.09.15 增加了3.9.7.25版本的偏移地址 + * 2023.09.28 增加了数据库部分解析 + * 2023.09.15 增加了3.9.7.25版本的偏移地址 ## 一、项目介绍 @@ -11,10 +11,10 @@ 该分支是[SharpWxDump](https://github.com/AdminTest0/SharpWxDump)的经过重构python语言版本,同时添加了一些新的功能。 -**如果觉得好用的话的话,帮忙点个[![Star](https://img.shields.io/github/stars/xaoyaoo/PyWxDump.svg?style=social&label=Star)](https://github.com/xaoyaoo/PyWxDump/) +* +*如果觉得好用的话的话,帮忙点个[![Star](https://img.shields.io/github/stars/xaoyaoo/PyWxDump.svg?style=social&label=Star)](https://github.com/xaoyaoo/PyWxDump/) 呗** - ## 二、使用方法 ### 1. 安装依赖 @@ -152,7 +152,7 @@ git clone https://github.com/xaoyaoo/PyWxDump.git * 解密后可拖入数据库工具查找敏感信息 * 还有一份数据的说明文档,但是我累了,不想写了 - + **方法** 进入目录[decrypted](./decrypted) @@ -161,6 +161,8 @@ git clone https://github.com/xaoyaoo/PyWxDump.git python decrypt.py --key ******** --db_path ./decrypted/decrypted.db --out_path ./decrypted/decrypted.db ``` +[注]:--key为数据库密钥,--db_path为数据库路径,--out_path为解密后的数据库路径(解密后的路径目录必须存在) + 自动根据注册表读取本地微信聊天记录文件夹,解密后保存到当前目录下的decrypted文件夹中 ```shell diff --git a/decrypted/decrypt.py b/decrypted/decrypt.py index fa5e548..f447c7c 100644 --- a/decrypted/decrypt.py +++ b/decrypted/decrypt.py @@ -1,6 +1,7 @@ import argparse import hmac import hashlib +import os from Cryptodome.Cipher import AES @@ -13,6 +14,13 @@ DEFAULT_ITER = 64000 # 通过密钥解密数据库 def decrypt(key, db_path, out_path): + if not os.path.exists(db_path): + print("[-] db_path File not found!") + return False + if not os.path.exists(os.path.dirname(out_path)): + print("[-] out_path File Path not found!") + return False + password = bytes.fromhex(key.strip()) with open(db_path, "rb") as file: blist = file.read() @@ -49,6 +57,23 @@ def decrypt(key, db_path, out_path): return True +def batch_decrypt(key, db_path, out_path): + if not os.path.exists(db_path): + print("[-] db_path File not found!") + return False + if not os.path.exists(os.path.dirname(out_path)): + print("[-] out_path File Path not found!") + return False + + if os.path.isfile(db_path) and not os.path.isdir(out_path): + return decrypt(key, db_path, out_path) + if os.path.isdir(db_path) and not os.path.isfile(out_path): + for root, dirs, files in os.walk(db_path): + for file in files: + decrypt(key, os.path.join(root, file), os.path.join(out_path, "decrypted" + file)) + return True + + if __name__ == '__main__': # 创建命令行参数解析器 parser = argparse.ArgumentParser() @@ -69,5 +94,5 @@ if __name__ == '__main__': out_path = args.out_path # 调用 decrypt 函数,并传入参数 - result = decrypt(key, db_path, out_path) + result = batch_decrypt(key, db_path, out_path) print(f"{result} done!")