Skip to content

Commit

Permalink
增加PC端微信解密条件的判断
Browse files Browse the repository at this point in the history
  • Loading branch information
LC044 committed Nov 14, 2023
1 parent 54eddea commit cc059fc
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 51 deletions.
33 changes: 19 additions & 14 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/Ui/mainview.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
@Version : Python3.10
@comment : 主窗口
"""

from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
Expand Down Expand Up @@ -69,6 +68,7 @@ def __init__(self, username, parent=None):
# 创建右键菜单函数

def init_ui(self):
# self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.menubar.setStyleSheet("background-color: rgb(240, 240, 240);")

def create_rightmenu(self):
Expand Down
39 changes: 20 additions & 19 deletions app/Ui/pc_decrypt/decryptUi.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,54 +42,55 @@ def setupUi(self, Dialog):
self.label_ready = QtWidgets.QLabel(Dialog)
self.label_ready.setGeometry(QtCore.QRect(40, 260, 41, 21))
self.label_ready.setObjectName("label_ready")
self.widget = QtWidgets.QWidget(Dialog)
self.widget.setGeometry(QtCore.QRect(20, 50, 221, 151))
self.widget.setObjectName("widget")
self.gridLayout = QtWidgets.QGridLayout(self.widget)
self.layoutWidget = QtWidgets.QWidget(Dialog)
self.layoutWidget.setGeometry(QtCore.QRect(20, 50, 221, 151))
self.layoutWidget.setObjectName("layoutWidget")
self.gridLayout = QtWidgets.QGridLayout(self.layoutWidget)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout")
self.label_wxid = QtWidgets.QLabel(self.widget)
self.label_wxid.setText("")
self.label_wxid.setObjectName("label_wxid")
self.gridLayout.addWidget(self.label_wxid, 4, 1, 1, 1)
self.label = QtWidgets.QLabel(self.widget)
self.label = QtWidgets.QLabel(self.layoutWidget)
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
self.label_2 = QtWidgets.QLabel(self.widget)
self.label_2 = QtWidgets.QLabel(self.layoutWidget)
self.label_2.setObjectName("label_2")
self.gridLayout.addWidget(self.label_2, 2, 0, 1, 1)
self.label_5 = QtWidgets.QLabel(self.widget)
self.label_5 = QtWidgets.QLabel(self.layoutWidget)
self.label_5.setObjectName("label_5")
self.gridLayout.addWidget(self.label_5, 3, 0, 1, 1)
self.label_4 = QtWidgets.QLabel(self.widget)
self.label_4 = QtWidgets.QLabel(self.layoutWidget)
self.label_4.setObjectName("label_4")
self.gridLayout.addWidget(self.label_4, 4, 0, 1, 1)
self.label_key = QtWidgets.QLabel(self.widget)
self.label_key = QtWidgets.QLabel(self.layoutWidget)
self.label_key.setText("")
self.label_key.setObjectName("label_key")
self.gridLayout.addWidget(self.label_key, 5, 1, 1, 1)
self.label_phone = QtWidgets.QLabel(self.widget)
self.label_phone = QtWidgets.QLabel(self.layoutWidget)
self.label_phone.setText("")
self.label_phone.setObjectName("label_phone")
self.gridLayout.addWidget(self.label_phone, 2, 1, 1, 1)
self.label_6 = QtWidgets.QLabel(self.widget)
self.label_6 = QtWidgets.QLabel(self.layoutWidget)
self.label_6.setObjectName("label_6")
self.gridLayout.addWidget(self.label_6, 5, 0, 1, 1)
self.label_pid = QtWidgets.QLabel(self.widget)
self.label_pid = QtWidgets.QLabel(self.layoutWidget)
self.label_pid.setText("")
self.label_pid.setObjectName("label_pid")
self.gridLayout.addWidget(self.label_pid, 0, 1, 1, 1)
self.label_name = QtWidgets.QLabel(self.widget)
self.label_name = QtWidgets.QLabel(self.layoutWidget)
self.label_name.setText("")
self.label_name.setObjectName("label_name")
self.gridLayout.addWidget(self.label_name, 3, 1, 1, 1)
self.label_7 = QtWidgets.QLabel(self.widget)
self.label_7 = QtWidgets.QLabel(self.layoutWidget)
self.label_7.setObjectName("label_7")
self.gridLayout.addWidget(self.label_7, 1, 0, 1, 1)
self.label_version = QtWidgets.QLabel(self.widget)
self.label_version = QtWidgets.QLabel(self.layoutWidget)
self.label_version.setText("")
self.label_version.setObjectName("label_version")
self.gridLayout.addWidget(self.label_version, 1, 1, 1, 1)
self.lineEdit = QtWidgets.QLineEdit(self.layoutWidget)
self.lineEdit.setStyleSheet("background:transparent;border-width:0;border-style:outset")
self.lineEdit.setFrame(False)
self.lineEdit.setObjectName("lineEdit")
self.gridLayout.addWidget(self.lineEdit, 4, 1, 1, 1)
self.gridLayout.setColumnMinimumWidth(0, 1)
self.gridLayout.setColumnMinimumWidth(1, 2)
self.gridLayout.setRowMinimumHeight(5, 10)
Expand Down
19 changes: 11 additions & 8 deletions app/Ui/pc_decrypt/decryptUi.ui
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<string>未就绪</string>
</property>
</widget>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>20</x>
Expand All @@ -113,13 +113,6 @@
</property>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,10" columnstretch="1,3"
rowminimumheight="0,0,0,0,0,10" columnminimumwidth="1,2">
<item row="4" column="1">
<widget class="QLabel" name="label_wxid">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
Expand Down Expand Up @@ -197,6 +190,16 @@
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEdit">
<property name="styleSheet">
<string notr="true">background:transparent;border-width:0;border-style:outset</string>
</property>
<property name="frame">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QPushButton" name="pushButton_3">
Expand Down
21 changes: 15 additions & 6 deletions app/Ui/pc_decrypt/pc_decrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,29 @@ def __init__(self, parent=None):
self.btn_getinfo.clicked.connect(self.get_info)
self.btn_db_dir.clicked.connect(self.select_db_dir)
self.info = {}
self.lineEdit.setFocus()
self.ready = False
self.wx_dir = None

# @log
def get_info(self):
try:
result = get_wx_info.get_info()
if result == -1:
QMessageBox.critical(self, "错误", "请登录微信")
elif result == -2:
QMessageBox.critical(self, "错误", "微信版本不匹配\n请更新微信版本为:3.9.8.15")
# print(result)
if result:
else:
self.ready = True
self.info = result[0]
self.label_key.setText(self.info['key'])
self.label_wxid.setText(self.info['wxid'])
self.lineEdit.setText(self.info['wxid'])
self.label_name.setText(self.info['name'])
self.label_phone.setText(self.info['mobile'])
self.label_pid.setText(str(self.info['pid']))
self.label_version.setText(self.info['version'])
self.lineEdit.setFocus()
if self.wx_dir and os.path.exists(os.path.join(self.wx_dir, self.info['wxid'])):
self.label_ready.setText('已就绪')
except Exception as e:
Expand All @@ -59,14 +66,16 @@ def decrypt(self):
if not self.ready:
QMessageBox.critical(self, "错误", "请先获取密钥")
return

if not self.wx_dir:
QMessageBox.critical(self, "错误", "请先选择微信安装路径")
return
if self.lineEdit.text() == 'None':
QMessageBox.critical(self, "错误", "请填入wxid")
return
if self.ready:
if not os.path.exists(os.path.join(self.wx_dir, self.info['wxid'])):
QMessageBox.critical(self, "错误", "文件夹选择错误\n一般以WeChat Files结尾")
return
# self.thread1 = MyThread()
# self.thread1.signal.connect(self.progressBar_view)
# self.thread1.start()
db_dir = os.path.join(self.wx_dir, self.info['wxid'], 'Msg')
self.thread2 = DecryptThread(db_dir, self.info['key'])
self.thread2.maxNumSignal.connect(self.setProgressBarMaxNum)
Expand Down
10 changes: 7 additions & 3 deletions app/decrypt/get_wx_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import psutil
from win32com.client import Dispatch

from app.log import log

ReadProcessMemory = ctypes.windll.kernel32.ReadProcessMemory
void_p = ctypes.c_void_p

Expand All @@ -30,7 +32,7 @@ def get_info_wxid(h_process, address, n_size=32, address_len=8):
if ReadProcessMemory(h_process, void_p(address), array, address_len, 0) == 0: return "None"
address = int.from_bytes(array, byteorder='little') # 逆序转换为int地址(key地址)
wxid = get_info_without_key(h_process, address, n_size)
if not wxid.startswith("wxid_"): wxid = "None"
# if not wxid.startswith("wxid_"): wxid = "None"
return wxid


Expand All @@ -46,6 +48,7 @@ def get_key(h_process, address, address_len=8):


# 读取微信信息(account,mobile,name,mail,wxid,key)
@log
def read_info(version_list):
wechat_process = []
result = []
Expand All @@ -55,7 +58,7 @@ def read_info(version_list):
wechat_process.append(process)

if len(wechat_process) == 0:
return "[-] WeChat No Run"
return -1

for process in wechat_process:
tmp_rd = {}
Expand All @@ -65,7 +68,7 @@ def read_info(version_list):

bias_list = version_list.get(tmp_rd['version'], None)
if not isinstance(bias_list, list):
return f"[-] WeChat Current Version {tmp_rd['version']} Is Not Supported"
return -2

wechat_base_address = 0
for module in process.memory_maps(grouped=False):
Expand Down Expand Up @@ -97,6 +100,7 @@ def read_info(version_list):
return result


@log
def get_info():
VERSION_LIST_PATH = "app/decrypt/version_list.json"

Expand Down

0 comments on commit cc059fc

Please sign in to comment.