forked from 592767809/WeChatOpenDevTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWeChatAppEx.exe.py
62 lines (50 loc) · 1.94 KB
/
WeChatAppEx.exe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# HOOK微信小程序
import os
import sys
import frida
import psutil
def on_message(message, data):
if message["type"] == 'send':
print(message['payload'])
elif message["type"] == 'error':
print(message['stack'])
def main():
version = sys.argv[1].lower()
bit = sys.argv[2].lower()
addressSource = ""
addressSourceHeadFilePath = os.path.join(os.path.dirname(__file__), 'Core', 'AddressSource.head')
addressSourceEndFilePath = os.path.join(os.path.dirname(__file__), 'Core', 'AddressSource.end')
addressFilePath = os.path.join(os.path.dirname(__file__), 'Core', 'WeChatAppEx.exe', f'address_{version}_{bit}.json')
hookFilePath = os.path.join(os.path.dirname(__file__), 'Core', 'WeChatAppEx.exe', 'hook.js')
if os.path.exists(addressFilePath):
with open(addressSourceHeadFilePath, 'r', encoding='utf-8') as f:
addressSource += f.read()
with open(addressFilePath, 'r', encoding='utf-8') as f:
addressSource += f.read()
with open(addressSourceEndFilePath, 'r', encoding='utf-8') as f:
addressSource += f.read()
with open(hookFilePath, 'r', encoding='utf-8') as f:
addressSource += f.read()
else:
print(f'暂不支持 {version}_{bit} 的版本!')
return
print("HOOK文件组装成功!")
device = frida.get_local_device()
processes = device.enumerate_processes()
pid = -1
for p_ in processes:
if p_.name == 'WeChatAppEx.exe':
commandLine = ' '.join(psutil.Process(p_.pid).cmdline())
if '--type=' not in commandLine:
pid = p_.pid
if pid == -1:
print("WeChatAppEx.exe 主进程未找到!")
return
session = frida.attach(pid)
script = session.create_script(addressSource)
script.on('message', on_message)
script.load()
sys.stdin.read()
if __name__ == '__main__':
# python WeChatAppEx.exe.py 8447 x64
main()