-
Notifications
You must be signed in to change notification settings - Fork 1
/
brickDevice.py
54 lines (45 loc) · 1.28 KB
/
brickDevice.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 frida, sys
if len(sys.argv) < 2:
print("Enter Target Device ID by running 'adb devices' command")
print("Usage: python3 brickDevice.py <deviceID>")
exit()
# Function to communicate with injected script
resFile = open("brickDeviceResult.txt","w+")
def on_message(message, data):
if message['type'] == 'send':
print("[*] {0}".format(message['payload']))
resFile.write("{0}".format(message['payload']))
resFile.write("\n")
else:
print(message)
# Find target device
devList = frida.get_device_manager().enumerate_devices()
devFound = 0
device = ""
devID = sys.argv[1]
for dev in devList:
if dev.id == devID:
print("Found " + dev.id)
device = dev
devFound = 1
break
if devFound == 0:
print("Error device not found " + devID)
exit()
# Spawn target app on the device
appPkg = "com.belkin.wemoandroid"
pid = device.spawn([appPkg])
device.resume(pid)
process = device.attach(pid)
# Read injected script
injectedScript = open(appPkg+".js","r",encoding="utf8")
script = process.create_script(injectedScript.read())
# Set up communication with injected script
script.on('message', on_message)
# Inject script
print('[*] Running')
script.load()
# Keep the script running
input()
print("[*] Closed")
process.detach()