-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
41 lines (29 loc) · 839 Bytes
/
run.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
import subprocess
import os
GHIDRA_ANALYZEHEADLESS_PATH = 'path/To/Ghidra/support/analyzeHeadless'
BINARY_PATH = 'path/to/bins'
def ghidra(binary):
if not os.path.exists(f"./src/tmp"):
os.mkdir(f"./src/tmp")
cmd = []
if not os.path.exists(binary):
print("[-] input path does not exist")
return
cmd = [
GHIDRA_ANALYZEHEADLESS_PATH,
f"ghidra{os.sep}tmp",
"analyze",
"-prescript",
"src/pre.py",
"-postscript",
"src/post.py",
"-import",
binary,
]
subprocess.run(cmd)
return
if __name__ == '__main__':
binaries = os.listdir(BINARY_PATH)
for binary in binaries:
binary = BINARY_PATH + binary
ghidra(binary)