forked from JaveleyQAQ/WeChatOpenDevTools-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommons.py
More file actions
70 lines (60 loc) · 2.82 KB
/
commons.py
File metadata and controls
70 lines (60 loc) · 2.82 KB
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
63
64
65
66
67
68
69
70
#commons.py //2024年3月5日23点25分
from utils.colors import Color
from utils.wechatutils import WechatUtils
import frida,sys,time
class Commons:
def __init__(self):
self.wechatutils_instance = WechatUtils()
self.device = frida.get_local_device()
self.process = self.device.enumerate_processes()
self.pid = -1
self.version_list = []
self.configs_path = ""
def onMessage(self, message, data):
if message['type'] == 'send':
print(Color.GREEN + message['payload'], Color.END)
elif message['type'] == 'error':
print(Color.RED + message['stack'], Color.END)
def inject_wehcatEx(self, pid, code):
session = frida.attach(pid)
script = session.create_script(code)
script.on("message", self.onMessage)
script.load()
sys.stdin.read()
# session.detach()
def inject_wechatDLL(self, path, code):
pid = self.device.spawn(path)
session = frida.attach(pid)
script = session.create_script(code)
script.on("message", self.onMessage)
script.load()
self.device.resume(pid)
time.sleep(10)
session.detach()
# sys.stdin.read()
def load_wechatEx_configs(self):
path = self.wechatutils_instance.get_configs_path()
pid, version = self.wechatutils_instance.get_wechat_pid_and_version()
if pid or version is not None:
wehcatEx_hookcode = open(path + "..\\scripts\\hook.js", "r", encoding="utf-8").read()
wechatEx_addresses = open(path + "..\\configs\\address_{}_x64.json".format(version)).read()
wehcatEx_hookcode = "var address=" + wechatEx_addresses + wehcatEx_hookcode
self.inject_wehcatEx(pid, wehcatEx_hookcode)
else:
self.wechatutils_instance.print_process_not_found_message()
def load_wechatEXE_configs(self):
pid, version = self.wechatutils_instance.get_wechat_pid_and_version()
if pid or version is not None:
print(Color.RED+f"[-] 请退出微信后在执行该命令 "+Color.END)
return 0
wechatEXEpath = self.wechatutils_instance.find_installation_path("微信")
path = self.wechatutils_instance.get_configs_path()
wehcatEXE_hookcode = open(path + "..\\scripts\\WechatWin.dll\\hook.js", "r", encoding="utf-8").read()
self.inject_wechatDLL(wechatEXEpath, wehcatEXE_hookcode)
def load_wechatEXE_and_wechatEx(self):
pid, version = self.wechatutils_instance.get_wechat_pid_and_version()
if pid or version is not None:
print(Color.RED+f"[-] 请关闭微信后在执行该命令 "+Color.END)
return 0
self.load_wechatEXE_configs()
self.load_wechatEx_configs()