I read the documentation of headleass analyzer. It is used to perform analysis on existing binaries. I know that -postscript
flag allows to enter the analysis script. I have a java script which works fine. But, I want to use python 3 for the analysis. I want to run that like:
./analyzeHeadless ghidra-project-directory -import binary-file -postscript yourpythonscript
Is it possible to run python script for the analysis? Also, is there any documentation available to do that?
Edit:
I made a following script and it does work fine (but it gives me not found errors for DecompInterface):
import ghidra.app.util.headless.HeadlessScript; import ghidra.app.decompiler.ClangNode; import ghidra.app.decompiler.ClangToken; import ghidra.app.decompiler.ClangLine; import ghidra.app.decompiler.ClangTokenGroup; import ghidra.app.decompiler.DecompInterface; import ghidra.app.decompiler.DecompileResults; import ghidra.program.model.address.Address; import ghidra.program.model.listing.CodeUnit; import ghidra.program.model.listing.Function; import ghidra.program.model.listing.FunctionIterator; import ghidra.program.model.listing.InstructionIterator; import ghidra.program.model.listing.Program; import ghidra.program.model.listing.Variable; import ghidra.program.model.pcode.HighFunction; import ghidra.program.model.pcode.HighSymbol; import ghidra.program.model.pcode.HighVariable; import ghidra.program.model.pcode.LocalSymbolMap; import ghidra.program.model.pcode.PcodeOp; import ghidra.program.model.pcode.Varnode; import ghidra.program.model.symbol.Symbol; import ghidra.program.model.symbol.Reference; import ghidra.program.model.symbol.ReferenceIterator; import ghidra.util.task.ConsoleTaskMonitor; args = getScriptArgs() print(args) p = currentProgram print(p) filename = "/projects/zephyr/Ruturaj/ghidra_learning/" + p.getName() + ".txt" print(filename) #di = DecompInterface() #print(di)