| name | reverse-engineering |
| description | Reverse engineer binaries using radare2 (r2), rabin2, objdump, readelf, and strings. Analyze PE/ELF executables, shellcode, scripts, and documents. Covers disassembly, control flow, imports, crypto detection, and anti-analysis techniques. |
| argument-hint | <path-to-binary> |
| allowed-tools | Bash Read Write Grep Glob |
Reverse Engineering Analysis
You are reverse engineering a binary or suspicious file using radare2 and supporting tools. Systematically analyze the target, document functionality, and identify malicious behavior.
SAFETY: Do NOT execute the binary. Analysis is static only unless the user explicitly requests dynamic/debug analysis.
Target
Binary: $ARGUMENTS
Pre-flight Checks
which r2 rabin2 rahash2 rafind2 rasm2 rax2 2>/dev/null || echo "WARNING: radare2 suite not found"
which objdump readelf strings file 2>/dev/null || echo "WARNING: binutils not found"
which pdf-parser pdfid 2>/dev/null || echo "pdf tools available"
Analysis Procedure
Phase 1: File Identification & Hashing
file <target>
sha256sum <target>
md5sum <target>
rahash2 -a md5,sha1,sha256,crc32 <target>
ls -lh <target>
Phase 2: Binary Metadata (rabin2)
rabin2 is the radare2 binary info extractor — use it for fast metadata without loading the full r2 shell.
rabin2 -I <target>
rabin2 -e <target>
rabin2 -i <target>
rabin2 -E <target>
rabin2 -s <target>
rabin2 -z <target> | head -100
rabin2 -zz <target> | head -100
rabin2 -S <target>
rabin2 -l <target>
rabin2 -R <target> | head -50
rabin2 -H <target>
rabin2 -c <target> 2>/dev/null | head -30
Phase 3: ELF-Specific Analysis (Linux binaries)
readelf -h <target>
readelf -S <target>
readelf -l <target>
readelf -d <target>
readelf -s <target> | head -50
readelf -n <target>
readelf -l <target> | grep -i "GNU_RELRO"
readelf -s <target> | grep -i "__stack_chk_fail"
readelf -l <target> | grep -i "GNU_STACK"
rabin2 -I <target> | grep -iE "pic|canary|nx|relro"
Phase 4: PE-Specific Analysis (Windows binaries)
objdump -x <target> | head -100
objdump -h <target>
objdump -p <target> | grep -A2000 "Import Tables" | head -200
objdump -h <target> | awk '{print $2}' | grep -viE "^(\.text|\.data|\.rdata|\.rsrc|\.reloc|\.bss|\.idata|\.edata|$)" | head -20
rabin2 -I <target> | grep -i "compiled\|timestamp\|date"
objdump -p <target> | grep -i "TLS"
Phase 5: Radare2 Deep Analysis
r2 -q -c "aaa" <target> 2>/dev/null
r2 -q -c "aaa; afl~[2,0,3]" <target> | sort -rn | head -40
r2 -q -c "aaa; afl~?" <target>
r2 -q -c "aaa; s entry0; pd 50" <target>
r2 -q -c "aaa; s main; pdf" <target> 2>/dev/null
r2 -q -c "aaa; axt @@ sym.imp.*" <target> 2>/dev/null | head -50
r2 -q -c "aaa; axt @@ str.*" <target> 2>/dev/null | head -50
Phase 6: Suspicious Import Analysis
Categorize imports by threat behavior:
r2 -q -c "aaa; afl" <target> 2>/dev/null | grep -iE "VirtualAlloc|VirtualProtect|WriteProcessMemory|CreateRemoteThread|NtUnmapViewOfSection|QueueUserAPC|NtQueueApcThread"
r2 -q -c "aaa; afl" <target> 2>/dev/null | grep -iE "WinExec|ShellExecute|CreateProcess|system|exec|popen"
rabin2 -i <target> | grep -iE "CreateFile|WriteFile|ReadFile|DeleteFile|MoveFile|CopyFile|fopen|fwrite"
rabin2 -i <target> | grep -iE "WSAStartup|socket|connect|bind|listen|send|recv|InternetOpen|HttpSendRequest|URLDownloadToFile|WinHttpOpen"
rabin2 -i <target> | grep -iE "RegOpenKey|RegSetValue|RegCreateKey|RegDeleteKey"
rabin2 -i <target> | grep -iE "CryptEncrypt|CryptDecrypt|CryptGenKey|CryptImportKey|BCryptEncrypt"
rabin2 -i <target> | grep -iE "IsDebuggerPresent|CheckRemoteDebugger|NtQueryInformationProcess|GetTickCount|QueryPerformanceCounter|OutputDebugString"
Phase 7: Shellcode Analysis
If the target is raw shellcode or contains shellcode:
rasm2 -a x86 -b 32 -d -f <target> | head -50
rasm2 -a x86 -b 64 -d -f <target> | head -50
r2 -q -c "e asm.arch=x86; e asm.bits=32; pd 50" <target> 2>/dev/null
rafind2 -x "558bec" <target>
rafind2 -x "6a00" <target>
rafind2 -x "ff15" <target>
rafind2 -x "e8" <target>
Phase 8: Document Analysis (PDF/Office)
PDF files:
pdfid <target>
pdfid <target> | grep -iE "JS|JavaScript|OpenAction|AA|Launch|EmbeddedFile|RichMedia|ObjStm"
pdf-parser <target> | head -100
pdf-parser --type /JS <target> 2>/dev/null
pdf-parser --type /JavaScript <target> 2>/dev/null
pdf-parser --search "eval\|exec\|unescape\|fromCharCode" <target> 2>/dev/null
Phase 9: Entropy & Packing Analysis
r2 -q -c "iS entropy" <target> 2>/dev/null
rabin2 -I <target> | grep -i "packer\|compiler\|linker"
strings -a <target> | grep -iE "UPX|Themida|VMProtect|Enigma|ASPack|PECompact|MPRESS|Petite|NSPack"
binwalk -E <target> 2>/dev/null
Phase 10: Specific Function Deep-Dive
For functions identified as suspicious in earlier phases:
r2 -q -c "aaa; pdf @ <function_name_or_address>" <target>
r2 -q -c "aaa; agc @ <function_name_or_address>" <target> 2>/dev/null
r2 -q -c "aaa; axt @ <function_name_or_address>" <target>
r2 -q -c "aaa; axf @ <function_name_or_address>" <target>
r2 -q -c "px 256 @ <address>" <target>
Validation Rules
- Imports: Suspicious imports must be correlated with actual code that calls them (via xrefs)
- Strings: Suspicious strings must be referenced by code (not just present in data sections)
- Packing: Confirmed by high entropy + packer signatures + small import table
- Malicious behavior: Requires multiple converging indicators, not a single suspicious import
- Anti-analysis: Must find actual implementation, not just import presence
Report Output
Write the report to ./reports/reverse-engineering-report.md:
# Reverse Engineering Report
**Date**: <date>
**File**: <filename>
**SHA256**: <hash>
**Architecture**: <arch/bits>
**Format**: <PE/ELF/Mach-O/raw>
**Compiler/Packer**: <if detected>
**Analyst**: Claude Code DFIR
## Executive Summary
<What this binary does in 2-3 sentences>
## Binary Properties
| Property | Value |
|----------|-------|
| Type | |
| Arch | |
| Bits | |
| Endianness | |
| Stripped | |
| Static/Dynamic | |
| PIE | |
| NX | |
| Canary | |
| RELRO | |
| Packer | |
## Capabilities Assessment
| Capability | Evidence | Risk |
|------------|----------|------|
| Process Injection | | |
| Network Communication | | |
| File System Manipulation | | |
| Registry Modification | | |
| Credential Access | | |
| Anti-Analysis | | |
| Persistence | | |
| Encryption/Encoding | | |
## Key Functions
| Address | Name | Purpose | Suspicious |
|---------|------|---------|------------|
## Findings
### Finding 1: <Title>
- **Category**: <capability>
- **Evidence**: <disassembly/imports/strings>
- **Validation**: <cross-references>
- **MITRE ATT&CK**: <technique ID>
- **Reproduce**:
```bash
<exact r2/rabin2/command(s) the analyst can copy-paste to independently verify this finding>
Control Flow Summary
Indicators of Compromise
Recommendations
```
Create the reports/ directory if it does not exist.