Skip to main content
Be Bitwise

Getting Started with Ghidra

Binary Analysis with Ghidra · Reverse Engineering track

7 min read

In this module

Ghidra: A World-Class Reverse Engineering Tool

Ghidra is an open-source software reverse engineering (SRE) framework developed by the NSA and dropped on the internet in 2019. Before it landed, the only tool with comparable decompilation was IDA Pro — thousands of dollars per licence. Ghidra broke that monopoly.

In Reverse Engineering Basics, you learned the fundamentals of reverse engineering: reading disassembly, following control flow, recovering data structures. This module teaches you to do all of that efficiently using Ghidra, the same tool professional vulnerability researchers reach for daily.

Installation and Setup

Ghidra is a Java application that runs on Windows, macOS, and Linux. Installation is straightforward:

  1. Install a JDK - Ghidra needs a 64-bit JDK, and the required version keeps moving: 11.0 and 11.1 ran on JDK 17, 11.2 raised it to JDK 21, and the development docs for 12.2 ask for JDK 25. The Getting Started guide inside your release states the exact version. OpenJDK works perfectly (substitute the version your release asks for):
bash
# Ubuntu/Debian
sudo apt install openjdk-21-jdk
# macOS with Homebrew
brew install openjdk@21
# Verify installation
java -version
  1. Download Ghidra - obtain the latest release from the official GitHub repository. Decompress the archive to your preferred location:
bash
# Extract Ghidra
# (substitute the version and date of the release you downloaded)
unzip ghidra_<version>_PUBLIC_<date>.zip -d /opt/
# Launch Ghidra
/opt/ghidra_<version>_PUBLIC/ghidraRun
  1. First launch - Ghidra opens a Project Manager window. Before analysing anything, you need to create a project to organise your work.

Creating Projects and Importing Binaries

Ghidra organises work into projects. Each project contains imported binaries, your analysis annotations, and any scripts you develop. Think of a project as a workspace for a particular research target.

Creating a project:

  • File -> New Project -> Non-Shared Project
  • Choose a directory and project name (e.g., "libpng-audit")
  • The project appears in the Project Manager

Importing a binary:

  • File -> Import File (or drag the binary into the project window)
  • Ghidra automatically detects the format (ELF, PE, Mach-O) and architecture (x86, ARM, MIPS)
  • Review the import summary - Ghidra shows the detected format, architecture, endianness, and address space
  • Click OK to import

After import, double-click the binary in the Project Manager to open it in the CodeBrowser - Ghidra's main analysis interface.

Auto-Analysis

When you first open a binary, Ghidra offers to run auto-analysis. Always accept this. Auto-analysis runs dozens of analyzers that:

  • Disassemble code - convert raw bytes into assembly instructions, following control flow to identify code regions
  • Identify functions - detect function prologues, epilogues, and boundaries
  • Build cross-references - track which instructions call, jump to, or reference each address
  • Detect strings - find ASCII and Unicode string constants in the binary
  • Resolve imports/exports - identify library function calls (printf, malloc, recv, etc.)
  • Apply type information - match known function signatures from the target platform

Auto-analysis takes anywhere from seconds (small binaries) to hours (large firmware images). You can watch progress in the bottom-right status bar. For most binaries under 10MB, analysis completes in under a minute.

Analysis Options

The analysis options dialogue lets you enable or disable specific analyzers. For vulnerability research, ensure these are enabled: Aggressive Instruction Finder (finds code in data sections), Decompiler Switch Analysis (resolves switch/case tables), and Stack Analysis (tracks stack variable usage). The defaults are good for most binaries, but for heavily obfuscated code, you may need to tune these settings.

The CodeBrowser is Ghidra's main workspace. Understanding its layout is essential for efficient analysis:

Listing View (centre) - the disassembly listing. Shows addresses, bytes, assembly instructions, and any comments or labels you have added. This is where you read the actual machine code.

Decompiler (right, if enabled via Window -> Decompiler) - Ghidra's crown jewel. It shows a C-like pseudo-code representation of the currently selected function. The decompiler output is not compilable C code, but it is dramatically easier to read than raw assembly. You will spend most of your analysis time here.

Symbol Tree (left) - a hierarchical view of all identified symbols: functions, labels, classes, namespaces, imports, and exports. Use this to navigate to specific functions by name.

Data Type Manager (lower left) - manages all known data types: structs, enums, typedefs, and function signatures. You can create custom types here to match the data structures you discover during analysis.

Program Trees (upper left) - shows the binary's section layout (.text, .data, .bss, .rodata). Useful for understanding the overall binary structure.

Function Graph (Window -> Function Graph) - visualises the control flow of the current function as a graph of basic blocks connected by edges. Essential for understanding complex branching logic.

Essential Keyboard Shortcuts

Efficiency in Ghidra comes from keyboard shortcuts. These are the ones you will use constantly:

  • G - Go to address. Type an address or symbol name to jump directly to it
  • L - add or edit a label in the Listing, or rename the function or variable under the cursor in the Decompiler. The single most important annotation action
  • Ctrl+L - retype the selected variable or parameter in the Decompiler
  • T - define data in the Listing (choose a data type for the bytes at the current address)
  • ; (semicolon) - add a comment at the current address
  • Search > For Strings... - find strings in the binary (no default shortcut; Window > Defined Strings lists the ones already found)
  • Ctrl+Shift+F - show references to the selected item (IDA users often rebind this to X)
  • Ctrl+E - open the decompiler for the current function (if not already visible)
  • D - disassemble bytes at the current address as code

Renaming is the most important habit in Ghidra. Press L the moment you understand what a function does. Rename local_18 to payload_length the moment you know what that slot holds. Every rename makes the surrounding code more legible, and legibility compounds — each clarified variable makes the next one easier to identify.

Your First Analysis

Let us walk through analysing a simple binary. Suppose you have a small C program compiled without symbols:

  1. Import and analyse - import the binary, accept auto-analysis defaults
  2. Find main - look in the Symbol Tree for entry or _start, which calls __libc_start_main. The first argument to __libc_start_main is the address of main
  3. Read the decompiler output - navigate to main and read the decompiled pseudo-code. Even without symbols, the decompiler shows the function's logic in C-like form
  4. Identify library calls - Ghidra resolves imported functions automatically. Calls to printf, malloc, recv, and other library functions appear by name
  5. Start renaming - as you understand each variable and function, rename them. The code becomes progressively more readable

Read, understand, rename, repeat. That loop is the whole job. With practice, complex programs yield in hours rather than days.

Decompiler vs. Disassembly

The decompiler is incredibly useful but not infallible. It can misidentify variable types, collapse important operations, or produce misleading output for unusual code patterns. Always cross-reference the decompiler output with the actual assembly in the Listing view when something looks suspicious. The assembly is ground truth; the decompiler is interpretation.