-
Notifications
You must be signed in to change notification settings - Fork 32
/
frida-import-list.py
executable file
·42 lines (36 loc) · 1.11 KB
/
frida-import-list.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
#!/usr/bin/python
import sys
import frida
import time
def on_message(message, data):
if 'payload' in message:
pname = message['payload']
filename = ("%s.bin" % pname)
print("Writing %s" % filename)
fo = open(filename, "wb")
fo.write(data)
fo.close()
def list_imports(target_process):
session = frida.get_usb_device().attach(target_process)
print("Listing imports for %s:" % target_process)
script = session.create_script("""
var modules = Process.enumerateModulesSync();
var module;
for (var i=0; i<modules.length; i++) {
module = modules[i];
console.log("\t"+module.name+":"+module.base+":"+module.size);
}
""")
script.on('message', on_message)
script.load()
session.detach()
if __name__ == '__main__':
if len(sys.argv) < 2:
print 'Usage: %s <process name or PID>' % __file__
sys.exit(1)
try:
target_process = int(sys.argv[1])
except ValueError:
target_process = sys.argv[1]
list_imports(target_process)
sys.exit(0)