Ghidra Comprehensive Cheatsheet
Installation Instructions
All Platforms (Java Required)
# Install Java Development Kit (JDK) 11 or later first
# Download Ghidra from https://ghidra-sre.org/
Download ZIP file
Extract to desired location
Run ghidraRun.bat
# Download ZIP file
unzip ghidra_* .zip
cd ghidra_*
./ghidraRun
# Using Homebrew
brew install --cask ghidra
# Manual Installation
# Extract ZIP and run ghidraRun
Create New Project
File → New Project
Select Shared or Non-Shared
Choose Project Directory
Import Files
File → Import File
Dragon drop files into project
Open Program
Double-click program in project window
File → Open from project window
Auto Analysis
Analysis → Auto Analyze
Configure analysis options
Click 'Analyze'
Function Analysis
Right-click in Function Window
Create Function
Edit Function
Data Type Analysis
Window → Data Type Manager
Import Additional Archives
Go To Address
G or Ctrl+G
Enter address
Find
Search → Program Text
Search → Memory
Search → Labels
Cross References
Right-click → References
Show References to Address
Show References from Address
View Decompiler
Window → Decompiler
Double-click function in listing
Rename Variables
Right-click variable
Rename Variable
Retype Variables
Right-click variable
Retype Variable
Function Graph
Window → Function Graph
Display → Layout Mode
Data Flow Analysis
Right-click → Data Flow
Forward Slice
Backward Slice
Control Flow Analysis
Right-click → Control Flow
Show Dominance Tree
Basic Script Structure
#@category Analysis
#@keybinding
#@menupath
#@toolbar
def run ():
program = getCurrentProgram ()
# Your code here
Memory Access
memory = currentProgram .getMemory ()
bytes = memory .getBytes (addr , length )
Symbol Table Access
symbolTable = currentProgram .getSymbolTable ()
symbols = symbolTable .getSymbols ("main" )
Basic Java Script
import ghidra .app .script .GhidraScript ;
public class MyScript extends GhidraScript {
@ Override
public void run () throws Exception {
// Your code here
}
}
Program API
Program program = getCurrentProgram ();
Memory memory = program .getMemory ();
Batch Analysis
#@category Analysis
def analyzeBatch ():
project = getProject ()
folder = project .getProjectData ()
# Process all programs
Custom Data Types
DataTypeManager dtm = getCurrentProgram ().getDataTypeManager ();
Structure struct = dtm .createStructure ("MyStruct" );
Patch Bytes
memory = currentProgram .getMemory ()
memory .setBytes (addr , bytes )
Add Comments
listing = currentProgram .getListing ()
listing .setComment (addr , PLATE_COMMENT , "My comment" )
Version Tracking
Tools → Version Tracking
Select two programs
Compare versions
Function Matching
Right-click function
Apply Function Hash
Match Functions
Import Types
File → Parse C Source
Select header files
Import into program
Create Structures
Window → Data Type Manager
Create Structure
Add fields
Stack Frame Analysis
Window → Function Stack Frame
Analyze local variables
Edit parameters
Call Graph
Window → Function Call Graph
Analyze function relationships
Folder Structure
Project/
├── Sources/
├── Libraries/
└── Analysis/
Naming Conventions
Functions: verb_noun
Variables: descriptive_name
Structures: Name_t
Initial Analysis
1. Import file
2. Run auto-analysis
3. Check entry points
4. Analyze strings
5. Check imports/exports
Deep Analysis
1. Identify key functions
2. Analyze data structures
3. Track cross-references
4. Document findings
Navigation
G - Go to address
Ctrl+F - Find
Ctrl+E - Edit instruction
Ctrl+L - Label
Views
Space - Toggle listing/decompiler
Ctrl+T - Text view
Ctrl+G - Graph view
Common Issues and Solutions
Memory Issues
Edit → Tool Options
Increase memory allocation
Adjust cache settings
Analysis Problems
Clear flow
Disassemble
Create function
Fix stack frame
Find Strings
def findStrings ():
memory = currentProgram .getMemory ()
listing = currentProgram .getListing ()
# Search for strings
Analyze Functions
def analyzeFunctions ():
fm = currentProgram .getFunctionManager ()
functions = fm .getFunctions (True )
# Process functions
Data Flow Analysis
public void analyzeDataFlow () {
DataFlow df = new DataFlow (currentProgram );
// Analyze data flow
}
Control Flow Analysis
public void analyzeControlFlow () {
ControlFlow cf = new ControlFlow (currentProgram );
// Analyze control flow
}