Last active
September 27, 2020 17:00
-
-
Save pawlos/7b85dcc65da816c0f1e17254377aee67 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#armageddon | |
from ghidra.program.model.listing import CodeUnitFormat, CodeUnitFormatOptions | |
from ghidra.program.model.symbol import RefType | |
codeUnitFormat = CodeUnitFormat(CodeUnitFormatOptions(CodeUnitFormatOptions.ShowBlockName.ALWAYS,CodeUnitFormatOptions.ShowNamespace.ALWAYS,"",True,True,True,True,True,True,True)) | |
addr = toAddr('<start address>') | |
limiter = 0 | |
limit = 50 | |
instruction = currentProgram.getListing().getInstructionAt(addr) | |
while True: | |
t = instruction.getFlowType() | |
if t == RefType.UNCONDITIONAL_JUMP: | |
dest_addr = toAddr(int(str(instruction)[2:],16)) | |
sym = currentProgram.symbolTable.getPrimarySymbol(dest_addr) | |
if 'LAB_' in str(sym): | |
addr = dest_addr | |
instruction = currentProgram.getListing().getInstructionAt(addr) | |
continue | |
print(str(instruction.address) +': '+codeUnitFormat.getRepresentationString(instruction)) | |
instruction = instruction.getNext() | |
limiter += 1 | |
if limiter > limit: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment