ejschwartz commited on
Commit
d717efb
·
1 Parent(s): 4c2ae05
Files changed (1) hide show
  1. main.py +53 -3
main.py CHANGED
@@ -1,7 +1,57 @@
1
  import gradio as gr
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  demo.launch(server_name="0.0.0.0", server_port=7860)
 
1
  import gradio as gr
2
+ import shutil
3
+ import subprocess
4
+ import tempfile
5
 
 
 
6
 
7
+ def new_binary(file):
8
+
9
+ with tempfile.TemporaryDirectory() as TEMPDIR, tempfile.TemporaryDirectory() as OUTPUTDIR:
10
+ shutil.copy2(file.name, TEMPDIR)
11
+
12
+ # python3 generate.py --ghidra PATH_TO_GHIDRA_ANALYZEHEADLESS -t NUM_THREADS -n [NUM_FILES|None] -b BINARIES_DIR -o OUTPUT_DIR
13
+ output = subprocess.check_output(f"python /DIRTY/dataset-gen-ghidra/generate.py --ghidra /ghidra/support/analyzeHeadless -t 1 -b {TEMPDIR} -o {OUTPUT_DIR}")
14
+ print(output)
15
+
16
+
17
+
18
+ with gr.Blocks() as demo:
19
+
20
+ all_dis_state = gr.State()
21
+
22
+ gr.Markdown(
23
+ """
24
+ # DIRTY-Ghidra Testing
25
+ First, upload a binary.
26
+ """
27
+ )
28
+
29
+ file_widget = gr.File(label="Binary file")
30
+
31
+ def file_change_fn(file, progress=gr.Progress()):
32
+
33
+ print("hi")
34
+ new_binary(file)
35
+
36
+ if file is None:
37
+ return {
38
+ #col: gr.update(visible=False),
39
+ all_dis_state: None}
40
+ else:
41
+
42
+ #fun_data = {42: 2, 43: 3}
43
+ progress(0, desc="Disassembling executable")
44
+ #fun_data = get_all_dis(file.name)
45
+
46
+ #addrs = ["%#x" % addr for addr in fun_data.keys()]
47
+
48
+ return {
49
+ #col: gr.update(visible=True),
50
+ #fun_dropdown: gr.Dropdown.update(choices=addrs, value=addrs[0]),
51
+ #all_dis_state: fun_data
52
+ }
53
+
54
+ file_widget.change(file_change_fn, file_widget)
55
+
56
+ demo.queue()
57
  demo.launch(server_name="0.0.0.0", server_port=7860)