我有一个大学项目,我必须disagmble二进制文件。所以我尝试了凯普斯通。我尝试了几周与Java,但它没有工作,所以自从昨天我教了自己一个小Python。要阅读二进制我想:凯普尔反汇编从Python中的二进制文件
file = open('binary_file')
content = file.readlines()
从这个链接:Python中读取二进制文件(.OUT),并与顶层和指令反汇编从顶峰http://www.capstone-engine.org/lang_python.html
拆开我的解决方案,从在线反汇编,结果是超过13000行。当我启动我的时候,我只能得到一个(0x1000:sc 0x2b)。我找不到这个错误,因为在我眼中,它是没问题的,但我没有任何Python或Capstone的计划。
顺便说一下,Capstone页面的Testcode工作正常,所以它没有错,我认为安装。
代码:
from capstone import *
file = open('C:/...sth', 'rb')
content = file.read()
ergebnism = open("C:/.../ergebnis.txt", "w")
mi = Cs(CS_ARCH_MIPS, CS_MODE_MIPS32)
for i in mi.disasm(content, 0x1000):
print("0x%x:\t%s\t%s" %(i.address, i.mnemonic, i.op_str))
#for (address, size, mnemonic, op_str) in mi.disasm_lite(content,0x1000):
# print("0x%x:\t%s\t%s" %(address, mnemonic, op_str))
ergebnism.write("0x%x:\t%s\t%s" %(i.address, i.mnemonic, i.op_str))
ergebnism.write("\n")
ergebnism.close()
file2 = open('C:/...erdb', 'rb')
content2 = file2.read()
ergebnisp = open("C:/.../ergebnisp.txt", "w")
pp = Cs(CS_ARCH_PPC, CS_MODE_64)
for i in pp.disasm(content, 0x1000):
print("0x%x:\t%s\t%s" %(i.address, i.mnemonic, i.op_str))
#for (address, size, mnemonic, op_str) in pp.disasm_lite(content2, 0x1000):
#print("0x%x:\t%s\t%s" %(address, mnemonic, op_str))
ergebnisp.write("0x%x:\t%s\t%s" %(i.address, i.mnemonic, i.op_str))
ergebnisp.write("\n")
ergebnisp.close()
是的,真是太好了。感谢您对我的文本进行了两次纠正,但我仍然没有解决问题,明天我必须发送它。我不知道如何接受更正,但这是目前真的不符合我的兴趣 – AzadefiaS