Table of Contents
IronForgeCyber
Courses
Resources
Blog
Log In


IronForgeCyber

AboutPrivacyTerms

© 2026 IronForgeCyber. All rights reserved.

  1. courses
  2. re-static-analysis
  3. tools
9 min read

Orienting Ghidra

The last lesson ended with a listing of what Ghidra makes of a small program. This lesson is about getting to that listing yourself. We install Ghidra, load a binary, and walk through the handful of windows you will spend the course in. Then we make our first corrections to the decompiler's guess, which is where the real work of reverse engineering starts.

Ghidra is a large program with a lot of buttons, and most of them can be ignored. The goal here is to know which few matter.

We use the same chall as the last lesson, the PIN check with the scramble helper. If you do not have it, grab the download from that page. Using a program whose source we have already read means we can check everything Ghidra tells us.

Installing Ghidra

Ghidra is not in most package managers, and the cleanest way to set it up on any distribution is to download a release and add it to your path by hand.

  1. Install Java. Ghidra 12 needs JDK 25. Install it with your system's package manager: openjdk-25-jdk on Ubuntu and Debian, java-25-openjdk-devel on Fedora, and the equivalent elsewhere. Older Ghidra releases need older JDKs, and each release lists its requirement.

  2. Download and extract Ghidra. Take the latest release from the Ghidra releases page and extract it wherever you keep tools:

    $ unzip ghidra_<version>_PUBLIC.zip -d ~/tools
  3. Add it to your path. The launcher is ghidraRun, inside the extracted folder. Symlink it into ~/.local/bin so you do not have to navigate there every time:

    $ ln -s ~/tools/ghidra_<version>_PUBLIC/ghidraRun ~/.local/bin/ghidraRun

Make sure ~/.local/bin is on your PATH. Most shells add it automatically. If yours does not, add export PATH="$HOME/.local/bin:$PATH" to your shell profile. After that, running ghidraRun from anywhere starts Ghidra.

Updates are manual
A Ghidra installed this way does not update itself. To upgrade, download the new release, extract it next to the old one, and point the symlink at it.

Projects and Importing

Ghidra keeps its work in projects. A project is a folder holding every binary you have imported, along with the names, types and comments you have added to each. The first time you start Ghidra, create one with File > New Project, choose Non-Shared Project, and give it a name and a location.

The window you are looking at is the Project Window. It lists the project's binaries, and the row of icons under Tool Chest holds Ghidra's tools. The green dragon is the CodeBrowser, the only one this course uses.

ghidra-project.webp

One project is enough to start
For CTF work, where each binary stands alone, keeping everything in a single project is fine and saves setup. Separate projects earn their keep when binaries belong together, such as a program and the libraries it ships with.

To add a binary, press I or use File > Import File, and pick chall. Ghidra inspects the file and proposes how to load it:

ghidra-import-dialog.webp

It has worked out the same things file told us in the first lesson. The format is ELF, and the language x86:LE:64:default:gcc means x86, little-endian, 64-bit, built by GCC. For ordinary binaries these guesses are right, so click OK. Ghidra then shows a summary of what it loaded, which you can close.

Analysis

Double-click chall in the project window to open it in the CodeBrowser. Ghidra notices the binary is new and offers to analyze it. Say yes, and it shows a list of analyzers:

ghidra-analysis-options.webp

Analysis is where Ghidra does its own static analysis before you start yours. It finds where functions begin and end, follows calls and jumps, marks strings, and matches known library functions. Everything you see afterwards is built on this pass.

The defaults are good, so click Analyze. For a program this small it finishes at once. A large binary can take minutes, with progress shown in the bottom-right corner, and it is worth waiting for it to finish before you trust what is on screen.

The CodeBrowser

This is the window you will work in:

ghidra-codebrowser.webp

It is busy, but only three parts need your attention at first.

The Listing

The large pane in the middle is the Listing: the disassembly of the whole binary, top to bottom. Each line has an address, the raw bytes, and the instruction. It is the same information objdump gave us, with extras. Ghidra draws a banner above each function, replaces stack offsets with names like local_c, and notes what else refers to each address under XREF.

The Listing is the ground truth. When the decompiler shows something you do not believe, this is where you check it.

The Decompiler

The pane on the right is the Decompiler. It shows C for whichever function the cursor is in, and the two panes stay in sync: click a line of C and the Listing highlights the instructions it came from, and the other way around. In the screenshot it shows main, and the code matches the listing from the last lesson, undefined4 local_c and all.

You will read here most of the time. Double-click a function name in the C, such as scramble, to jump into that function. Alt+Left takes you back.

The Symbol Tree

On the left, the Symbol Tree lists every name Ghidra knows. Imports holds the library functions the program calls, which for chall are printf, puts and scanf. Functions holds the functions inside the binary. Open it and you will find main and scramble, surrounded by names like _start and frame_dummy. Those are the startup functions the linker added in the last lesson, and you can ignore them.

Double-click any name to jump to it. In a binary with thousands of functions, type in the Filter box at the bottom to narrow the list.

Everything Else

The remaining panes can wait. The Program Trees pane lists the file's sections, the Data Type Manager holds type definitions that the Data & Types lesson puts to use, and the Console prints script output. Two windows that are not open by default are worth knowing about, both under the Window menu:

  • Function Graph draws the current function as boxes of code joined by arrows, one arrow per jump. It makes branches and loops visible at a glance, and Control Flow relies on it.
  • Defined Strings lists every string Ghidra found, like strings with the addresses attached. Strings & Constants starts there.

To go straight to an address or a name, press G and type it.

Improving the Decompilation

A decompiler's first output is a draft. Ghidra expects you to correct it, and it carries each correction through the rest of the program. That is the difference between reading a binary in Ghidra and reading it in objdump: your understanding gets saved into the tool as you go.

Renaming

We know from the source that local_c holds the PIN. Even without the source we could tell: it is the variable scanf fills in right after the program prints PIN: . Click local_c in the Decompiler and press L:

ghidra-rename.webp

Type pin and press Enter. Every use of the variable changes, in the Decompiler and in the Listing.

L renames whatever is under the cursor, including functions. In a stripped binary, turning FUN_00400486 into scramble once you have worked out what it does is the most useful thing you can do, because the new name shows up in every function that calls it.

Retyping

Ghidra typed the variable as undefined4: four bytes, meaning unknown. We can do better. It is passed to scanf with %d, so it is an int. Click the variable and press Ctrl+L, then type int. The Decompiler now reads:

ghidra-renamed.webp

This one was cosmetic. Types matter far more once pointers and structs are involved, where the right type turns a page of pointer arithmetic into named fields. To change a function's return type and parameters in one go, click its name and press F.

Commenting

Press ; on any line to attach a comment. Use it for conclusions that a name cannot hold, such as "only the low byte is compared" on the call to scramble. Comments are saved with the project, so they are still there next week.

None of this changes the binary. Names, types and comments live in the Ghidra project. They are your notes, kept where you need them.

What Ghidra Can't Do

Ghidra is a static tool. It never runs the program, so it cannot tell you what value a variable holds at some moment during a run. That question belongs to a debugger, and the GDB Guide covers one.

Its output also has habits worth learning early:

  • Local variables are named after their stack position. local_c sits 0xc bytes below the return address, and the Listing shows it as Stack[-0xc]. Two variables with nearby numbers are neighbors on the stack.
  • Arrays and structs on the stack often come out as a run of separate variables, local_28, local_20, local_18 and so on, because nothing in the binary says they belong together. Recognizing that pattern and rebuilding the array is part of the job.
  • Types are guesses, as we saw with undefined4, and a wrong guess can make correct code look strange. In the last lesson Ghidra decided scramble takes a byte where the source said int.

When the Decompiler and the Listing disagree, believe the Listing.

Lighter Tools

Ghidra is not always the right tool. Starting it, importing and analyzing takes a minute or two, and some questions do not need it.

  • For what kind of file this is and what text it holds, file and strings answer in a second.
  • For one small function, objdump -d is often enough. The first lesson solved a whole challenge with it.
  • For moving around a binary from the terminal, renaming and following references without a GUI, there is radare2. The Radare2 Guide on this site covers it.

A rule of thumb: start with the quick tools, and move to Ghidra once you find yourself tracking more than one function in your head.

Summary

  • Ghidra keeps binaries and your notes on them in a project. Import a binary with I, open it in the CodeBrowser, and let the default analysis run.
  • Three panes matter at first: the Listing (disassembly, the ground truth), the Decompiler (C, a draft), and the Symbol Tree (every name, for getting around).
  • Improve the draft as you read: L renames, Ctrl+L retypes, ; comments, and G jumps to an address or name.
  • Ghidra cannot run the program, names locals after stack offsets, and guesses at types. Check the Listing when the C looks wrong.

With the tools in place, the next section starts on the main skill of the course. Control Flow covers reading branches and loops in decompiled code.