Ghidra Basics: Reverse Engineer Your First Binary (Legally)
You download a program. It runs. But what does it actually do? Reverse engineering answers that question — and Ghidra is the free tool that makes it possible for beginners.
Ghidra was built by the NSA and released to the public in 2019. It’s a full reverse engineering framework: it takes a compiled program (a binary) and shows you the assembly code and a readable decompiled version. Security researchers use it to analyze malware, find vulnerabilities, and understand software they didn’t write.
Install Ghidra
Ghidra runs on Windows, Linux and macOS. You need Java 17 or newer installed first.
# Linux: check Java, then download Ghidra from ghidra-sre.orgjava -versionunzip ghidra_11.x_PUBLIC_*.zipcd ghidra_11.x_PUBLIC./ghidraRun
The first launch asks you to create a project. Create a new non-shared project, then drag a binary into it — or use File → Import File.
Your First Binary: A Safe Target
Never reverse engineer random binaries from the internet — they could be live malware. Start with a program you compiled yourself. Write a tiny C program:
#include <stdio.h>int main() { int secret = 42; printf("The secret is %d\n", secret); return 0;}
Compile it with `gcc -o myprogram myprogram.c`, then import `myprogram` into Ghidra. Double-click it to open the CodeBrowser.
Reading the Decompiled Code
Ghidra shows you two main views:
- Listing window — the raw assembly instructions. Precise, but hard to read.
- Decompile window — Ghidra’s best guess at the original C code. This is where beginners should live.
Press F in the Decompile window to jump to a function, or click a function name in the Symbol Tree on the left. Find `main` and you’ll see something very close to the C code you wrote — including your secret number, 42, sitting in plain sight.
Three Things to Practice
- Find strings. Open Window → Defined Strings. Programs hide passwords, URLs and file paths as strings. A quick scan tells you a lot about what a binary does.
- Follow the calls. In the Decompile window, click any function name to jump to it. Trace what `main` calls and you’ll map the program’s behavior.
- Rename as you learn. Right-click a variable and rename it to something meaningful. Ghidra remembers your labels — this is how real analysts build understanding, one name at a time.
How This Helps Security
Reverse engineering is a defensive superpower. Malware analysts use Ghidra to understand what a suspicious file does before it runs. Vulnerability researchers use it to find bugs in software. And if you ever build software yourself, seeing your own binary decompiled teaches you exactly what attackers see — including hardcoded secrets you forgot to remove.
The Rules
- Only reverse engineer software you own, wrote yourself, or have written permission to analyze. Cracking commercial software or bypassing protections is illegal in most countries.
- Analyze suspicious files in a virtual machine, never on your main system.
- Ghidra is free and open source — the same tool the pros use costs you nothing.
Start with your own tiny program. In an hour, you’ll be reading binaries like a book.



Comments
Post a Comment