我有一個大學項目,我必須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