Reverse Engineering
Table of Contents
Analysing a compiled or obfuscated system to understand its structure and behaviour without access to source code. In security contexts the primary application is malware analysis — determining what a malicious binary does, how it communicates, and what indicators it leaves behind.
Related: Malware Analysis REMnux Ghidra Command and Control Detection
Static vs Dynamic Analysis
| Approach | Method | Risk | Best for |
|---|---|---|---|
| Static | Examine without executing | None | Structure, strings, imports |
| Dynamic | Execute in sandbox/debugger | Contained to sandbox | Actual behaviour, network calls, dropped files |
Both are usually needed — static analysis reveals intent and structure; dynamic analysis confirms actual runtime behaviour and catches obfuscated code that only decrypts at runtime.
See Malware Analysis for the full combined workflow.
Key Techniques
Disassembly
Convert machine code to assembly language. Reveals the exact instructions the CPU executes.
objdump -d binary # Linux # Output: raw assembly instructions # 0x401000: push rbp # 0x401001: mov rbp, rsp
Decompilation
Convert assembly to higher-level pseudocode (C-like). Easier to read than raw assembly but less accurate than the original. Ghidra's decompiler is the standard free tool.
Debugging
Step through execution to observe register values, memory contents, and control flow at each instruction.
x64dbg (Windows) — GUI debugger, good for malware gdb (Linux) — standard debugger WinDbg — kernel-level debugging
Strings Extraction
Fast initial triage — reveals readable strings without executing the binary:
strings binary.exe | grep -Ei "http|\.exe|cmd|powershell|registry" floss binary.exe # handles obfuscated/stack strings
Tools
| Tool | Type | Use |
|---|---|---|
| Ghidra | Disassembler + decompiler | Full static analysis — free, NSA-developed |
| IDA Pro | Disassembler + decompiler | Industry standard — expensive |
| x64dbg | Debugger | Windows dynamic analysis |
| gdb | Debugger | Linux dynamic analysis |
| PeStudio | PE analyser | Fast Windows binary triage |
| Binwalk | Firmware analyser | Embedded firmware extraction |
| floss | String extractor | Obfuscated string recovery |
| Wireshark | Traffic analyser | Dynamic network behaviour |
Obfuscation and Evasion
Malware authors deliberately hinder reverse engineering:
Packers — compress and encrypt payload; unpacks at runtime String encryption — XOR or AES-encrypt all readable strings Anti-debugging — detect debugger presence and alter behaviour Code virtualisation — replace native code with custom VM bytecode Control flow obfuscation — add junk jumps and dead code
Counter-techniques:
- Run packer until unpacked code is in memory, then dump
- Set breakpoints after decryption routines for string recovery
flossrecovers stack strings and decoded strings automatically- Dynamic analysis bypasses static obfuscation entirely
Tips
- Start with strings and PE headers (PeStudio) — often enough to identify the malware family without deeper analysis
- Ghidra's decompiler is the first tool to reach for after initial triage — the pseudocode view is far more readable than assembly for most analysts
- Set breakpoints at API calls rather than stepping through every instruction — network functions, file writes, and registry modifications are the high-value targets
- REMnux provides most of these tools pre-installed — use it as the analysis environment to keep the host clean