Ghidra allows you to analyze compiled programs without having their source code: you can examine their instructions, decompile functions, and explore their logic.
It becomes useful when an investigation leads you to a binary: a legacy executable, a native library, or a component whose behavior the documentation doesn’t explain. You have the program. What you need is a way to examine what it does.
What is Ghidra and what is it for?
Ghidra is a free and open-source tool for software reverse engineering, created and maintained by the NSA Research Directorate.
It brings together functions for inspecting machine instructions, reconstructing high-level code, visualizing a program’s structure, and automating analysis. It supports different processor architectures and executable formats, both in interactive sessions and in automated processes. You can consult its capabilities in the official repository.
For a developer, it helps to start with a concrete question. Where does this error originate? What happens before this function returns a result? What part of a native component processes a particular input?
Those questions narrow down the investigation. Understanding a complete unknown executable on the first try is a much larger task.
What is reverse engineering?
Reverse engineering consists of studying an existing system to understand how it’s built or how it works. In this case, you take parts of the compiled program and analyze their instructions to reconstruct an explanation of its behavior.
Ghidra provides tools for that process, also known as reverse engineering. A practical application is investigating software whose source code you don’t have available.
Can you recover source code with Ghidra?
Ghidra generates a C-like representation of compiled functions; you shouldn’t expect it to reconstruct the original project.
Its decompiler reconstructs expressions, variables, and function calls from the binary. The result changes as you provide information, such as names, data types, and function signatures. The assembly and decompiled code views are connected, which allows you to examine the instructions behind a high-level expression. This is how the official decompiler documentation describes it.
Treat that result as an analysis that you’re refining. A readable function is a good starting point, but you still need to review the inferred types and names. Understanding what it does requires checking the evidence behind that representation.
The distinction matters when reading a condition or a call: the code can seem so familiar that it leads you to trust an interpretation before you’ve verified it.
How do you install Ghidra?
Download the official distribution and follow the documentation for that version.
At the time of preparing this note, September 16, 2026, GitHub identifies Ghidra 12.1.3 as the latest published version. Download the distribution ZIP from Assets on the releases page. The source code files generated automatically are not the ready-to-run distribution.
For that version:
- Install the 64-bit JDK 21 indicated in its documentation.
- Extract the distribution in a new folder, without overwriting a previous installation.
- On Windows, run
ghidraRun.bat. On Linux or macOS, run./ghidraRunfrom the extracted folder, once your platform’s requirements are satisfied.
There is a difference between platforms: the guide for that version includes precompiled native components for Windows and Linux x86-64; for macOS and Linux ARM64 it indicates that you must compile them. Follow the specific instructions in the installation guide for the version. The debugger and PyGhidra features also require Python.
How do you use Ghidra to analyze a program?
Create a local project, import a small executable, and let Ghidra perform the initial analysis.
For the first exercise, use a small native program that you’ve compiled yourself. Keep its source code to contrast your interpretation with something you know.
- Select File → New Project, choose Non-Shared, and assign a name and location to the project.
- Select File → Import File… and import the executable. Check the format and language detected.
- Open the imported program in CodeBrowser and accept the analysis proposal.
- Select a function and examine its decompiled representation alongside the assembler.
The automatic analysis identifies functions and cross-references by following the code flow. If Ghidra doesn’t recognize the file and presents it as an unformatted binary, you’ll need to indicate the appropriate combination of language and compiler. For this first exercise, choose an executable it recognizes. The procedure is detailed in the official beginner’s guide.
Set yourself a concrete objective: find a branch that you recognize from your program and explain what controls it. Then, compare your explanation with the source code.
This way you get a first useful result without having to understand all the functions that the compiler included.
How do you automate analysis with Ghidra?
Ghidra allows you to run batch analysis without a graphical interface, in headless mode, and PyGhidra offers access via Python 3. Both options are documented among its execution modes.
Complete a manual investigation first. When you know what information you need to obtain repeatedly, you’ll have a clearer basis for deciding what to automate.
A good first session ends with a modest and verifiable result: you identified a function, understood a decision it makes, and contrasted that interpretation with the program. It’s a useful first step for working with software whose source code you can’t consult.