TransWikia.com

How to import files and analyze it in Ghidra using a python script?

Reverse Engineering Asked by Sajjad Zulphekari on July 21, 2021

I want to write a script which imports an exe file, analyzes it, extracts some features and saves it using python.

The part which I am not able to understand is, how to import a file from the script itself. I do not want to use the askFile function and i do not want to use the headleassAnalyzer.

Are there any functions which let me do this from the script itself?

One Answer

In order to run a script in Ghidra you can run the following:

analyzeHeadless <project_location> <project_name> -import <path/to/file> -scriptPath <path/to/scripts> -preScript <preScript_name> <preScript_params> -postScript <postScript_name> <postScript_params>

analyzeHeadless is the Ghidra GUI-less executable script.

You can specify postScript, preScript, or both of them.

From the script itself, you can reference your program with currentProgram variable.

Answered by macro_controller on July 21, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP