Malware analysis (deep RE)
When it applies
defense-malware-triage gave a verdict and you need the deep dive: a packed or obfuscated sample, a
family you must write durable detection for, or an implant recovered on an engagement whose C2,
injection, and persistence mechanisms you need to document. Covers EXE / DLL / SYS / .NET and script
droppers (bat, ps1, vba). Always work inside an isolated analysis VM — detonating an unknown sample
on a real host is itself an incident.
Why it works
Malware hides its intent behind packing, dynamic API resolution, and environment checks, but every
layer must eventually resolve to real API calls and real behavior. Static analysis maps the
capabilities; a debugger or sandbox catches what only exists at runtime (decrypted strings, resolved
imports, injected code). Detection written on code/string internals — not hashes — survives
recompilation.
Method
Anti-analysis catalog, YARA/Sigma writing guide, and rule examples: see
cheatsheet.md next to this file.
- Triage fast.
file, sha256sum (hash-check VT / MalwareBazaar / Triage — don't upload a
possibly targeted sample), diec (packer/compiler ID), floss (deobfuscated strings),
pecheck / pescan (PE structural anomalies), rabin2 -zz (strings + xrefs). Record the file
class: EXE / DLL / SYS / .NET / script — each has its own anchors below.
- Unpack and rebuild the IAT if packed: x86 → ImportREC, x64 → Scylla. If repair fails or the
dumped binary crashes on start (self CRC/size checks), stop repairing statically, record the
failure, and go dynamic: break on
CreateFile / GetFileSize / hashing APIs and use hardware
breakpoints or memory search to catch the imports at runtime.
- Static deep-dive (Ghidra / IDA / radare2 / x64dbg). One mandatory pass: classify the import
table (
rabin2 -i / pecheck) into network / file / crypto / process-injection / registry.
DLL/SYS → dump the export table too (rabin2 -E). .NET has no classic IAT — use dnSpy IL /
metadata / assembly references as the equivalent anchor. A suspiciously clean import table means
dynamic resolution — break on GetProcAddress and look for API-hash loops. No ASCII IOCs →
retry wide strings (strings -el). Also check .rsrc for embedded payloads and TLS callbacks
for code that runs before the entry point.
- Dynamic run. Pre-set breakpoints in this order: TLS callbacks → entry point → sensitive
APIs →
ExitProcess (dump memory the moment it fires, before restarting). Watch: process
creation, file writes (ransomware?) or deletes (wiper?), Run/RunOnce keys, HTTP/DNS (C2),
VirtualAllocEx (injection), CreateService (persistence). Sandboxes: CAPE (open source,
YARA-integrated), Joe Sandbox / ANY.RUN / Triage (commercial), Cuckoo (legacy). Submit to a local
CAPE: curl -F "file=@sample.exe" http://localhost:8000/apiv2/tasks/create/file/.
- No behavior? The sample is checking its environment (CPUID, RDTSC, PEB flags, tool process
names, disk/RAM size). Locate the check statically, patch it or bypass with hardware breakpoints,
or move to a higher-fidelity host. Record "no behavior + the condition found" — a dormant run
never means "benign".
- Produce detection and intel. YARA on stable strings/opcodes; Sigma for behavioral telemetry
(tag ATT&CK IDs, convert with
sigmac -t splunk rule.yml or sigma convert). Extract IOCs by
class: network (C2 IP/domain/URL/User-Agent), host (file paths, mutexes, Run keys, service
names), behavioral (ATT&CK techniques), static (PDB path, anomalous section names, import combos
like CryptEncrypt + shadow-copy deletion).
Gotchas
- ImportREC on 64-bit samples does not work — use Scylla on x64.
- Signed ≠ safe — verify with sigcheck; a forged or revoked signature does not lower the threat
level.
- Long import tables — filter OS noise and report the malicious combination clusters (e.g.
FindWindow + WriteProcessMemory + CreateRemoteThread).
- Script/macro samples — deobfuscate layer by layer (bat
set splicing, PowerShell
Base64/Gzip/IEX string reversal, VBA stomping/P-code) and keep every layer as evidence.
- A dormant sample is not a clean sample — use the anti-analysis catalog in the cheatsheet to
find what it was checking for.
Verify success
You can state the family/capabilities and the full chain (dropper → payload → persistence → C2),
you have host + network IOCs, and a tested YARA rule (matches the sample set, clean against benign
files) and/or a Sigma rule — reproducible by someone else from your recorded commands.
References
CAPE/Cuckoo docs; YARA & SigmaHQ rule guides; FLOSS; Detect It Easy; pe-sieve. Ship the Sigma rule
with defense-detection-sigma; fast verdicts with defense-malware-triage; generic binary work
with reverse-eng-binary-triage and reverse-eng-deobfuscation.
Portions adapted from reverse-skill by zhaoxuya520, MIT License.
1---2name: reverse-eng-malware3description: >4 Fully analyze a malware sample — static, dynamic, and behavioral — including unpacking and IAT5 rebuild, import-table triage, anti-analysis detection and defeat, IOC extraction, and YARA/Sigma6 rule writing. Load when handed a suspicious PE/ELF/Mach-O/script sample to reverse beyond quick7 triage: packed binaries, "analyze this malware", a sandbox run that shows no behavior, or a need8 for durable detection. Signals: a dropped sample, a VirusTotal/MalwareBazaar hash, C2 strings,9 anti-VM/anti-debug checks, "write a YARA rule for this family".10domain: reverse-engineering11type: methodology12stability: learning13modes: [pentest, defense]14severity: medium15mitre: [T1027, T1497, T1622, T1055]16tools: [ghidra, ida, radare2, x64dbg, floss, die, pecheck, yara, sigma, cape, pe-sieve, dnspy]17schema_version: 118metadata:19 source: https://skillmd.com/skills/noorqureshi/reverse-eng-malware20---2122# Malware analysis (deep RE)2324## When it applies25`defense-malware-triage` gave a verdict and you need the deep dive: a packed or obfuscated sample, a26family you must write durable detection for, or an implant recovered on an engagement whose C2,27injection, and persistence mechanisms you need to document. Covers EXE / DLL / SYS / .NET and script28droppers (bat, ps1, vba). Always work inside an isolated analysis VM — detonating an unknown sample29on a real host is itself an incident.3031## Why it works32Malware hides its intent behind packing, dynamic API resolution, and environment checks, but every33layer must eventually resolve to real API calls and real behavior. Static analysis maps the34capabilities; a debugger or sandbox catches what only exists at runtime (decrypted strings, resolved35imports, injected code). Detection written on code/string internals — not hashes — survives36recompilation.3738## Method39> **Anti-analysis catalog, YARA/Sigma writing guide, and rule examples:** see40> [`cheatsheet.md`](cheatsheet.md) next to this file.41421. **Triage fast.** `file`, `sha256sum` (hash-check VT / MalwareBazaar / Triage — don't upload a43 possibly targeted sample), `diec` (packer/compiler ID), `floss` (deobfuscated strings),44 `pecheck` / `pescan` (PE structural anomalies), `rabin2 -zz` (strings + xrefs). Record the file45 class: EXE / DLL / SYS / .NET / script — each has its own anchors below.462. **Unpack and rebuild the IAT** if packed: x86 → ImportREC, x64 → Scylla. If repair fails or the47 dumped binary crashes on start (self CRC/size checks), stop repairing statically, record the48 failure, and go dynamic: break on `CreateFile` / `GetFileSize` / hashing APIs and use hardware49 breakpoints or memory search to catch the imports at runtime.503. **Static deep-dive** (Ghidra / IDA / radare2 / x64dbg). One mandatory pass: classify the import51 table (`rabin2 -i` / `pecheck`) into network / file / crypto / process-injection / registry.52 DLL/SYS → dump the export table too (`rabin2 -E`). .NET has no classic IAT — use dnSpy IL /53 metadata / assembly references as the equivalent anchor. A suspiciously clean import table means54 dynamic resolution — break on `GetProcAddress` and look for API-hash loops. No ASCII IOCs →55 retry wide strings (`strings -el`). Also check `.rsrc` for embedded payloads and TLS callbacks56 for code that runs before the entry point.574. **Dynamic run.** Pre-set breakpoints in this order: TLS callbacks → entry point → sensitive58 APIs → `ExitProcess` (dump memory the moment it fires, before restarting). Watch: process59 creation, file writes (ransomware?) or deletes (wiper?), Run/RunOnce keys, HTTP/DNS (C2),60 `VirtualAllocEx` (injection), `CreateService` (persistence). Sandboxes: CAPE (open source,61 YARA-integrated), Joe Sandbox / ANY.RUN / Triage (commercial), Cuckoo (legacy). Submit to a local62 CAPE: `curl -F "file=@sample.exe" http://localhost:8000/apiv2/tasks/create/file/`.635. **No behavior?** The sample is checking its environment (CPUID, RDTSC, PEB flags, tool process64 names, disk/RAM size). Locate the check statically, patch it or bypass with hardware breakpoints,65 or move to a higher-fidelity host. Record "no behavior + the condition found" — a dormant run66 never means "benign".676. **Produce detection and intel.** YARA on stable strings/opcodes; Sigma for behavioral telemetry68 (tag ATT&CK IDs, convert with `sigmac -t splunk rule.yml` or `sigma convert`). Extract IOCs by69 class: network (C2 IP/domain/URL/User-Agent), host (file paths, mutexes, Run keys, service70 names), behavioral (ATT&CK techniques), static (PDB path, anomalous section names, import combos71 like `CryptEncrypt` + shadow-copy deletion).7273## Gotchas74- **ImportREC on 64-bit samples** does not work — use Scylla on x64.75- **Signed ≠ safe** — verify with sigcheck; a forged or revoked signature does not lower the threat76 level.77- **Long import tables** — filter OS noise and report the malicious combination clusters (e.g.78 `FindWindow` + `WriteProcessMemory` + `CreateRemoteThread`).79- **Script/macro samples** — deobfuscate layer by layer (bat `set` splicing, PowerShell80 Base64/Gzip/`IEX` string reversal, VBA stomping/P-code) and keep every layer as evidence.81- **A dormant sample is not a clean sample** — use the anti-analysis catalog in the cheatsheet to82 find what it was checking for.8384## Verify success85You can state the family/capabilities and the full chain (dropper → payload → persistence → C2),86you have host + network IOCs, and a tested YARA rule (matches the sample set, clean against benign87files) and/or a Sigma rule — reproducible by someone else from your recorded commands.8889## References90CAPE/Cuckoo docs; YARA & SigmaHQ rule guides; FLOSS; Detect It Easy; pe-sieve. Ship the Sigma rule91with `defense-detection-sigma`; fast verdicts with `defense-malware-triage`; generic binary work92with `reverse-eng-binary-triage` and `reverse-eng-deobfuscation`.9394---95_Portions adapted from [reverse-skill](https://github.com/zhaoxuya520/reverse-skill) by zhaoxuya520, MIT License._