Spaces:
Running
Running
Commit
·
e92c772
1
Parent(s):
1bc7f4c
Filter trivial functions
Browse files- Dockerfile +1 -1
- main.py +9 -5
Dockerfile
CHANGED
@@ -27,7 +27,7 @@ RUN unzip ghidrathon/Ghidrathon-v4.0.0.zip -d /ghidra/Ghidra/Extensions
|
|
27 |
|
28 |
WORKDIR /
|
29 |
|
30 |
-
RUN git clone -b main https://github.com/edmcman/DIRTY # 09-
|
31 |
#ADD ./DIRTY /DIRTY
|
32 |
|
33 |
RUN --mount=type=cache,target=/root/.cache pip install --upgrade -r /DIRTY/requirements.txt
|
|
|
27 |
|
28 |
WORKDIR /
|
29 |
|
30 |
+
RUN git clone -b main https://github.com/edmcman/DIRTY # 09-23-24
|
31 |
#ADD ./DIRTY /DIRTY
|
32 |
|
33 |
RUN --mount=type=cache,target=/root/.cache pip install --upgrade -r /DIRTY/requirements.txt
|
main.py
CHANGED
@@ -10,10 +10,16 @@ def get_functions(file):
|
|
10 |
|
11 |
with tempfile.TemporaryDirectory() as TEMP_DIR:
|
12 |
|
13 |
-
|
|
|
14 |
f"/ghidra/support/analyzeHeadless {TEMP_DIR} Project -import {file} -postscript /home/user/app/scripts/dump_functions.py {TEMP_DIR}/funcs.json",
|
15 |
shell=True,
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
json_funcs = json.load(open(f"{TEMP_DIR}/funcs.json"))
|
19 |
|
@@ -32,9 +38,9 @@ with gr.Blocks() as demo:
|
|
32 |
To get started, upload a binary or select one of the example binaries below.
|
33 |
|
34 |
## TODOs
|
35 |
-
* Filter out trivial functions
|
36 |
* Avoid re-running Ghidra when changing the function
|
37 |
* Make predictions for variables in non-unique storage locations
|
|
|
38 |
"""
|
39 |
)
|
40 |
|
@@ -127,8 +133,6 @@ with gr.Blocks() as demo:
|
|
127 |
|
128 |
with tempfile.TemporaryDirectory() as TEMP_DIR:
|
129 |
|
130 |
-
print(selected_fun)
|
131 |
-
|
132 |
progress(0, desc=f"Running DIRTY Ghidra on {hex(selected_fun)}...")
|
133 |
|
134 |
try:
|
|
|
10 |
|
11 |
with tempfile.TemporaryDirectory() as TEMP_DIR:
|
12 |
|
13 |
+
try:
|
14 |
+
output = subprocess.check_output(
|
15 |
f"/ghidra/support/analyzeHeadless {TEMP_DIR} Project -import {file} -postscript /home/user/app/scripts/dump_functions.py {TEMP_DIR}/funcs.json",
|
16 |
shell=True,
|
17 |
+
)
|
18 |
+
except Exception as e:
|
19 |
+
raise gr.Error(f"Unable to run Ghidra on {file}: {e}\n{output}")
|
20 |
+
|
21 |
+
if not os.path.exists(f"{TEMP_DIR}/funcs.json"):
|
22 |
+
raise gr.Error(f"DIRTY Ghidra failed to produce output: {output}")
|
23 |
|
24 |
json_funcs = json.load(open(f"{TEMP_DIR}/funcs.json"))
|
25 |
|
|
|
38 |
To get started, upload a binary or select one of the example binaries below.
|
39 |
|
40 |
## TODOs
|
|
|
41 |
* Avoid re-running Ghidra when changing the function
|
42 |
* Make predictions for variables in non-unique storage locations
|
43 |
+
* Use JSON viewer for model output
|
44 |
"""
|
45 |
)
|
46 |
|
|
|
133 |
|
134 |
with tempfile.TemporaryDirectory() as TEMP_DIR:
|
135 |
|
|
|
|
|
136 |
progress(0, desc=f"Running DIRTY Ghidra on {hex(selected_fun)}...")
|
137 |
|
138 |
try:
|