Ghidra Quick Reference
Keyboard shortcuts, analysis workflows, cross-references, crypto constant identification, and Ghidra Python scripting for malware analysis.
⌨️ Keyboard Shortcuts
🔬 Malware Analysis Workflow in Ghidra
decrypt_config, send_beacon, check_vm. Add comments with ;. Good naming transforms unreadable decompiler output. Work from known points (string references, imports) outward.🔗 Cross-Reference Workflows
Cross-references (xrefs) are the most powerful navigation tool in Ghidra. Mastering xrefs means being able to trace any value from its origin to every place it's used.
Find all call sites for a suspicious import
2. Filter by namespace:
EXTERNAL3. Find
VirtualAllocEx (or any target import)4. Right-click → References → Show References to Symbol
5. Every row = one call site. Double-click to jump there.
6. For each call site: examine what arguments are passed (address, size, protection flags)
Trace a decrypted string back to its source
2. Double-click → jumps to string location in memory
3. Press Ctrl+Shift+F → shows all references to this address
4. Follow the reference to the function that uses this string
5. Look at what calls THAT function (xref the function) — reveals execution chain
Find all functions that call a specific function
send_beacon)2. Right-click function name → References → Show References to Function
3. All callers listed. This shows you the call graph without the graph view.
4. For malware: trace backwards from network functions to find what data is being sent
Function call graph
Ensure "Show Calls Into" and "Show Calls From" are ticked
Use to understand the overall code structure — identify clusters of related functions
Tip: right-click any node → "Set Function as Root" to explore from that function's perspective
Data type xrefs — finding struct usage
2. Find or create a struct (e.g.,
HTTP_REQUEST)3. Right-click struct → Find Uses
4. All variables and functions using that struct type are listed
5. Apply imported Windows structs (from Built-In types) to decompiler output for readable code
🔐 Crypto Constant Identification
Cryptographic algorithms can be identified by their magic constants. Search for these values in Ghidra (Search → Memory, hex value) to locate crypto code in a malware sample.
for(i=0;i<256;i++) S[i]=i; followed by a swap loop. RC4 is symmetric — same function encrypts and decrypts.0x63 0x7C 0x77 0x7B 0xF2 0x6B 0x6F 0xC5Hex search:
63 7C 77 7B F2 6B 6F C50x67452301, 0xEFCDAB89, 0x98BADCFE, 0x1032547601 23 45 67 (little-endian). Often used for keying, fingerprinting, or integrity checks in malware.0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F00xC3D2E1F0. SHA-1 used in certificate pinning, HMAC-based C2 authentication.for(i=0;i<len;i++) buf[i] ^= key;Multi-byte key XOR:
buf[i] ^= key[i % keylen];In Ghidra decompiler: XOR operation inside loop over buffer. Single-byte key means 256 possible values — brute-force in Python with
for k in range(256): print(bytes([b^k for b in data]))0xEDB88320 (reflected) or 0x04C11DB7 (normal)Finding constants with CAPA (automation)
🐍 Ghidra Scripting (Python / Java)
Ghidra supports Python 2.7 (Jython) and Java scripts via Window → Script Manager. Scripts automate repetitive analysis tasks — renaming functions, finding patterns, extracting data.
Running a script
Window → Script Manager → New Script (Python) → write code → Run (play button). Script runs in the context of the currently open program.