/firmware-reverse-engineering:ghidra-refrom firmware-reverse-engineering
Expert-level Ghidra reverse engineering for stripped firmware binaries. Covers function discovery, type recovery, cryptographic routine identification, authentication logic detection, and vulnerability hunting via Python scripting.
Ships in firmware-reverse-engineering. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Expert-level Ghidra workflows for analyzing stripped firmware binaries, with automation via Python scripting.
Use this skill for:
Prerequisites:
# @runtime Jython; they do not run in a standalone Python interpreter.Integration:
The four bundled scripts produce review candidates, not confirmed vulnerabilities. They inspect recovered instructions and resolved references; indirect calls, inlined code and unrecovered data may be missed. They preserve existing names and comments; candidate renames apply only to default symbols. Save the project before running analysis scripts.
Set these paths for the headless examples (replace with absolute local paths):
export GHIDRA_INSTALL_DIR=/path/to/ghidra_12.1.3_PUBLIC
export GHIDRA_SCRIPT_DIR=/path/to/ghidra-re/scripts
mkdir -p /projects
# Create project
"$GHIDRA_INSTALL_DIR/ghidraRun"
# Or headless for automation
"$GHIDRA_INSTALL_DIR/support/analyzeHeadless" /projects FirmwareProject -scriptPath "$GHIDRA_SCRIPT_DIR" -import /path/to/binary.elf
# Batch import
for bin in extracted/bin/*; do
"$GHIDRA_INSTALL_DIR/support/analyzeHeadless" /projects Firmware -scriptPath "$GHIDRA_SCRIPT_DIR" -import "$bin"
done
Automated approach:
# Run analysis scripts in sequence
"$GHIDRA_INSTALL_DIR/support/analyzeHeadless" /projects Firmware -scriptPath "$GHIDRA_SCRIPT_DIR" -process binary.elf \
-postScript find_crypto.py \
-postScript find_auth_functions.py \
-postScript find_buffer_overflows.py
Manual approach:
Run Auto-Analysis (Analysis → Auto Analyze)
Find Functions - Stripped binaries need manual function discovery
references/stripped-analysis.md)Initial Renaming
scripts/auto_rename.py for heuristic-based namingChoose analysis path based on goal:
Authentication Analysis → Use scripts/find_auth_functions.py
Crypto Analysis → Use scripts/find_crypto.py
Vulnerability Hunting → Use scripts/find_buffer_overflows.py
Network Protocol Analysis
For each interesting function:
# @runtime Jython
# Decompile and enhance
func = getFunctionAt(toAddr("0x00401000"))
# Set signature (if known)
sig = "int verify_password(char *user_input, char *stored_hash)"
from ghidra.app.cmd.function import ApplyFunctionSignatureCmd
from ghidra.app.util.parser import FunctionSignatureParser
from ghidra.program.model.symbol import SourceType
from ghidra.program.model.listing import Function, ParameterImpl
from ghidra.program.model.data import *
assert func is not None, "Select a valid function entry"
definition = FunctionSignatureParser(currentProgram.getDataTypeManager(), None).parse(func.getSignature(), sig)
assert ApplyFunctionSignatureCmd(func.getEntryPoint(), definition, SourceType.USER_DEFINED).applyTo(currentProgram)
# Define structures
dtm = currentProgram.getDataTypeManager()
struct = StructureDataType("auth_request", 0)
struct.add(DWordDataType(), "session_id", None)
struct.add(PointerDataType(CharDataType()), "username", None)
struct.add(PointerDataType(CharDataType()), "password", None)
dtm.addDataType(struct, DataTypeConflictHandler.REPLACE_HANDLER)
# Apply to function parameters
param = ParameterImpl("request", PointerDataType(struct), currentProgram)
func.replaceParameters(Function.FunctionUpdateType.DYNAMIC_STORAGE_ALL_PARAMS, True, SourceType.USER_DEFINED, param)
Buffer Overflow Detection:
# @runtime Jython
# Manual verification after script identifies candidates
# 1. Check buffer size
# 2. Trace input length
# 3. Verify bounds checking (or lack thereof)
# 4. Confirm exploitability
# Example: strcpy without length check
# Decompiler shows:
# strcpy(local_buffer, user_input);
# Check local_buffer size in stack frame
# Verify attacker-controlled length exceeds the destination and reaches this call.
# A write beyond the buffer is a vulnerability; code execution needs separate evidence.
Format String Bugs:
# @runtime Jython
# Find printf(user_controlled_string)
# Script pattern:
if "printf" in called_functions:
# Check if format arg is from user input
# A variable format is not necessarily attacker-controlled; trace its origin.
pass # Manual review, not a complete detector
Command Injection:
# @runtime Jython
# Find system/popen with user data
# Pattern: system(cmd) where cmd contains user input
# Look for string concatenation before system() call
Automated structure inference:
# @runtime Jython
# See references/stripped-analysis.md for a sketch, not a complete inference engine
# Analyzes memory access patterns:
# - *(ptr + 0) → field at offset 0
# - *(ptr + 4) → field at offset 4
# Define the structure manually after verifying offsets and field sizes
Manual structure definition:
# @runtime Jython
# From decompiler output showing member accesses
struct = StructureDataType("device_state", 0)
struct.add(DWordDataType(), "magic", None) # offset 0
struct.add(ByteDataType(), "enabled", None) # offset 4
struct.add(ArrayDataType(CharDataType(), 32, 1), "name", None) # offset 5
# Apply and watch decompiler improve
Find callers:
Right-click function → References → Show References to
Find call sites:
# @runtime Jython
func = getFunctionAt(currentAddress)
refs = getReferencesTo(func.getEntryPoint())
for ref in refs:
if ref.getReferenceType().isCall():
caller = getFunctionContaining(ref.getFromAddress())
if caller:
print("Called from: {}".format(caller.getName()))
Trace data flow:
# @runtime Jython
# From source to sink
# 1. Find all calls to source (e.g., recv)
# 2. Track where data goes
# 3. Check if reaches sink (e.g., system)
# See scripts/find_buffer_overflows.py for manual data-flow verification
All scripts in scripts/ run in Ghidra with the Jython runtime above:
Finds candidate constant prefixes and their direct references; absence is not evidence that crypto is absent:
Usage:
"$GHIDRA_INSTALL_DIR/support/analyzeHeadless" /projects Project -scriptPath "$GHIDRA_SCRIPT_DIR" -process binary -postScript find_crypto.py
Discovers authentication logic via heuristics:
Usage:
"$GHIDRA_INSTALL_DIR/support/analyzeHeadless" /projects Project -scriptPath "$GHIDRA_SCRIPT_DIR" -process binary -postScript find_auth_functions.py
Detects potential buffer overflow vulnerabilities:
Usage:
"$GHIDRA_INSTALL_DIR/support/analyzeHeadless" /projects Project -scriptPath "$GHIDRA_SCRIPT_DIR" -process binary -postScript find_buffer_overflows.py
# @runtime Jython
# my_analysis.py
# Description: Custom analysis for firmware
from ghidra.program.model.symbol import SourceType
currentProgram = getCurrentProgram()
listing = currentProgram.getListing()
fm = currentProgram.getFunctionManager()
mem = currentProgram.getMemory()
# Your analysis logic
for func in fm.getFunctions(True):
# Process each function
pass
# @runtime Jython
# Navigate
addr = toAddr("0x00400000")
func = getFunctionAt(addr)
func = getFunctionContaining(addr)
# Modify
func.setName("new_name", SourceType.USER_DEFINED)
createFunction(addr, "function_name")
createLabel(addr, "label_name", True)
# Data types
from ghidra.program.model.data import *
DWordDataType()
PointerDataType(CharDataType())
StructureDataType("struct_name", 0)
# Instructions
instr = listing.getInstructionAt(addr)
instr.getMnemonicString() # "bl", "mov", etc.
instr.getReferencesFrom()
# Decompiler
from ghidra.app.decompiler import DecompInterface
decompiler = DecompInterface()
decompiler.openProgram(currentProgram)
results = decompiler.decompileFunction(func, 30, monitor)
high_func = results.getHighFunction()
Method 1: Prologue Scanning
# @runtime Jython
# ARM: push {r11, lr} = 0xe92d4800
# MIPS: addiu sp,sp,-XX
# x86: push ebp; mov ebp,esp
# Search for patterns in executable memory
# See references/stripped-analysis.md for complete implementation
Method 2: Cross-Reference Analysis
# @runtime Jython
# Find all call instructions
# Target addresses likely are function starts
# See references/stripped-analysis.md
Method 3: String References
# @runtime Jython
# Functions that reference strings
# Use string content to infer function purpose
# See references/stripped-analysis.md
# @runtime Jython
# Pattern-based naming
def infer_name(func):
strings = get_function_strings(func)
called = get_called_functions(func)
# Authentication
if any("password" in s.lower() for s in strings):
if "strcmp" in called:
return "check_password"
# Network
if "socket" in called or "recv" in called:
return "network_handler"
# Crypto
if "aes" in "".join(strings).lower():
return "crypto_aes"
return None
Workflow:
Example:
# @runtime Jython
# In Ghidra: Find auth function
auth_func = getFunctionAt(toAddr("0x00401234"))
# Note address: 0x00401234. For PIE/shared objects, translate using the actual
# runtime load bias; do not use a static address unchanged.
# In QEMU with GDB:
# gdb-multiarch binary
# (gdb) target remote :1234
# (gdb) break *0x00401234
# (gdb) continue
# ... trigger auth ...
# (gdb) info registers # See actual values
# Return to Ghidra with understanding of runtime behavior
G Go to address
L Label/rename
; EOL comment
Ctrl-; Pre-comment
D Disassemble
P Create function
X Show references to
Ctrl-Shift-E Edit function signature
T Set data type
Decompiler fails:
Auto-analysis misses functions:
scripts/ folderreferences/stripped-analysis.md)Poor decompilation quality:
references/stripped-analysis.md - Complete techniques for analyzing stripped binaries, type recovery, function discoveryreferences/workflow.md - Expert workflow patterns, scripting examples, integration tips# Headless analysis with scripts
"$GHIDRA_INSTALL_DIR/support/analyzeHeadless" /projects Firmware -scriptPath "$GHIDRA_SCRIPT_DIR" -import binary.elf \
-postScript find_crypto.py -postScript find_auth_functions.py
# Import without auto-analysis (manual control)
"$GHIDRA_INSTALL_DIR/support/analyzeHeadless" /projects Firmware -scriptPath "$GHIDRA_SCRIPT_DIR" -import binary.elf -noanalysis
# Export analysis results (first save the JSON example in references/workflow.md
# as export_results.py in GHIDRA_SCRIPT_DIR; it is not a bundled script)
"$GHIDRA_INSTALL_DIR/support/analyzeHeadless" /projects Firmware -scriptPath "$GHIDRA_SCRIPT_DIR" -process binary.elf \
-postScript export_results.py
# @runtime Jython
# Essential Ghidra Python APIs
currentProgram # Program object
getFunctionAt(addr) # Get function
createFunction(addr, name) # Create function
toAddr("0x00400000") # String to address
listing.getInstructions(body, True) # Iterate instructions
getReferencesTo(addr) # Get xrefs to
func.setName(name, SourceType.USER_DEFINED) # Rename function
This skill assumes expert RE knowledge and focuses on firmware-specific analysis patterns. For general Ghidra basics, consult official documentation.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub orbitcurve/firmware-reverse-engineering --plugin firmware-reverse-engineering5 skills in this plugin
/firmware-emulationComprehensive firmware dynamic analysis and emulation using QEMU (user-mode and system-mode), GDB debugging, network traffic analysis, and automated tools (Firmadyne/FirmAE). Use when the agent needs to run extracted firmware for dynamic analysis. Covers: (1) Deciding between automated vs manual emulation approaches, (2) QEMU user-mode emulation for individual binaries, (3) QEMU system-mode emulation for full firmware stack, (4) Advanced GDB debugging with gdb-multiarch, (5) Network traffic capture and protocol analysis, (6) MITM attacks and traffic manipulation, (7) Automated emulation with Firmadyne/FirmAE, (8) Troubleshooting boot failures and network issues. Requires extracted firmware (use firmware-extraction skill first). Complements firmware-static-analysis skill with runtime behavior observation./firmware-extractionExtract firmware images and embedded filesystems using unblob first, summarize its JSON report, and investigate unresolved regions with Binwalk or filesystem-specific tools. Use for device dumps and manufacturer update images, including nested, unsupported, encrypted, or damaged formats. For individual ELF analysis use firmware-static-analysis; for execution use firmware-emulation./firmware-security-reportsEvidence-based security report generation for firmware assessments. Use when the agent needs to create technical security reports from firmware analysis. Covers: (1) Full penetration test reports with executive summaries and technical details, (2) Individual vulnerability findings with CVSS 3.1 scoring, (3) Working notes for documentation during assessment, (4) Integration with firmware analysis skills (extraction, static analysis, Ghidra RE, emulation). Outputs to markdown and PDF formats. Technical audience only. Includes templates for findings, PoC code, remediation guidance, and evidence documentation./firmware-static-analysisSystematic static analysis of ELF firmware binaries using command-line tools (file, strings, readelf, objdump, xxd). Use when the agent needs to perform initial reconnaissance on firmware/embedded binaries before reverse engineering, specifically for (1) Identifying architecture and binary characteristics, (2) Extracting metadata, strings, and imports, (3) Analyzing symbols, sections, and entry points, (4) Understanding binary structure and dependencies, (5) Generating structured analysis reports. Covers ARM, MIPS, x86, RISC-V, PowerPC architectures. Does NOT handle firmware extraction/unpacking (use separate skill for that).Other plugins' skills for the same job