Spaces:
Sleeping
Sleeping
Commit
·
66b746d
1
Parent(s):
ff724df
update
Browse files
main.py
CHANGED
@@ -64,13 +64,13 @@ def compile(compiler, flags, source):
|
|
64 |
return None, compile_output, disassembly
|
65 |
|
66 |
|
67 |
-
def disassemble_bytes(byte_data):
|
68 |
with tempfile.NamedTemporaryFile(suffix=".bin", delete=False) as temp_bin_file:
|
69 |
temp_bin_file.write(byte_data)
|
70 |
temp_bin_file_name = temp_bin_file.name
|
71 |
|
72 |
disassembly = subprocess.run(
|
73 |
-
["objdump", "-D", "-b", "binary", "-m",
|
74 |
capture_output=True,
|
75 |
text=True
|
76 |
).stdout
|
@@ -78,10 +78,10 @@ def disassemble_bytes(byte_data):
|
|
78 |
return disassembly
|
79 |
|
80 |
|
81 |
-
def predict(target_bytes, source, compiler, flags):
|
82 |
target_bytes = bytes.fromhex(target_bytes)
|
83 |
compiled_bytes, compile_output, compiled_disassembly = compile(compiler, flags, source)
|
84 |
-
target_disassembly = disassemble_bytes(target_bytes)
|
85 |
|
86 |
if compiled_bytes is not None:
|
87 |
return (
|
@@ -120,6 +120,7 @@ def run():
|
|
120 |
),
|
121 |
gr.Textbox(label="Compiler", value="g++"),
|
122 |
gr.Textbox(label="Compiler Flags", value="-O2"),
|
|
|
123 |
],
|
124 |
outputs=[
|
125 |
gr.Textbox(label="Compiled bytes"),
|
|
|
64 |
return None, compile_output, disassembly
|
65 |
|
66 |
|
67 |
+
def disassemble_bytes(byte_data, architecture):
|
68 |
with tempfile.NamedTemporaryFile(suffix=".bin", delete=False) as temp_bin_file:
|
69 |
temp_bin_file.write(byte_data)
|
70 |
temp_bin_file_name = temp_bin_file.name
|
71 |
|
72 |
disassembly = subprocess.run(
|
73 |
+
["objdump", "-D", "-b", "binary", "-m", architecture, temp_bin_file_name],
|
74 |
capture_output=True,
|
75 |
text=True
|
76 |
).stdout
|
|
|
78 |
return disassembly
|
79 |
|
80 |
|
81 |
+
def predict(target_bytes, source, compiler, flags, architecture):
|
82 |
target_bytes = bytes.fromhex(target_bytes)
|
83 |
compiled_bytes, compile_output, compiled_disassembly = compile(compiler, flags, source)
|
84 |
+
target_disassembly = disassemble_bytes(target_bytes, architecture)
|
85 |
|
86 |
if compiled_bytes is not None:
|
87 |
return (
|
|
|
120 |
),
|
121 |
gr.Textbox(label="Compiler", value="g++"),
|
122 |
gr.Textbox(label="Compiler Flags", value="-O2"),
|
123 |
+
gr.Textbox(label="Architecture", value="i386"),
|
124 |
],
|
125 |
outputs=[
|
126 |
gr.Textbox(label="Compiled bytes"),
|