forked from shirof1re/OpenDocPy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fridahook.py
73 lines (58 loc) · 1.96 KB
/
fridahook.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
63
64
65
66
67
68
69
70
71
72
73
import sys
from base64 import b64decode
import frida
import json
import os
ADB_PATH = "platform-tools\\adb.exe"
with open("config/config.json") as f:
config = json.load(f)
server = config["server"]
HOST = server["host"]
PORT = server["port"]
MODE = server["mode"]
NO_PROXY = server["noProxy"]
ACTIVITY_MIN_START_TS = config["userConfig"]["activityMinStartTs"]
ACTIVITY_MAX_START_TS = config["userConfig"]["activityMaxStartTs"]
VISION = config["userConfig"]["vision"]
GADGET = server["gadget"]
def on_message(message, data):
print("[%s] => %s" % (message, data))
def main():
device = frida.get_usb_device(timeout=1)
if GADGET:
os.system(f'"{ADB_PATH}" reverse tcp:{PORT} tcp:{PORT}')
session = device.attach("Gadget")
elif MODE == "cn":
pid = device.spawn(
b64decode('Y29tLmh5cGVyZ3J5cGguYXJrbmlnaHRz').decode())
device.resume(pid)
session = device.attach(pid)
elif MODE == "global":
pid = device.spawn(
b64decode('Y29tLllvU3RhckVOLkFya25pZ2h0cw==').decode())
device.resume(pid)
session = device.attach(pid, realm="emulated")
with open("_.js", encoding="utf-8") as f:
s = f.read()
s = s.replace(
"@@@DOCTORATE_HOST@@@", "NO_PROXY" if NO_PROXY else HOST, 1
).replace(
"@@@DOCTORATE_PORT@@@", str(PORT), 1
).replace(
"@@@DOCTORATE_ACTIVITY_MIN_START_TS@@@", str(ACTIVITY_MIN_START_TS), 1
).replace(
"@@@DOCTORATE_ACTIVITY_MAX_START_TS@@@", str(ACTIVITY_MAX_START_TS), 1
)
script = session.create_script(s)
script.on('message', on_message)
script.load()
if VISION:
with open("vision.js", encoding="utf-8") as f:
s = f.read()
vision_script = session.create_script(s)
vision_script.load()
print("[!] Ctrl+D on UNIX, Ctrl+Z on Windows/cmd.exe to detach from instrumented program.")
sys.stdin.read()
session.detach()
if __name__ == '__main__':
main()