# Ghidra headless post-script: dump function/strings/block overview. # Usage: analyzeHeadless -process -noanalysis # -scriptPath tools/ghidra_scripts -postScript ExportOverview.py #@category Analysis from ghidra.program.model.symbol import SymbolType fm = currentProgram.getFunctionManager() listing = currentProgram.getListing() funcs = fm.getFunctions(True) n = 0 print('=== FUNCTIONS ===') for f in funcs: print('%s %s' % (f.getEntryPoint(), f.getName())) n += 1 print('total functions: %d' % n) print('=== STRINGS (>=6 chars) ===') di = listing.getDefinedData(True) ns = 0 for d in di: dt = d.getDataType().getName().lower() if 'char' in dt or 'unicode' in dt: v = d.getValue() if v 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'))