mtk-wifi-fw/tools/ghidra_scripts/ExportOverview.py

31 lines
1.1 KiB
Python

# Ghidra headless post-script: dump function/string/block overview.
# Run via PyGhidra launcher (see PLAN.md tooling notes).
#@category Analysis
fm = currentProgram.getFunctionManager()
listing = currentProgram.getListing()
print('=== FUNCTIONS ===')
n = 0
for f in fm.getFunctions(True):
print('%s %s' % (f.getEntryPoint(), f.getName()))
n += 1
print('total functions: %d' % n)
print('=== STRINGS (>=6 chars) ===')
ns = 0
for d in listing.getDefinedData(True):
dt = d.getDataType().getName().lower()
if 'char' in dt or 'unicode' in dt or 'string' in dt:
v = d.getValue()
if v is not None and len(str(v)) >= 6:
print('%s %r' % (d.getAddress(), str(v)[:120]))
ns += 1
print('total strings: %d' % ns)
print('=== MEMORY BLOCKS ===')
for b in currentProgram.getMemory().getBlocks():
print('%s %s %s r%s w%s x%s' % (b.getName(), b.getStart(), b.getSize(),
'1' if b.isRead() else '0',
'1' if b.isWrite() else '0',
'1' if b.isExecute() else '0'))