from ghidra.app.decompiler import DecompInterface from ghidra.util.task import ConsoleTaskMonitor
# get the current program # here currentProgram is predefined
program = currentProgram decompinterface = DecompInterface() decompinterface.openProgram(program); functions = program.getFunctionManager().getFunctions(True) for function inlist(functions): print(function) # decompile each function tokengrp = decompinterface.decompileFunction(function, 0, ConsoleTaskMonitor()) print(tokengrp.getDecompiledFunction().getC())
for function inlist(functions): # 外部函数不反编译 if function.isExternal() or"::"instr(function): # print(function,function.getExternalLocation(),function.getSymbol()) continue
print("[+] Decompiling {}".format(function)) # # decompile each function tokengrp = decompinterface.decompileFunction(function, 0, ConsoleTaskMonitor())
-noanalysis If present, executables will not be analyzed (auto-analysis occurs by default).
-max-cpu <max cpu cores to use> Sets the maximum numberof CPU cores to use during headless processing (must be aninteger). Setting max-cpu to0ora negative integer is equivalent to setting the maximum numberof cores to1.