Commit ·
54f2f10
1
Parent(s): cfe2c85
run decompiler
Browse files
main.py
CHANGED
|
@@ -149,9 +149,32 @@ This is a space to experiment with our quantized 22B neural model for decompilat
|
|
| 149 |
"addrs": addrs},
|
| 150 |
}
|
| 151 |
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
print("Lauching now.")
|
| 157 |
|
|
|
|
| 149 |
"addrs": addrs},
|
| 150 |
}
|
| 151 |
|
| 152 |
+
@fun_dropdown.change(inputs=[fun_dropdown, state], outputs=[disassembly, original_decompile, decompile, model_output])
|
| 153 |
+
def function_change_fn(selected_fun, state, progress=gr.Progress()):
|
| 154 |
+
|
| 155 |
+
with tempfile.TemporaryDirectory() as TEMP_DIR:
|
| 156 |
+
|
| 157 |
+
progress(0, desc=f"Running GhidraFunctionCPPExporter {hex(selected_fun)}...")
|
| 158 |
+
|
| 159 |
+
o = subprocess.run(["/code/GhidraFunctionCPPExporter/export.bash", state['file'], "address_set_str", str(selected_fun), "output_dir", TEMP_DIR], shell=False, capture_output=True, encoding="utf8")
|
| 160 |
+
|
| 161 |
+
print(o.stdout)
|
| 162 |
+
print(o.stderr)
|
| 163 |
+
|
| 164 |
+
if (o.returncode != 0):
|
| 165 |
+
raise Exception(f"Ghidra export failed with return code {o.returncode}: {o.stderr}")
|
| 166 |
+
|
| 167 |
+
# Show files in TEMP_DIR
|
| 168 |
+
print("Files in TEMP_DIR:")
|
| 169 |
+
for f in os.listdir(TEMP_DIR):
|
| 170 |
+
print(f)
|
| 171 |
+
|
| 172 |
+
return {
|
| 173 |
+
disassembly: gr.Textbox(value=""),
|
| 174 |
+
original_decompile: gr.Textbox(value=""),
|
| 175 |
+
decompile: gr.Textbox(value=""),
|
| 176 |
+
model_output: gr.JSON(value=None),
|
| 177 |
+
}
|
| 178 |
|
| 179 |
print("Lauching now.")
|
| 180 |
|