From 346dfe5b886da95972f3630f16df9836e5cb4446 Mon Sep 17 00:00:00 2001 From: shuaikangzhou <863909694@qq.com> Date: Tue, 5 Dec 2023 20:53:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=A7=A3=E5=AF=86=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/decrypt/decrypt.py | 8 +++++--- app/ui_pc/tool/pc_decrypt/pc_decrypt.py | 18 +++++++++++++++--- requirements_pc.txt | 2 +- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app/decrypt/decrypt.py b/app/decrypt/decrypt.py index cbc113b..7a833cb 100644 --- a/app/decrypt/decrypt.py +++ b/app/decrypt/decrypt.py @@ -5,7 +5,7 @@ from typing import Union, List from Cryptodome.Cipher import AES -from app.log import log +from app.log import log, logger # from Crypto.Cipher import AES # 如果上面的导入失败,可以尝试使用这个 @@ -24,7 +24,8 @@ def decrypt(key: str, db_path, out_path): if not os.path.exists(os.path.dirname(out_path)): return f"[-] out_path:'{out_path}' File not found!" if len(key) != 64: - return f"[-] key:'{key}' Error!" + logger.error(f"[-] key:'{key}' Error!") + return -1 password = bytes.fromhex(key.strip()) with open(db_path, "rb") as file: blist = file.read() @@ -39,7 +40,8 @@ def decrypt(key: str, db_path, out_path): hash_mac.update(b'\x01\x00\x00\x00') if hash_mac.digest() != first[-32:-12]: - return f"[-] Password Error! (key:'{key}'; db_path:'{db_path}'; out_path:'{out_path}' )" + logger.error(f"[-] Password Error! (key:'{key}'; db_path:'{db_path}'; out_path:'{out_path}' )") + return -1 newblist = [blist[i:i + DEFAULT_PAGESIZE] for i in range(DEFAULT_PAGESIZE, len(blist), DEFAULT_PAGESIZE)] diff --git a/app/ui_pc/tool/pc_decrypt/pc_decrypt.py b/app/ui_pc/tool/pc_decrypt/pc_decrypt.py index d741a00..c1c1555 100644 --- a/app/ui_pc/tool/pc_decrypt/pc_decrypt.py +++ b/app/ui_pc/tool/pc_decrypt/pc_decrypt.py @@ -124,12 +124,17 @@ class DecryptControl(QWidget, decryptUi.Ui_Dialog): if not os.path.exists(db_dir): QMessageBox.critical(self, "错误", "文件夹选择错误\n一般以wxid_xxx结尾") return + if self.info.get('key') == 'none': + QMessageBox.critical(self, "错误", "密钥错误\n请检查微信版本是否为最新") self.label_tip.setVisible(True) self.label_tip.setText('点我之后没有反应那就多等儿吧,不要再点了') self.thread2 = DecryptThread(db_dir, self.info['key']) self.thread2.maxNumSignal.connect(self.setProgressBarMaxNum) self.thread2.signal.connect(self.progressBar_view) self.thread2.okSignal.connect(self.btnExitClicked) + self.thread2.errorSignal.connect( + lambda x: QMessageBox.critical(self, "错误", "密钥错误\n请检查微信版本是否为最新") + ) self.thread2.start() def btnEnterClicked(self): @@ -171,11 +176,14 @@ class DecryptControl(QWidget, decryptUi.Ui_Dialog): # 目标数据库文件 target_database = "app/DataBase/Msg/MSG.db" # 源数据库文件列表 - source_databases = [f"app/DataBase/Msg/MSG{i}.db" for i in range(1,20)] + source_databases = [f"app/DataBase/Msg/MSG{i}.db" for i in range(1, 20)] import shutil shutil.copy("app/DataBase/Msg/MSG0.db", target_database) # 使用一个数据库文件作为模板 # 合并数据库 - merge_databases(source_databases, target_database) + try: + merge_databases(source_databases, target_database) + except FileNotFoundError: + QMessageBox.critical(self, "错误", "数据库不存在\n请检查微信版本是否为最新") self.DecryptSignal.emit(True) self.close() @@ -184,6 +192,7 @@ class DecryptThread(QThread): signal = pyqtSignal(str) maxNumSignal = pyqtSignal(int) okSignal = pyqtSignal(str) + errorSignal = pyqtSignal(bool) def __init__(self, db_path, key): super(DecryptThread, self).__init__() @@ -206,13 +215,16 @@ class DecryptThread(QThread): for root, dirs, files in os.walk(self.db_path): for file in files: if '.db' == file[-3:]: + if 'xInfo.db' == file: + continue inpath = os.path.join(root, file) # print(inpath) output_path = os.path.join(output_dir, file) tasks.append([self.key, inpath, output_path]) self.maxNumSignal.emit(len(tasks)) for i, task in enumerate(tasks): - decrypt.decrypt(*task) + if decrypt.decrypt(*task) == -1: + self.errorSignal.emit(True) self.signal.emit(str(i)) # print(self.db_path) self.okSignal.emit('ok') diff --git a/requirements_pc.txt b/requirements_pc.txt index 9ad796b..e62cb22 100644 --- a/requirements_pc.txt +++ b/requirements_pc.txt @@ -7,7 +7,7 @@ silk-python pyaudio fuzzywuzzy python-Levenshtein -pillow +pillow==9.5.0 requests flask==3.0.0 pyecharts==2.0.1