You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
which means all LDR instructions have been misinterpreted, and may be something wrong with the aarch64 compilation function.
Last but not the least, I enjoyed this project very much, any of your feedback is appreciated!
from __future__ importprint_functionfrompprintimportpprintfrommiasm.analysis.machineimportMachinefrommiasm.archimportaarch64frommiasm.arch.aarch64.archimportmn_aarch64frommiasm.coreimportparse_asm, asmblockfrommiasm.arch.aarch64.lifter_model_callimportLifter_Aarch64lfrommiasm.coreimportlocationdbfrommiasm.core.locationdbimportLocationDBfrommiasm.loader.strpatchworkimportStrPatchworkfrommiasm.analysis.binaryimportContainerfrommiasm.ir.irimportIRCFG, AssignBlockfrommiasm.expression.expressionimport*frommiasm.ir.symbexecimportSymbolicExecutionEngineimportsysfromfuture.utilsimportviewvaluesfrommiasm.analysis.binaryimportContainerfrommiasm.analysis.machineimportMachinefrommiasm.core.locationdbimportLocationDBimportlogging# Quiet warningsasmblock.log_asmblock.setLevel(logging.ERROR)
defgen_arm64_asmcfg(asm):
# First, asm codemachine=Machine("aarch64l")
# Add dummy label "end" at code's endcode=asm+"\nend:\n"loc_db=LocationDB()
# The main will be at address 0loc_db.set_location_offset(loc_db.get_or_create_name_location("main"), 0x0)
# The second param should be 'l' for little endian or 'b' for big endianasmcfg=parse_asm.parse_txt(mn_aarch64, 'l', code, loc_db)
# Assemble shellcodevirt=StrPatchwork()
patches=asmblock.asm_resolve_final(machine.mn, asmcfg)
# Put shellcode in a stringforoffset, rawinpatches.items():
virt[offset] =rawdata=bytes(virt)
cont=Container.fallback_container(
data,
vm=None, addr=0,
loc_db=loc_db,
)
dis_engine=machine.dis_engine# Disassemble back the shellcode# Now, basic blocks are at known position, determined by# the assembled versionmdis=dis_engine(cont.bin_stream, loc_db=cont.loc_db)
asmcfg=mdis.dis_multiblock(0)
returnasmcfgdeflift_arm64_asm(asmcfg, model_call=False, lifter_custom=None):
machine=Machine("aarch64l")
# Get a lifterlifter=Noneifmodel_callandlifter_customisNone:
lifter=Lifter_Aarch64l(asmcfg.loc_db)
eliflifter_customisnotNone:
lifter=lifter_custom(asmcfg.loc_db)
else:
lifter=machine.lifter(asmcfg.loc_db)
# Translate to IRircfg=lifter.new_ircfg_from_asmcfg(asmcfg)
returnircfg,lifterreal_asm_text= \
'''main: LDR X1, [SP, 0x18] ADRP X0, 0 ADD X0, X0, 0xB44 LDR X8, [SP] LDR X8, [X8, 0x28] LDR X9, [SP, 0x28] CMP X8, X9'''asmcfg=gen_arm64_asmcfg(real_asm_text)
print(asmcfg)
The text was updated successfully, but these errors were encountered:
Hello, I have a piece of code at the bottom, the output should be something like:
roughly the same as variable
real_asm_text
However, I got the following result instead:
which means all LDR instructions have been misinterpreted, and may be something wrong with the aarch64 compilation function.
Last but not the least, I enjoyed this project very much, any of your feedback is appreciated!
The text was updated successfully, but these errors were encountered: