我想用python (jython)编写一个ghidra脚本,将当前程序中所有函数的二进制代码导出到.bin文件中。
我想出了这段代码,但是我不确定应该如何在BinaryExporter类中使用export()函数
函数签名:导出(java.io.File文件、DomainObject domainObj、AddressSetView addrSet、TaskMonitor监视器)
我应该如何填写这些参数?有没有更好的方法呢?
from ghidra.app.util.exporter import BinaryExporter
function_ASVs = [] #all functions address set view
exporter = BinaryExporter()
fm = currentProgram.getFunctionManager()
functions = fm.getFunctions(True)
for f in functions:
function_ASVs.append(f.getBody())
with open("C:\Users\Me\Desktop\target_file.bin", "w") as f:
for asv in function_ASVs:
ret = exporter.export(f, currentProgram, asv, ???)发布于 2021-03-14 02:40:27
monitor是GhidraScript从FlatProgramAPI继承的字段。您问题中的???应该是monitor。
我不使用python,但我认为您可以将您的脚本压缩为以下内容:
from ghidra.app.util.exporter import BinaryExporter
asv = AddressSet()
exporter = BinaryExporter()
for f in currentProgram.getFunctionManager().getFunctions(True):
asv.add(f.getBody())
with open("C:\Users\Me\Desktop\target_file.bin", "w") as f:
ret = exporter.export(f, currentProgram, asv, monitor)https://stackoverflow.com/questions/65148478
复制相似问题