forked from shirof1re/OpenDocPy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
startfrida.py
54 lines (43 loc) · 1.64 KB
/
startfrida.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
import os
import sys
import subprocess
from contextlib import suppress
import json
from ppadb.client import Client as AdbClient
server_port = json.load(open('config/config.json', 'r'))["server"]["port"]
default_ports = [7555, 5555, 62001]
ADB_PATH = "platform-tools\\adb.exe"
def get_device():
devices = client.devices()
if len(devices) == 0:
for port in default_ports:
with suppress(Exception):
client.remote_connect("127.0.0.1", port)
devices = client.devices()
if len(devices) == 1:
return devices[0]
print("No emulator found.\nEnter the adb connection url with port manually or type q to exit or press enter to wait for a device: ")
result = input()
if result.lower() == "q":
sys.exit(0)
if result:
result = result.split(":")
client.remote_connect(result[0], int(result[1]))
devices = client.devices()
if len(devices) == 1:
return devices[0]
os.system('cls')
# subprocess.run(f'"{ADB_PATH}" kill-server')
subprocess.run(f'"{ADB_PATH}" start-server')
client = AdbClient(host="127.0.0.1", port=5037)
device = None
print("Trying to connect to currently opened emulator")
device = get_device()
print("Check the emulator and accept if it asks for root permission.")
with suppress(RuntimeError):
device.root()
device = get_device()
os.system(f'"{ADB_PATH}" wait-for-device')
print("\nRunning frida\nNow you can start fridahook\n")
os.system(f'"{ADB_PATH}" reverse tcp:{server_port} tcp:{server_port}')
os.system(f'"{ADB_PATH}"' + " shell /data/local/tmp/frida-server &")