Skip to content

Instantly share code, notes, and snippets.

@pawlos
Created September 27, 2020 16:59
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/a0f5f05c1ca146affb5212c9ad9cfadf to your computer and use it in GitHub Desktop.
Save pawlos/a0f5f05c1ca146affb5212c9ad9cfadf to your computer and use it in GitHub Desktop.
#exceptional
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
instruction = currentProgram.getListing().getInstructionAt(addr)
while True:
t = instruction.getFlowType()
if t == RefType.UNCONDITIONAL_CALL:
dest_addr = toAddr(int(str(instruction)[7:],16))
sym = currentProgram.symbolTable.getPrimarySymbol(dest_addr)
if 'FUN_' in str(sym):
addr = dest_addr
instruction = currentProgram.getListing().getInstructionAt(addr)
continue
print(codeUnitFormat.getRepresentationString(instruction))
instruction = instruction.getNext()
limiter += 1
if limiter > 50:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment