mirror of
https://github.com/LC044/WeChatMsg
synced 2025-02-22 19:02:17 +08:00
完善解密错误提示
This commit is contained in:
parent
6d6b355283
commit
346dfe5b88
@ -5,7 +5,7 @@ from typing import Union, List
|
|||||||
|
|
||||||
from Cryptodome.Cipher import AES
|
from Cryptodome.Cipher import AES
|
||||||
|
|
||||||
from app.log import log
|
from app.log import log, logger
|
||||||
|
|
||||||
# from Crypto.Cipher import AES # 如果上面的导入失败,可以尝试使用这个
|
# 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)):
|
if not os.path.exists(os.path.dirname(out_path)):
|
||||||
return f"[-] out_path:'{out_path}' File not found!"
|
return f"[-] out_path:'{out_path}' File not found!"
|
||||||
if len(key) != 64:
|
if len(key) != 64:
|
||||||
return f"[-] key:'{key}' Error!"
|
logger.error(f"[-] key:'{key}' Error!")
|
||||||
|
return -1
|
||||||
password = bytes.fromhex(key.strip())
|
password = bytes.fromhex(key.strip())
|
||||||
with open(db_path, "rb") as file:
|
with open(db_path, "rb") as file:
|
||||||
blist = file.read()
|
blist = file.read()
|
||||||
@ -39,7 +40,8 @@ def decrypt(key: str, db_path, out_path):
|
|||||||
hash_mac.update(b'\x01\x00\x00\x00')
|
hash_mac.update(b'\x01\x00\x00\x00')
|
||||||
|
|
||||||
if hash_mac.digest() != first[-32:-12]:
|
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)]
|
newblist = [blist[i:i + DEFAULT_PAGESIZE] for i in range(DEFAULT_PAGESIZE, len(blist), DEFAULT_PAGESIZE)]
|
||||||
|
|
||||||
|
@ -124,12 +124,17 @@ class DecryptControl(QWidget, decryptUi.Ui_Dialog):
|
|||||||
if not os.path.exists(db_dir):
|
if not os.path.exists(db_dir):
|
||||||
QMessageBox.critical(self, "错误", "文件夹选择错误\n一般以wxid_xxx结尾")
|
QMessageBox.critical(self, "错误", "文件夹选择错误\n一般以wxid_xxx结尾")
|
||||||
return
|
return
|
||||||
|
if self.info.get('key') == 'none':
|
||||||
|
QMessageBox.critical(self, "错误", "密钥错误\n请检查微信版本是否为最新")
|
||||||
self.label_tip.setVisible(True)
|
self.label_tip.setVisible(True)
|
||||||
self.label_tip.setText('点我之后没有反应那就多等儿吧,不要再点了')
|
self.label_tip.setText('点我之后没有反应那就多等儿吧,不要再点了')
|
||||||
self.thread2 = DecryptThread(db_dir, self.info['key'])
|
self.thread2 = DecryptThread(db_dir, self.info['key'])
|
||||||
self.thread2.maxNumSignal.connect(self.setProgressBarMaxNum)
|
self.thread2.maxNumSignal.connect(self.setProgressBarMaxNum)
|
||||||
self.thread2.signal.connect(self.progressBar_view)
|
self.thread2.signal.connect(self.progressBar_view)
|
||||||
self.thread2.okSignal.connect(self.btnExitClicked)
|
self.thread2.okSignal.connect(self.btnExitClicked)
|
||||||
|
self.thread2.errorSignal.connect(
|
||||||
|
lambda x: QMessageBox.critical(self, "错误", "密钥错误\n请检查微信版本是否为最新")
|
||||||
|
)
|
||||||
self.thread2.start()
|
self.thread2.start()
|
||||||
|
|
||||||
def btnEnterClicked(self):
|
def btnEnterClicked(self):
|
||||||
@ -171,11 +176,14 @@ class DecryptControl(QWidget, decryptUi.Ui_Dialog):
|
|||||||
# 目标数据库文件
|
# 目标数据库文件
|
||||||
target_database = "app/DataBase/Msg/MSG.db"
|
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
|
import shutil
|
||||||
shutil.copy("app/DataBase/Msg/MSG0.db", target_database) # 使用一个数据库文件作为模板
|
shutil.copy("app/DataBase/Msg/MSG0.db", target_database) # 使用一个数据库文件作为模板
|
||||||
# 合并数据库
|
# 合并数据库
|
||||||
|
try:
|
||||||
merge_databases(source_databases, target_database)
|
merge_databases(source_databases, target_database)
|
||||||
|
except FileNotFoundError:
|
||||||
|
QMessageBox.critical(self, "错误", "数据库不存在\n请检查微信版本是否为最新")
|
||||||
self.DecryptSignal.emit(True)
|
self.DecryptSignal.emit(True)
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
@ -184,6 +192,7 @@ class DecryptThread(QThread):
|
|||||||
signal = pyqtSignal(str)
|
signal = pyqtSignal(str)
|
||||||
maxNumSignal = pyqtSignal(int)
|
maxNumSignal = pyqtSignal(int)
|
||||||
okSignal = pyqtSignal(str)
|
okSignal = pyqtSignal(str)
|
||||||
|
errorSignal = pyqtSignal(bool)
|
||||||
|
|
||||||
def __init__(self, db_path, key):
|
def __init__(self, db_path, key):
|
||||||
super(DecryptThread, self).__init__()
|
super(DecryptThread, self).__init__()
|
||||||
@ -206,13 +215,16 @@ class DecryptThread(QThread):
|
|||||||
for root, dirs, files in os.walk(self.db_path):
|
for root, dirs, files in os.walk(self.db_path):
|
||||||
for file in files:
|
for file in files:
|
||||||
if '.db' == file[-3:]:
|
if '.db' == file[-3:]:
|
||||||
|
if 'xInfo.db' == file:
|
||||||
|
continue
|
||||||
inpath = os.path.join(root, file)
|
inpath = os.path.join(root, file)
|
||||||
# print(inpath)
|
# print(inpath)
|
||||||
output_path = os.path.join(output_dir, file)
|
output_path = os.path.join(output_dir, file)
|
||||||
tasks.append([self.key, inpath, output_path])
|
tasks.append([self.key, inpath, output_path])
|
||||||
self.maxNumSignal.emit(len(tasks))
|
self.maxNumSignal.emit(len(tasks))
|
||||||
for i, task in enumerate(tasks):
|
for i, task in enumerate(tasks):
|
||||||
decrypt.decrypt(*task)
|
if decrypt.decrypt(*task) == -1:
|
||||||
|
self.errorSignal.emit(True)
|
||||||
self.signal.emit(str(i))
|
self.signal.emit(str(i))
|
||||||
# print(self.db_path)
|
# print(self.db_path)
|
||||||
self.okSignal.emit('ok')
|
self.okSignal.emit('ok')
|
||||||
|
@ -7,7 +7,7 @@ silk-python
|
|||||||
pyaudio
|
pyaudio
|
||||||
fuzzywuzzy
|
fuzzywuzzy
|
||||||
python-Levenshtein
|
python-Levenshtein
|
||||||
pillow
|
pillow==9.5.0
|
||||||
requests
|
requests
|
||||||
flask==3.0.0
|
flask==3.0.0
|
||||||
pyecharts==2.0.1
|
pyecharts==2.0.1
|
||||||
|
Loading…
Reference in New Issue
Block a user