-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathexport.py
More file actions
35 lines (28 loc) · 1.01 KB
/
export.py
File metadata and controls
35 lines (28 loc) · 1.01 KB
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
import json
from smda.Disassembler import Disassembler
def detectBackend():
backend = ""
version = ""
try:
import idaapi
backend = "IDA"
version = idaapi.IDA_SDK_VERSION
except ImportError:
pass
return (backend, version)
if __name__ == "__main__":
BACKEND, VERSION = detectBackend()
if BACKEND == "IDA":
from smda.ida.IdaInterface import IdaInterface
ida_interface = IdaInterface()
binary = ida_interface.getBinary()
base_addr = ida_interface.getBaseAddr()
DISASSEMBLER = Disassembler(backend=BACKEND)
REPORT = DISASSEMBLER.disassembleBuffer(binary, base_addr)
output_path = ida_interface.getIdbDir()
output_filepath = output_path + "ConvertedFromIdb.smda"
with open(output_filepath, "w") as fout:
json.dump(REPORT.toDict(), fout, indent=1, sort_keys=True)
print(f"Output saved to: {output_filepath}")
else:
raise Exception("No supported backend found.")