surmenage · · budding · ghidra · reverse-engineering · tools · security
ghidra in one hour: from a stripped binary to code you can read
Ghidra is the NSA’s open-source reverse engineering framework, and the current release is 12.2, published on 22 October 2026. It disassembles, decompiles, graphs and scripts compiled code for a long list of processors. The first hour is mostly about learning which three or four windows matter and the handful of keys that turn raw decompiler output into something you can read.
This guide assumes a small program you compiled yourself or a deliberately built practice binary. That is the right size for a first session. Large, unfamiliar software mostly teaches frustration.
Setup that will not eat your hour
Ghidra 12.2 needs a 64-bit JDK 25. The official Getting Started guide names Adoptium Temurin and Amazon Corretto as free LTS builds, and it lists Python 3 (3.9 to 3.15) as a requirement for some features. There is no installer: you unzip the release and run ghidraRun. Never unzip it over an older install.
Two platform details are worth knowing. The official release ships prebuilt native components, the decompiler among them, only for Windows x86-64, Windows ARM64 and Linux x86-64. On macOS or Linux ARM you build them once with Gradle (gradle buildNatives in support/gradle), and without them the decompiler window will not work. On a Mac, the guide also says to strip the quarantine attribute from the zip before extracting: xattr -d com.apple.quarantine <file>.zip.
Check the SHA-256 on the release page against your download. For a tool whose whole job is handling untrusted binaries, it is a cheap habit.
Project, import, CodeBrowser
Ghidra works inside projects. Create one with File, New Project, Non-Shared Project, then drag your binary into the project window or use File, Import File (the I key). The import dialog detects the format (ELF, PE, Mach-O) and the processor. Accept the detection unless you know better; a wrong language guess is the most common reason for garbage output.
Double-click the imported program and it opens in the CodeBrowser, the main working tool. When it asks whether to analyze, say yes. The window arrangement to aim for:
- Listing in the centre: the disassembly, with addresses, bytes, mnemonics and labels.
- Decompiler on the right: C-like output for whichever function your cursor is in.
- Symbol Tree on the left: functions, imports, labels.
- Program Tree and Data Type Manager are there if you want them, and can be closed for now.
If the decompiler is not showing, use Window, Decompile.
What auto-analysis actually does
Analysis is a chain of analyzers. According to the help pages, a typical chain goes: the function analyzer finds calls and creates functions, the stack analyzer builds stack frames, the operand analyzer looks for scalars that are really addresses, and the data reference analyzer turns pointers into strings and data. Each change can trigger further analyzers, and each has a priority.
In the options dialog, analyzers that differ from their default setting are shown in a yellowish colour. For a first run, leave the defaults alone. Revisit the list only when something is missing, and remember you can re-run it later (Analysis, Auto Analyze) or run individual one-shot analyzers from the Analysis menu. It matters a little more for stripped binaries, where there are no function names to fall back on and everything begins as FUN_ followed by an address.
Reading the decompiler
The decompiler follows the cursor. Click a function in the Symbol Tree and the right pane re-decompiles it. Clicking a token in the decompiler highlights the matching instruction in the Listing, and vice versa. The official help is blunt that the mapping is not one-to-one: the decompiler restructures code, so some instructions have no matching token and some tokens summarise several instructions. When a line of C looks wrong, trust the assembly.
The decompiler re-runs after every edit. It reads the labels, types and comments you add, which is why the annotation loop below works.
The annotation loop
The loop that turns output into source is small:
- Rename (
L) anything whose purpose you have worked out: variables, functions and globals. - Retype (
Ctrl+L) variables the decompiler typed aslongorundefined8when they are really pointers orchar *. - Comment (
;) the conclusions, so you do not have to rediscover them. - Look at the result. Better types often make a whole block collapse into a readable loop or a string comparison.
Change one thing at a time at first. The decompiler is re-deriving everything after each edit, and seeing what a retype does teaches you more than ten blind renames.
Cross-references and strings
Two questions answer most of what you will ask of a small program: where is this used, and what is it called with?
Strings first. Window, Defined Strings lists every string Ghidra recognised. A prompt such as “Enter passphrase:” or an error message is the best landmark in a program you have never seen. Double-click a string to jump to it in the Listing. Then press Ctrl+Shift+F (Show References To) on its label, or use the right-click References menu, and you get the list of instructions that read it. Follow one and you are inside the function that cares about that message.
Cross-references work the other way too. On a function, the same shortcut lists its callers; that is how you find out whether a helper is called from one place or twenty.
A tiny worked example
Imagine a practice program you compiled yourself: a toy “crackme” that prints a prompt, reads a line, compares it to a hardcoded passphrase and prints either Access granted or Wrong. Compile it for Linux with optimisation off, then strip it with strip so function names disappear. This is a teaching exercise on code you own; nothing here involves bypassing anyone’s protection.
Import and analyze. In Defined Strings you find three entries: the prompt, Access granted, and Wrong, plus the passphrase itself, since it is stored in plain text in the read-only data. Anyone who has done this once learns the lesson that most hardcoded secrets are visible to the first strings pass.
Jump to the Wrong string and press Ctrl+Shift+F. One reference, inside a function Ghidra calls FUN_00101189 (the address will differ). The decompiler shows roughly this shape, which I am reconstructing as an illustration rather than pasting from a real run:
undefined8 FUN_00101189(void)
{
int iVar1;
char local_58 [72];
puts(s_Enter_passphrase:_00102004);
fgets(local_58,0x40,stdin);
iVar1 = strcmp(local_58,s_hunter2_0010201a);
if (iVar1 == 0) {
puts(s_Access_granted_00102020);
}
else {
puts(s_Wrong_0010202f);
}
return 0;
}
Now apply the loop. Rename FUN_00101189 to main (L; in an ELF Ghidra often has already found it by following the entry point’s call to __libc_start_main). Rename local_58 to input, iVar1 to cmp_result. Retype nothing, because the types are already right. Add a comment on the strcmp call. The function now reads exactly like the source you would have written, and the passphrase is the string being compared: hunter2.
The point is the route: strings, then references to the string, then the function around it, then the comparison. The same route works on real programs, and on larger ones the comparison is simply buried deeper.
Tips that save time
- Use
Gto jump anywhere by address or symbol name instead of scrolling. - Make Defined Strings your starting point before you read a single instruction. Messages and prompts are the cheapest orientation you will get.
- Keep Listing and Decompiler side by side. When the C and the assembly disagree, you need both visible.
- Retype before you rename. Fixing a pointer type can rewrite a screenful of arithmetic into a clean array access, after which names are easier to choose.
- If a big function makes the decompiler sluggish while you edit, use the lock toggle in the decompiler toolbar to stop auto-refresh. The help warns the display will look stale until you refresh.
- Take a Snapshot of a decompiler window (the camera icon) to pin one function while you navigate elsewhere. It is how you read a caller and callee together.
- Comment every conclusion with
;the moment you reach it. An hour later you will not remember whyFUN_00101240is calledcheck_len. - Save often and keep one project per binary. Programs imported or modified in 12.2 may not open in earlier Ghidra versions, so do not mix versions on the same project.
Where to go next
Once a small program reads cleanly, the next step up is structures: build a struct in the Data Type Manager, apply it with T or via Retype, and watch pointer arithmetic turn into named fields. Ghidra 12.2 adds an interactive merger for structures, unions and enums, so when you realise two half-recovered structs are the same type you can combine them field by field instead of choosing one and retyping by hand.
After that, the Function Graph shows control flow as boxes and arrows, and scripting (Java or Python) lets you automate the repetitive parts. Neither is needed in the first hour.
Sources
- Ghidra 12.2 release (GitHub), 22 October 2026
- Ghidra 12.2 What’s New
- Getting Started with Ghidra (12.2)
- Ghidra help: Decompiler Window
- Ghidra help: Auto Analysis
- Source: RenameLocalAction (L key)
- Source: RetypeLocalAction (Ctrl+L)
- Ghidra cheat sheet, Portland State University (keys for references and Defined Strings)
- ghidra
- reverse-engineering
- tools
- security