run_tcp_test.py
1.53 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
import frida
import time
# Connect via TCP through adb forward
device = frida.get_device_manager().add_remote_device("127.0.0.1:27042")
print(f"Connected via TCP: {device.name}")
# Get PID by enumerating processes (or hardcode)
try:
processes = device.enumerate_processes()
wechat_pid = None
for p in processes:
if p.name == "com.tencent.mm":
wechat_pid = p.pid
print(f"Found WeChat PID: {wechat_pid}")
break
if not wechat_pid:
print("WeChat not found, using hardcoded PID 15059")
wechat_pid = 27337
except Exception as e:
print(f"enumerate_processes failed: {e}")
wechat_pid = 27337
print(f"Attaching to PID {wechat_pid}...")
session = device.attach(wechat_pid)
print("Attached!")
script = session.create_script("""
console.log("Java.available = " + (typeof Java !== 'undefined' ? Java.available : 'undefined'));
if (typeof Java !== 'undefined' && Java.available) {
Java.perform(function() {
console.log("Java.perform OK");
try {
var r1 = Java.use("u01.r1");
console.log("u01.r1 loaded");
var builder = r1.a("yibooo");
var clsName = builder.getClass().getName();
console.log("BUILDER_CLASS:" + clsName);
} catch(e) {
console.log("Error: " + e);
}
});
} else {
console.log("Java not available");
}
""")
def on_message(message, data):
print(f"[MSG] {message}")
script.on("message", on_message)
script.load()
print("Script loaded")
time.sleep(5)
print("Done")