使用Binwalk的pythonapi从二进制文件中提取文件

2024-06-09 18:08:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图用python创建一个对固件文件执行提取(matryoshka)的程序。基本上,我希望使用ap功能在python中实现“binwalk-Me binary_file”,而不是调用子进程。不幸的是,binwalk API的文档很少。下面是一段代码,展示了我现在是如何做的。在

from subprocess import call
import binwalk

for module in binwalk.scan('test.bin',signature=True,quiet=False):
    print ("%s Results:" % module.name)

for result in module.results:
    print ("\t%s    0x%.8X    %s" % (result.file.name, result.offset, result.description))

call(["binwalk","-Me","test.bin"])
任何建议都太好了!!!在


Tags: nameintestimportforbinresultcall
2条回答

您可以使用以下方法:

binwalk.scan('test.bin', signature=True,extract=True)

而不是call(["binwalk","-Me","test.bin"])

它不是一个单独的用于提取的函数,而是scan函数中的一个参数。在

for module in binwalk.scan('test.bin',signature=True,quiet=False, extract=True):
    print ("%s Results:" % module.name)

相关问题 更多 >