Malware Analysis Advanced
Summary
Advanced malware analysis is the discipline of unpacking, reverse engineering, and understanding modern packed/obfuscated malware (UPX, VMProtect, Themida, Enigma, custom packers), identifying sandbox-evasion techniques (anti-VM, anti-debug, anti-analysis), analyzing rootkits (user-mode, kernel-mode, bootkits, UEFI), and authoring detection rules (YARA). This domain covers full unpacking workflows (static + dynamic), modern threat actor tooling (Emotet, TrickBot, Conti, LockBit, BlackCat/ALPHV, REvil), YARA rule authoring and optimization, and industry-standard analyst tooling (IDA Pro, Ghidra, Binary Ninja, radare2). Distinct from foundational binary-reverse — this skill focuses on dynamic unpacking, evasion triage, rootkit techniques, and analyst workflow automation.
Key Terms
- Packer — Tool that compresses + encrypts executable to evade AV (UPX, VMProtect, Themida)
- Unpacking — Recovering original executable from packed binary
- Anti-VM — Code that detects virtual machine (sandbox evasion)
- Anti-debug — Code that detects debugger presence (analyst evasion)
- Anti-analysis — Umbrella term for AV/VM/debug/sandbox evasion
- Rootkit — Tool that hides processes / files / network connections
- User-mode rootkit — Rootkit running in ring 3 (DLL injection, API hooking)
- Kernel-mode rootkit — Rootkit running in ring 0 (driver, syscall hooking)
- Bootkit — Rootkit that infects bootloader (MBR / VBR)
- UEFI rootkit — Rootkit that infects UEFI firmware (persistent across reinstall)
- YARA — Pattern-matching tool for malware identification
- PE — Portable Executable format (Windows binaries)
- ELF — Executable and Linkable Format (Linux binaries)
- Triage — Initial malware assessment (severity, family, capability)
- Sandbox — Isolated analysis environment (Cuckoo, JoeSandbox, Any.Run)
Scope
This skill covers advanced malware analysis:
- Unpacking modern packers (UPX, VMProtect, Themida, Enigma, custom)
- Sandbox-evasion detection (anti-VM, anti-debug, anti-analysis)
- Rootkit analysis (user-mode, kernel-mode, bootkits, UEFI)
- YARA rule authoring and optimization
- IDA Pro / Ghidra / Binary Ninja workflows
- Modern threat tooling (Emotet, TrickBot, Conti, LockBit, BlackCat/ALPHV, REvil)
- Automated triage pipelines
Out of scope: foundational RE (see binary-reverse), exploit development (see exploit-development), reverse engineering theory (see reverse-engineering-advanced).
Use Cases
- Unpacking packed malware: Recover original code from VMProtect/Themida binaries
- Sandbox evasion triage: Identify anti-VM/anti-debug techniques
- Rootkit detection: Find user-mode/kernel-mode rootkit techniques
- YARA rule authoring: Detect malware families by signature
- Threat actor tooling analysis: Reverse engineer Emotet, TrickBot, Conti, LockBit, BlackCat, REvil
- Automated triage pipeline: Build Cuckoo/JoeSandbox pipeline for mass triage
- Detection rule optimization: Tune YARA rules for performance
- Memory forensics: Use Volatility for in-memory malware analysis
- UEFI analysis: Identify UEFI rootkits (LoJax, MosaicRegressor)
- API hook detection: Find user-mode rootkit hooks
Core Tools
| Tool |
Purpose |
IDA Pro |
Industry-standard disassembler + decompiler |
Ghidra |
Open-source RE tool (NSA) |
Binary Ninja |
Modern disassembler + decompiler |
radare2 |
Open-source disassembler |
x64dbg |
Windows dynamic debugger |
WinDbg |
Windows kernel debugger |
gdb |
GNU Debugger (Linux) |
yara |
Pattern-matching tool for malware detection |
volatility3 |
Memory forensics framework |
upx |
UPX unpacker |
vmprotect-devirt |
VMProtect devirtualization |
pe-sieve |
PE artifact scanner (process memory) |
hollows-hunter |
Process hollowing detector |
procdot |
Visual malware analysis |
process-hacker |
Process explorer (Windows) |
autoruns |
Autostart entry scanner |
pcap-ng-tools |
Network capture analysis |
zeek |
Network behavior analyzer |
suricata |
IDS / IPS for malware traffic |
pe-tree |
Visual PE analysis |
imhex |
Modern hex editor |
Methodology
Phase 1 — Static triage
# File hash
sha256sum malware.exe
# File type
file malware.exe
# PE analysis
pe-tree malware.exe
# Strings
strings -a malware.exe | grep -iE "http|dll|reg|cmd"
# Section entropy (packed indicator)
python3 -c "
import pefile
pe = pefile.PE('malware.exe')
for section in pe.sections:
print(f'{section.Name.decode().strip():12s} entropy={section.get_entropy():.2f}')
"
Phase 2 — Unpacking
# UPX
upx -d malware.exe -o malware_unpacked.exe
# VMProtect / Themida / custom
# Use x64dbg + Scylla to dump from memory
# 1. Load in x64dbg
# 2. Set breakpoint on OEP (original entry point)
# 3. Run until OEP hit
# 4. Use Scylla to dump process memory
# 5. Fix IAT (Import Address Table)
Phase 3 — Dynamic analysis
# Run in sandbox (Cuckoo)
cuckoo submit malware.exe
# Manual analysis with x64dbg
# 1. Load binary
# 2. Set breakpoints on WinAPI calls (CreateFile, WriteFile, etc.)
# 3. Run, observe behavior
# 4. Capture network traffic (Wireshark)
# Volatility memory analysis
volatility -f memory.dmp windows.pslist
volatility -f memory.dmp windows.netscan
volatility -f memory.dmp windows.malfind
Phase 4 — Sandbox evasion detection
# Static anti-VM strings
strings malware.exe | grep -iE "vmware|virtualbox|qemu|hyper-v|xen"
strings malware.exe | grep -iE "vbox|vmware tools|prl_"
# Anti-debug APIs
strings malware.exe | grep -iE "IsDebuggerPresent|CheckRemoteDebuggerPresent|NtQueryInformationProcess"
# Dynamic API tracing
# Use API monitor to capture all API calls
Phase 5 — Rootkit analysis
# User-mode rootkit detection
pe-sieve /pid 1234 /imp 3
hollows-hunter /pid 1234
# Kernel-mode rootkit detection
# Use WinDbg kernel mode
# List loaded drivers: lm t n
# Find hooked syscalls: !ssd
# Bootkit detection
# Check MBR / VBR / UEFI variables
bcdedit /enum firmware
Phase 6 — YARA rule authoring
rule Emotet_Loader_v4 {
meta:
author = "redteam"
date = "2026-06-28"
description = "Emotet v4 loader"
reference = "https://attack.mitre.org/software/S0679/"
strings:
$s1 = "emotet" wide ascii nocase
$s2 = { 6A 40 68 00 30 00 00 6A 14 8D 91 }
$s3 = "%u%.4x" wide ascii
$api1 = "CryptStringToBinaryA" wide
$api2 = "InternetOpenA" wide
condition:
uint16(0) == 0x5A4D and
3 of ($s*) and
2 of ($api*)
}
Phase 7 — IDA Pro workflow
# IDA Python script: find anti-debug calls
import idautils, idc
for func_ea in idautils.Functions():
name = idc.get_func_name(func_ea)
if name in ["IsDebuggerPresent", "CheckRemoteDebuggerPresent"]:
print(f"Anti-debug: {name} at {hex(func_ea)}")
# Decompile function
import ida_hexrays
cf = ida_hexrays.decompile(func_ea)
print(cf)
Phase 8 — Ghidra workflow
# Ghidra Python: find suspicious imports
from ghidra.program.model.symbol import SymbolType
sm = currentProgram.getSymbolTable()
for sym in sm.getAllSymbols(True):
if sym.getSymbolType() == SymbolType.FUNCTION:
name = sym.getName()
if "VirtualProtect" in name or "WriteProcessMemory" in name:
print(f"Inject: {name} at {sym.getAddress()}")
Phase 9 — Memory forensics (Volatility)
# Process listing
volatility -f memory.dmp windows.pslist
# Network connections
volatility -f memory.dmp windows.netscan
# Injected code detection
volatility -f memory.dmp windows.malfind
# DLL list per process
volatility -f memory.dmp windows.dlllist --pid 1234
# Kernel driver listing
volatility -f memory.dmp windows.modscan
Phase 10 — Reporting
Produce malware analysis report:
- Family + variant
- IOCs (hashes, domains, IPs, mutexes)
- TTP mapping (MITRE ATT&CK)
- YARA rules
- Detection recommendations
Practical Steps
Step 1 — Triage new sample
# Hash
sha256sum malware.exe > hash.txt
# VT lookup
curl -s "https://www.virustotal.com/api/v3/files/$(sha256sum malware.exe | cut -d' ' -f1)" \
-H "x-apikey: $VT_KEY" | jq .
# PE analysis
pe-tree malware.exe
Step 2 — Unpack UPX sample
upx -d malware_packed.exe -o malware_unpacked.exe
# Verify
sha256sum malware_unpacked.exe
file malware_unpacked.exe
strings -a malware_unpacked.exe | grep -iE "http|dll"
Step 3 — Unpack VMProtect sample
# In x64dbg:
# 1. Load binary
# 2. Set memory breakpoint on .vmp section execution
# 3. Run until breakpoint
# 4. Step until OEP (look for typical MSVC entry point pattern)
# 5. Use Scylla plugin:
# - Select process
# - Click "IAT AutoSearch"
# - Click "Get Imports"
# - Click "Dump" → save unpacked.exe
# - Click "Fix Dump" → fix IAT
Step 4 — Identify anti-VM
# Static
strings malware.exe | grep -iE "vmware|virtualbox|qemu"
strings malware.exe | grep -iE "vmware tools|vbox guest additions"
# Registry keys
strings malware.exe | grep -iE "SYSTEM\\\\CurrentControlSet\\\\Services\\\\VBoxGuest"
Step 5 — YARA rule authoring
rule BlackCat_ALPHV_Ransomware {
meta:
author = "redteam"
description = "BlackCat/ALPHV Rust-based ransomware"
reference = "https://attack.mitre.org/software/S1068/"
strings:
$rust = "rust_panic" wide ascii
$s1 = "BlackCat" wide ascii nocase
$s2 = "{ 52 75 73 74 }" // "Rust" in hex
$api1 = "CryptEncrypt" wide
$api2 = "BCryptEncrypt" wide
condition:
uint16(0) == 0x5A4D and
$rust and
any of ($s*) and
any of ($api*)
}
Step 6 — Memory forensics
volatility -f memory.dmp windows.pslist | grep -v "Microsoft\|Windows"
volatility -f memory.dmp windows.netscan
volatility -f memory.dmp windows.malfind --pid 1234
Step 7 — Rootkit detection
# User-mode hook detection
pe-sieve /pid 1234 /imp 3
# Hollowed process detection
hollows-hunter /pid 1234
# Autoruns (autostart persistence)
autoruns -accepteula -a autostart.arn
Defense Perspective
Defenders must assume:
- Packed malware evades AV signature — unpacking + behavioral detection required
- Sandbox evasion defeats dynamic analysis — anti-VM must be bypassed
- Rootkits hide in kernel — kernel-mode detection (PatchGuard, EDR) required
- UEFI rootkits persist across reinstall — firmware scanning required
- YARA rules need constant tuning — false positives / false negatives
- Memory forensics catches fileless malware — Volatility essential
- Threat actor tooling evolves rapidly — analyst workflow automation needed
- Malware uses LOLBins — signed binaries (certutil, bitsadmin) bypass allowlist
Key defensive controls:
- Behavior-based detection (EDR / XDR)
- Memory scanning (pe-sieve, hollows-hunter)
- YARA scanning at egress + endpoint
- Volatility memory forensics for IR
- Application allowlisting (AppLocker, WDAC)
- Kernel-mode protection (PatchGuard)
- UEFI Secure Boot
- Behavioral baseline for processes
Packer Triage Cheat Sheet
| Packer |
Detection |
Unpacking difficulty |
| UPX |
Section ".UPX0/.UPX1" |
Easy (upx -d) |
| ASPack |
Section ".aspack" |
Medium (manual) |
| Themida |
Section ".Themida" |
Hard (WinDbg) |
| VMProtect |
Section ".vmp0/.vmp1" |
Very Hard (devirt) |
| Enigma |
Section ".enigma1/.enigma2" |
Hard |
| Custom |
High entropy + obfuscation |
Very Hard |
Sandbox Evasion Techniques
| Technique |
Detection |
Bypass |
| CPUID VM bit |
Static strings |
Patch CPUID |
| Registry VM keys |
Strings (VMware, VBox) |
Registry scrub |
| MAC address OUI |
Network adapter |
Spoof MAC |
| Process count |
Psapi enumeration |
Inject extra processes |
| Sleep + check |
Timing analysis |
Hook sleep |
| Mouse movement |
Cursor position |
Virtual mouse |
| Disk size |
<60GB = VM |
Larger VMDK |
| Recent files |
User profile age |
Pre-populate |
Rootkit Categories
| Type |
Ring |
Persistence |
Example |
| User-mode |
3 |
Registry |
Hacker Defender |
| Kernel-mode |
0 |
Driver |
Rustock |
| Bootkit |
0 |
MBR/VBR |
TDL4 |
| UEFI |
-1 |
Firmware |
LoJax |
Threat Actor Tooling
| Family |
Type |
Packer |
Notable Techniques |
| Emotet |
Loader |
Custom |
Macro dropper, polymorphic |
| TrickBot |
Banking trojan |
Custom |
Process hollowing, anti-VM |
| Conti |
Ransomware |
Custom |
LockBit-shared code, Rclone exfil |
| LockBit 3.0 |
Ransomware |
Custom |
StealBit exfil, customizable |
| BlackCat/ALPHV |
Ransomware |
Rust |
MEGA exfil, cross-platform |
| REvil |
Ransomware |
Custom |
Affiliate program, onion leak |
Engagement Workflow
- Triage — hash, file type, PE analysis, VT lookup
- Static analysis — strings, section entropy, import analysis
- Unpacking — UPX/manual/VMProtect devirt
- Dynamic analysis — sandbox + manual x64dbg
- Evasion triage — anti-VM, anti-debug, anti-analysis
- Rootkit detection — user/kernel/boot/UEFI
- YARA authoring — detection rules
- Reporting — IOCs, TTPs, detection recommendations
Lab Setup
# Cuckoo sandbox
git clone https://github.com/cuckoosandbox/cuckoo
cd cuckoo && python3 setup.py install
# Ghidra
wget https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_11.0_build/ghidra_11.0_PUBLIC_20231222.zip
unzip ghidra_11.0_PUBLIC_20231222.zip
# Volatility
pip install volatility3
# YARA
pip install yara-python
Quality Checklist
Detection Methods
Static Analysis Detection
- AV signatures: YARA rules, ClamAV signatures match known malware families.
- Entropy analysis: PE sections with entropy > 7.0 (packed/encrypted).
- Import table anomalies: Missing imports (
LoadLibrary, GetProcAddress); imports via hash resolution.
- PE structure anomalies: Imports via only
LoadLibraryA/GetProcAddress; signature of dynamic resolution.
Dynamic Analysis Detection
- Sandbox detonation: Cuckoo, Joe Sandbox; behavioral signatures.
- API call sequences: Mimikatz signature (OpenProcess + ReadProcessMemory + WriteProcessMemory on lsass).
- Network anomalies: Connections to known C2 infrastructure (Cobalt Strike teamserver default ports).
SIEM Detection Rules
- Splunk SPL:
index=malware sourcetype=yara | where rule matches "mimikatz/*"
- YARA rules: Continuous scanning of filesystem for known signatures.
- AMSI integration: Scan PowerShell, VBA, JavaScript content via AMSI.
Defense Evasion Techniques
Anti-Analysis
- Anti-debugging:
IsDebuggerPresent, ntdll!KdUserExceptionDispatcher check, timing checks (rdtsc).
- Anti-VM: MAC address check (VMware 00:50:56), CPUID hypervisor bit, registry artifacts.
- Anti-sandbox: Mouse movement check (real users have jitter), recent documents check, uptime check.
- Anti-AV: Process enumeration looking for av processes; exit if found.
Code Obfuscation
- Packing: UPX, ASPack, Themida, VMProtect; detect via entropy.
- Polymorphic code: Decryptor changes; payload signature constant.
- Metamorphic code: Body rewritten each generation; no static signature.
- Control flow flattening: Switch dispatcher; defeats static analysis.
- Junk code insertion: No-op instructions between real instructions.
- String encryption: Encrypt sensitive strings; decrypt at runtime only.
Memory-Resident Evasion
- Reflective DLL injection: Load DLL from memory; no file artifacts.
- Process hollowing: Replace legitimate process memory; appears as legitimate process.
- Module stomping: Load legitimate DLL, overwrite; inherits module legitimacy.
- Phantom DLL hollowing: Hollow rarely-used DLL; less attention.
Modern AV/EDR Bypass
- AMSI bypass: Patch
amsi.dll!AmsiScanBuffer in-memory.
- ETW bypass: Patch
ntdll!EtwEventWrite in-memory.
- Direct syscalls: Bypass user-mode hooks (SysWhispers, HellsGate).
- BYOVD: Load vulnerable signed driver for kernel R/W.
References
1---2name: malware-analysis-advanced3description: Advanced malware analysis covering unpacking (UPX, VMProtect, Themida, Enigma, custom packers), sandbox-evasion detection (anti-VM, anti-debug, anti-analysis), rootkit analysis (user-mode, kernel-mode, bootkits, UEFI), YARA rule authoring and optimization, and IDA Pro / Ghidra / Binary Ninja workflows. Distinct from foundational `binary-reverse` — focuses on dynamic unpacking, evasion triage, rootkit techniques, and analyst workflow automation. Use when analyzing modern packed malware (Emotet, TrickBot, Conti, LockBit, BlackCat/ALPHV, REvil), authoring detection rules, or building automated malware triage pipelines.4---56# Malware Analysis Advanced78## Summary910Advanced malware analysis is the discipline of unpacking, reverse engineering, and understanding modern packed/obfuscated malware (UPX, VMProtect, Themida, Enigma, custom packers), identifying sandbox-evasion techniques (anti-VM, anti-debug, anti-analysis), analyzing rootkits (user-mode, kernel-mode, bootkits, UEFI), and authoring detection rules (YARA). This domain covers full unpacking workflows (static + dynamic), modern threat actor tooling (Emotet, TrickBot, Conti, LockBit, BlackCat/ALPHV, REvil), YARA rule authoring and optimization, and industry-standard analyst tooling (IDA Pro, Ghidra, Binary Ninja, radare2). Distinct from foundational `binary-reverse` — this skill focuses on dynamic unpacking, evasion triage, rootkit techniques, and analyst workflow automation.1112## Key Terms1314- **Packer** — Tool that compresses + encrypts executable to evade AV (UPX, VMProtect, Themida)15- **Unpacking** — Recovering original executable from packed binary16- **Anti-VM** — Code that detects virtual machine (sandbox evasion)17- **Anti-debug** — Code that detects debugger presence (analyst evasion)18- **Anti-analysis** — Umbrella term for AV/VM/debug/sandbox evasion19- **Rootkit** — Tool that hides processes / files / network connections20- **User-mode rootkit** — Rootkit running in ring 3 (DLL injection, API hooking)21- **Kernel-mode rootkit** — Rootkit running in ring 0 (driver, syscall hooking)22- **Bootkit** — Rootkit that infects bootloader (MBR / VBR)23- **UEFI rootkit** — Rootkit that infects UEFI firmware (persistent across reinstall)24- **YARA** — Pattern-matching tool for malware identification25- **PE** — Portable Executable format (Windows binaries)26- **ELF** — Executable and Linkable Format (Linux binaries)27- **Triage** — Initial malware assessment (severity, family, capability)28- **Sandbox** — Isolated analysis environment (Cuckoo, JoeSandbox, Any.Run)2930## Scope3132This skill covers **advanced malware analysis**:33- Unpacking modern packers (UPX, VMProtect, Themida, Enigma, custom)34- Sandbox-evasion detection (anti-VM, anti-debug, anti-analysis)35- Rootkit analysis (user-mode, kernel-mode, bootkits, UEFI)36- YARA rule authoring and optimization37- IDA Pro / Ghidra / Binary Ninja workflows38- Modern threat tooling (Emotet, TrickBot, Conti, LockBit, BlackCat/ALPHV, REvil)39- Automated triage pipelines4041**Out of scope**: foundational RE (see `binary-reverse`), exploit development (see `exploit-development`), reverse engineering theory (see `reverse-engineering-advanced`).4243## Use Cases4445- **Unpacking packed malware**: Recover original code from VMProtect/Themida binaries46- **Sandbox evasion triage**: Identify anti-VM/anti-debug techniques47- **Rootkit detection**: Find user-mode/kernel-mode rootkit techniques48- **YARA rule authoring**: Detect malware families by signature49- **Threat actor tooling analysis**: Reverse engineer Emotet, TrickBot, Conti, LockBit, BlackCat, REvil50- **Automated triage pipeline**: Build Cuckoo/JoeSandbox pipeline for mass triage51- **Detection rule optimization**: Tune YARA rules for performance52- **Memory forensics**: Use Volatility for in-memory malware analysis53- **UEFI analysis**: Identify UEFI rootkits (LoJax, MosaicRegressor)54- **API hook detection**: Find user-mode rootkit hooks5556## Core Tools5758| Tool | Purpose |59|------|---------|60| `IDA Pro` | Industry-standard disassembler + decompiler |61| `Ghidra` | Open-source RE tool (NSA) |62| `Binary Ninja` | Modern disassembler + decompiler |63| `radare2` | Open-source disassembler |64| `x64dbg` | Windows dynamic debugger |65| `WinDbg` | Windows kernel debugger |66| `gdb` | GNU Debugger (Linux) |67| `yara` | Pattern-matching tool for malware detection |68| `volatility3` | Memory forensics framework |69| `upx` | UPX unpacker |70| `vmprotect-devirt` | VMProtect devirtualization |71| `pe-sieve` | PE artifact scanner (process memory) |72| `hollows-hunter` | Process hollowing detector |73| `procdot` | Visual malware analysis |74| `process-hacker` | Process explorer (Windows) |75| `autoruns` | Autostart entry scanner |76| `pcap-ng-tools` | Network capture analysis |77| `zeek` | Network behavior analyzer |78| `suricata` | IDS / IPS for malware traffic |79| `pe-tree` | Visual PE analysis |80| `imhex` | Modern hex editor |8182## Methodology8384### Phase 1 — Static triage8586```bash87# File hash88sha256sum malware.exe8990# File type91file malware.exe9293# PE analysis94pe-tree malware.exe9596# Strings97strings -a malware.exe | grep -iE "http|dll|reg|cmd"9899# Section entropy (packed indicator)100python3 -c "101import pefile102pe = pefile.PE('malware.exe')103for section in pe.sections:104 print(f'{section.Name.decode().strip():12s} entropy={section.get_entropy():.2f}')105"106```107108### Phase 2 — Unpacking109110```bash111# UPX112upx -d malware.exe -o malware_unpacked.exe113114# VMProtect / Themida / custom115# Use x64dbg + Scylla to dump from memory116# 1. Load in x64dbg117# 2. Set breakpoint on OEP (original entry point)118# 3. Run until OEP hit119# 4. Use Scylla to dump process memory120# 5. Fix IAT (Import Address Table)121```122123### Phase 3 — Dynamic analysis124125```bash126# Run in sandbox (Cuckoo)127cuckoo submit malware.exe128129# Manual analysis with x64dbg130# 1. Load binary131# 2. Set breakpoints on WinAPI calls (CreateFile, WriteFile, etc.)132# 3. Run, observe behavior133# 4. Capture network traffic (Wireshark)134135# Volatility memory analysis136volatility -f memory.dmp windows.pslist137volatility -f memory.dmp windows.netscan138volatility -f memory.dmp windows.malfind139```140141### Phase 4 — Sandbox evasion detection142143```bash144# Static anti-VM strings145strings malware.exe | grep -iE "vmware|virtualbox|qemu|hyper-v|xen"146strings malware.exe | grep -iE "vbox|vmware tools|prl_"147148# Anti-debug APIs149strings malware.exe | grep -iE "IsDebuggerPresent|CheckRemoteDebuggerPresent|NtQueryInformationProcess"150151# Dynamic API tracing152# Use API monitor to capture all API calls153```154155### Phase 5 — Rootkit analysis156157```bash158# User-mode rootkit detection159pe-sieve /pid 1234 /imp 3160hollows-hunter /pid 1234161162# Kernel-mode rootkit detection163# Use WinDbg kernel mode164# List loaded drivers: lm t n165# Find hooked syscalls: !ssd166167# Bootkit detection168# Check MBR / VBR / UEFI variables169bcdedit /enum firmware170```171172### Phase 6 — YARA rule authoring173174```yara175rule Emotet_Loader_v4 {176 meta:177 author = "redteam"178 date = "2026-06-28"179 description = "Emotet v4 loader"180 reference = "https://attack.mitre.org/software/S0679/"181 strings:182 $s1 = "emotet" wide ascii nocase183 $s2 = { 6A 40 68 00 30 00 00 6A 14 8D 91 }184 $s3 = "%u%.4x" wide ascii185 $api1 = "CryptStringToBinaryA" wide186 $api2 = "InternetOpenA" wide187 condition:188 uint16(0) == 0x5A4D and189 3 of ($s*) and190 2 of ($api*)191}192```193194### Phase 7 — IDA Pro workflow195196```python197# IDA Python script: find anti-debug calls198import idautils, idc199200for func_ea in idautils.Functions():201 name = idc.get_func_name(func_ea)202 if name in ["IsDebuggerPresent", "CheckRemoteDebuggerPresent"]:203 print(f"Anti-debug: {name} at {hex(func_ea)}")204205# Decompile function206import ida_hexrays207cf = ida_hexrays.decompile(func_ea)208print(cf)209```210211### Phase 8 — Ghidra workflow212213```python214# Ghidra Python: find suspicious imports215from ghidra.program.model.symbol import SymbolType216217sm = currentProgram.getSymbolTable()218for sym in sm.getAllSymbols(True):219 if sym.getSymbolType() == SymbolType.FUNCTION:220 name = sym.getName()221 if "VirtualProtect" in name or "WriteProcessMemory" in name:222 print(f"Inject: {name} at {sym.getAddress()}")223```224225### Phase 9 — Memory forensics (Volatility)226227```bash228# Process listing229volatility -f memory.dmp windows.pslist230231# Network connections232volatility -f memory.dmp windows.netscan233234# Injected code detection235volatility -f memory.dmp windows.malfind236237# DLL list per process238volatility -f memory.dmp windows.dlllist --pid 1234239240# Kernel driver listing241volatility -f memory.dmp windows.modscan242```243244### Phase 10 — Reporting245246Produce malware analysis report:247- Family + variant248- IOCs (hashes, domains, IPs, mutexes)249- TTP mapping (MITRE ATT&CK)250- YARA rules251- Detection recommendations252253## Practical Steps254255### Step 1 — Triage new sample256257```bash258# Hash259sha256sum malware.exe > hash.txt260261# VT lookup262curl -s "https://www.virustotal.com/api/v3/files/$(sha256sum malware.exe | cut -d' ' -f1)" \263 -H "x-apikey: $VT_KEY" | jq .264265# PE analysis266pe-tree malware.exe267```268269### Step 2 — Unpack UPX sample270271```bash272upx -d malware_packed.exe -o malware_unpacked.exe273274# Verify275sha256sum malware_unpacked.exe276file malware_unpacked.exe277strings -a malware_unpacked.exe | grep -iE "http|dll"278```279280### Step 3 — Unpack VMProtect sample281282```bash283# In x64dbg:284# 1. Load binary285# 2. Set memory breakpoint on .vmp section execution286# 3. Run until breakpoint287# 4. Step until OEP (look for typical MSVC entry point pattern)288# 5. Use Scylla plugin:289# - Select process290# - Click "IAT AutoSearch"291# - Click "Get Imports"292# - Click "Dump" → save unpacked.exe293# - Click "Fix Dump" → fix IAT294```295296### Step 4 — Identify anti-VM297298```bash299# Static300strings malware.exe | grep -iE "vmware|virtualbox|qemu"301strings malware.exe | grep -iE "vmware tools|vbox guest additions"302303# Registry keys304strings malware.exe | grep -iE "SYSTEM\\\\CurrentControlSet\\\\Services\\\\VBoxGuest"305```306307### Step 5 — YARA rule authoring308309```yara310rule BlackCat_ALPHV_Ransomware {311 meta:312 author = "redteam"313 description = "BlackCat/ALPHV Rust-based ransomware"314 reference = "https://attack.mitre.org/software/S1068/"315 strings:316 $rust = "rust_panic" wide ascii317 $s1 = "BlackCat" wide ascii nocase318 $s2 = "{ 52 75 73 74 }" // "Rust" in hex319 $api1 = "CryptEncrypt" wide320 $api2 = "BCryptEncrypt" wide321 condition:322 uint16(0) == 0x5A4D and323 $rust and324 any of ($s*) and325 any of ($api*)326}327```328329### Step 6 — Memory forensics330331```bash332volatility -f memory.dmp windows.pslist | grep -v "Microsoft\|Windows"333volatility -f memory.dmp windows.netscan334volatility -f memory.dmp windows.malfind --pid 1234335```336337### Step 7 — Rootkit detection338339```bash340# User-mode hook detection341pe-sieve /pid 1234 /imp 3342343# Hollowed process detection344hollows-hunter /pid 1234345346# Autoruns (autostart persistence)347autoruns -accepteula -a autostart.arn348```349350### Defense Perspective351352Defenders must assume:3533541. **Packed malware evades AV signature** — unpacking + behavioral detection required3552. **Sandbox evasion defeats dynamic analysis** — anti-VM must be bypassed3563. **Rootkits hide in kernel** — kernel-mode detection (PatchGuard, EDR) required3574. **UEFI rootkits persist across reinstall** — firmware scanning required3585. **YARA rules need constant tuning** — false positives / false negatives3596. **Memory forensics catches fileless malware** — Volatility essential3607. **Threat actor tooling evolves rapidly** — analyst workflow automation needed3618. **Malware uses LOLBins** — signed binaries (certutil, bitsadmin) bypass allowlist362363Key defensive controls:364365- Behavior-based detection (EDR / XDR)366- Memory scanning (pe-sieve, hollows-hunter)367- YARA scanning at egress + endpoint368- Volatility memory forensics for IR369- Application allowlisting (AppLocker, WDAC)370- Kernel-mode protection (PatchGuard)371- UEFI Secure Boot372- Behavioral baseline for processes373374## Packer Triage Cheat Sheet375376| Packer | Detection | Unpacking difficulty |377|--------|-----------|---------------------|378| UPX | Section ".UPX0/.UPX1" | Easy (`upx -d`) |379| ASPack | Section ".aspack" | Medium (manual) |380| Themida | Section ".Themida" | Hard (WinDbg) |381| VMProtect | Section ".vmp0/.vmp1" | Very Hard (devirt) |382| Enigma | Section ".enigma1/.enigma2" | Hard |383| Custom | High entropy + obfuscation | Very Hard |384385## Sandbox Evasion Techniques386387| Technique | Detection | Bypass |388|-----------|-----------|--------|389| CPUID VM bit | Static strings | Patch CPUID |390| Registry VM keys | Strings (VMware, VBox) | Registry scrub |391| MAC address OUI | Network adapter | Spoof MAC |392| Process count | Psapi enumeration | Inject extra processes |393| Sleep + check | Timing analysis | Hook sleep |394| Mouse movement | Cursor position | Virtual mouse |395| Disk size | <60GB = VM | Larger VMDK |396| Recent files | User profile age | Pre-populate |397398## Rootkit Categories399400| Type | Ring | Persistence | Example |401|------|------|-------------|---------|402| User-mode | 3 | Registry | Hacker Defender |403| Kernel-mode | 0 | Driver | Rustock |404| Bootkit | 0 | MBR/VBR | TDL4 |405| UEFI | -1 | Firmware | LoJax |406407## Threat Actor Tooling408409| Family | Type | Packer | Notable Techniques |410|--------|------|--------|---------------------|411| Emotet | Loader | Custom | Macro dropper, polymorphic |412| TrickBot | Banking trojan | Custom | Process hollowing, anti-VM |413| Conti | Ransomware | Custom | LockBit-shared code, Rclone exfil |414| LockBit 3.0 | Ransomware | Custom | StealBit exfil, customizable |415| BlackCat/ALPHV | Ransomware | Rust | MEGA exfil, cross-platform |416| REvil | Ransomware | Custom | Affiliate program, onion leak |417418## Engagement Workflow4194201. **Triage** — hash, file type, PE analysis, VT lookup4212. **Static analysis** — strings, section entropy, import analysis4223. **Unpacking** — UPX/manual/VMProtect devirt4234. **Dynamic analysis** — sandbox + manual x64dbg4245. **Evasion triage** — anti-VM, anti-debug, anti-analysis4256. **Rootkit detection** — user/kernel/boot/UEFI4267. **YARA authoring** — detection rules4278. **Reporting** — IOCs, TTPs, detection recommendations428429## Lab Setup430431```bash432# Cuckoo sandbox433git clone https://github.com/cuckoosandbox/cuckoo434cd cuckoo && python3 setup.py install435436# Ghidra437wget https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_11.0_build/ghidra_11.0_PUBLIC_20231222.zip438unzip ghidra_11.0_PUBLIC_20231222.zip439440# Volatility441pip install volatility3442443# YARA444pip install yara-python445```446447## Quality Checklist448449- [ ] File hash + VT lookup450- [ ] PE analysis complete451- [ ] Packer identified452- [ ] Sample unpacked453- [ ] Sandbox evasion identified454- [ ] Rootkit techniques analyzed455- [ ] YARA rule authored456- [ ] IOCs documented457- [ ] TTP mapping complete458- [ ] Final report delivered459460## Detection Methods461462### Static Analysis Detection463- **AV signatures**: YARA rules, ClamAV signatures match known malware families.464- **Entropy analysis**: PE sections with entropy > 7.0 (packed/encrypted).465- **Import table anomalies**: Missing imports (`LoadLibrary`, `GetProcAddress`); imports via hash resolution.466- **PE structure anomalies**: Imports via only `LoadLibraryA`/`GetProcAddress`; signature of dynamic resolution.467468### Dynamic Analysis Detection469- **Sandbox detonation**: Cuckoo, Joe Sandbox; behavioral signatures.470- **API call sequences**: Mimikatz signature (OpenProcess + ReadProcessMemory + WriteProcessMemory on lsass).471- **Network anomalies**: Connections to known C2 infrastructure (Cobalt Strike teamserver default ports).472473### SIEM Detection Rules474- **Splunk SPL**: `index=malware sourcetype=yara | where rule matches "mimikatz/*"`475- **YARA rules**: Continuous scanning of filesystem for known signatures.476- **AMSI integration**: Scan PowerShell, VBA, JavaScript content via AMSI.477478## Defense Evasion Techniques479480### Anti-Analysis481- **Anti-debugging**: `IsDebuggerPresent`, `ntdll!KdUserExceptionDispatcher` check, timing checks (rdtsc).482- **Anti-VM**: MAC address check (VMware 00:50:56), CPUID hypervisor bit, registry artifacts.483- **Anti-sandbox**: Mouse movement check (real users have jitter), recent documents check, uptime check.484- **Anti-AV**: Process enumeration looking for av processes; exit if found.485486### Code Obfuscation487- **Packing**: UPX, ASPack, Themida, VMProtect; detect via entropy.488- **Polymorphic code**: Decryptor changes; payload signature constant.489- **Metamorphic code**: Body rewritten each generation; no static signature.490- **Control flow flattening**: Switch dispatcher; defeats static analysis.491- **Junk code insertion**: No-op instructions between real instructions.492- **String encryption**: Encrypt sensitive strings; decrypt at runtime only.493494### Memory-Resident Evasion495- **Reflective DLL injection**: Load DLL from memory; no file artifacts.496- **Process hollowing**: Replace legitimate process memory; appears as legitimate process.497- **Module stomping**: Load legitimate DLL, overwrite; inherits module legitimacy.498- **Phantom DLL hollowing**: Hollow rarely-used DLL; less attention.499500### Modern AV/EDR Bypass501- **AMSI bypass**: Patch `amsi.dll!AmsiScanBuffer` in-memory.502- **ETW bypass**: Patch `ntdll!EtwEventWrite` in-memory.503- **Direct syscalls**: Bypass user-mode hooks (SysWhispers, HellsGate).504- **BYOVD**: Load vulnerable signed driver for kernel R/W.505506## References507508- MITRE ATT&CK Defense Evasion — https://attack.mitre.org/tactics/TA0005/509- "Practical Malware Analysis" (Sikorski, Honig, 2012)510- "Malware Analyst's Cookbook" (Ligh, Adair, Hartstein, 2010)511- "Learning Malware Analysis" (Monnappa Ka, 2018)512- "The Art of Memory Forensics" (Hale Ligh, 2014)513- IDA Pro Book (Chris Eagle, 2nd Edition)514- Ghidra documentation — https://ghidra-sre.org/515- Volatility documentation — https://volatility3.readthedocs.io/516- YARA documentation — https://yara.readthedocs.io/517- CISA AA21-148A — DarkSide/Conti analysis518- Mandiant APT1 / APT41 reports519- CrowdStrike 2024 Global Threat Report520- MalwareBazaar — https://bazaar.abuse.ch/521- VirusTotal — https://www.virustotal.com/522- Any.Run sandbox — https://app.any.run/523- JoeSandbox — https://www.joesandbox.com/524- "VMProtect Devirtualization" (BlackHat 2023)525- "Rootkit Arsenal" (Blunden, 3rd Edition)526- "UEFI Rootkits" (ESET LoJax report 2018)