sample.bin
hex dump · disassembly
00000000 4d 5a 90 00 03 00 00 00 04 00 00 00 ff ff 00 00 |MZ..............| 00000010 b8 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 |........@.......| sub_401000: push rbp mov rbp, rsp call sub_401230
tool
Ghidra: reverse engineering without the source code
Disassembles and decompiles programs so analysts can study how they work.
Curated by Signal · 10/5/2026
What it is
Ghidra disassembles and decompiles compiled programs, turning machine code back into something closer to readable source. It is mostly used through its GUI, but it also has a headless mode for scripting and automation. Use it only on binaries you own or are authorized to analyze.
Starting Ghidra
# Launch the GUI
ghidraRun
# Launch headless mode (no GUI, for scripting)
analyzeHeadless <project-dir> <project-name> -import <binary-path>
Headless analysis basics
# Create a new project and analyze a binary
analyzeHeadless /home/user/ghidra_projects MyProject -import ./sample.exe
# Analyze without running default analyzers (faster, less complete)
analyzeHeadless /home/user/ghidra_projects MyProject -import ./sample.exe -noanalysis
# Re-analyze an already-imported binary already in a project
analyzeHeadless /home/user/ghidra_projects MyProject -process sample.exe
Running a script in headless mode
# Run a built-in or custom script after import
analyzeHeadless /home/user/ghidra_projects MyProject -import ./sample.exe -postScript MyScript.java
# Specify a custom script directory
analyzeHeadless /home/user/ghidra_projects MyProject -import ./sample.exe -scriptPath /home/user/scripts -postScript MyScript.java
GUI workflow (keyboard shortcuts in the Code Browser)
G Go to address or symbol
L Rename the selected label or variable
Ctrl+Shift+E Edit function signature
; Add a comment at the current line
Ctrl+Shift+F Find references to the selected item (Find Uses)
Ctrl+Shift+G Find text across the whole program
Tab Switch between Listing and Decompiler views
Useful GUI windows (Window menu)
Symbol Tree browse functions, labels, and data
Data Type Manager inspect and import structure definitions
Defined Strings list all strings found in the binary
Function Graph visual control-flow graph of a function
Bytes raw hex view of the binary
Common analysis tasks
# Find the program's entry point
# Window > Symbol Tree > search "entry"
# List all imported functions (useful to spot API calls, e.g. network or file access)
# Window > Symbol Tree > Imports
# Search for a specific string
# Search > For Strings... then filter by text
# Jump from a string reference to where it is used
# Right-click string > References > Show References to Address
Scripting (Java or Python via Jython)
# Example Ghidra script skeleton (Java)
import ghidra.app.script.GhidraScript;
public class ListFunctions extends GhidraScript {
public void run() throws Exception {
for (var f : currentProgram.getFunctionManager().getFunctions(true)) {
println(f.getName() + " @ " + f.getEntryPoint());
}
}
}
# Run that script from the Script Manager in the GUI,
# or headlessly with -postScript ListFunctions.java
Exporting results
# Export the decompiled C-like output for a function:
# right-click function in Decompiler > Export > To File
# Export headless with a script that writes decompiled output,
# then run it with -postScript
analyzeHeadless /home/user/ghidra_projects MyProject -import ./sample.exe -postScript ExportDecompiled.java
Typical workflow
# 1. Import the binary and let default analysis run
analyzeHeadless /home/user/ghidra_projects MyProject -import ./sample.exe
# 2. Open in the GUI, check Defined Strings for clues about behavior
# 3. Check Symbol Tree > Imports for suspicious API usage
# (e.g. network, registry, or process-injection calls)
# 4. Use the Decompiler view on the entry point and work outward
# 5. Rename variables and functions as you understand them (L key)
Curated summary. The original work belongs to its authors.
#reverse-engineering#malware
Related reading
~/signal
terminal
$ nmap -sV -p 22,80,443 scanme.nmap.org Starting Nmap ( https://nmap.org ) PORT STATE SERVICE 22/tcp open ssh 80/tcp open http 443/tcp closed https
Nmap: network discovery and port scanning
capture.pcap
packet capture
No. Source Destination Proto Info 1 192.0.2.10 198.51.100.7 DNS Standard query A example.com 2 198.51.100.7 192.0.2.10 DNS Standard query response 3 192.0.2.10 203.0.113.5 TCP 52144 → 443 [SYN] 4 203.0.113.5 192.0.2.10 TCP 443 → 52144 [SYN, ACK] 5 192.0.2.10 203.0.113.5 TLS Client Hello
Wireshark: see what is on the wire
illustration✦✦
unravel