Skip to content

Instantly share code, notes, and snippets.

@pawlos
Last active September 27, 2020 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pawlos/7b85dcc65da816c0f1e17254377aee67 to your computer and use it in GitHub Desktop.
Save pawlos/7b85dcc65da816c0f1e17254377aee67 to your computer and use it in GitHub Desktop.
#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