Malware Analysis
Table of Contents
Examining malicious software to determine its behaviour, capabilities, and impact — feeding both incident response (what did this do to us) and threat intelligence (what is this, who made it, what else does it target). Always work on a copy in an isolated environment, never the original sample on a live system.
Related: Hashing Incident Response Windows Client DFIR Cuckoo Sandbox PEStudio ProcMon YARA Ghidra Wireshark REMnux
1. Static Analysis
Examine the file without executing it. Always do this first — it is safer and quicker, and often answers enough questions that dynamic analysis isn't needed.
Initial Triage
# Identify file type regardless of extension file sample.exe # Hash for identification and threat intel lookup sha256sum sample.exe md5sum sample.exe # Check hash against VirusTotal / known malware databases
See Hashing for hash type reference.
Strings Extraction
# Readable strings often reveal URLs, IPs, file paths, registry # keys, and sometimes hardcoded credentials or C2 addresses strings sample.exe | grep -Ei "http|\.exe|\.dll|registry|cmd" # Unicode strings (Windows binaries often use UTF-16) strings -el sample.exe
PE Header Analysis
For Windows executables, PeStudio is the standard tool — examines
imports, exports, sections, and flags suspicious indicators
(packed sections, unusual entry points, suspicious imports like
VirtualAlloc + WriteProcessMemory combinations indicative of
process injection).
Key things to check in PeStudio: - Imported functions — crypto APIs, network APIs, process manipulation APIs are red flags in combination - Section entropy — high entropy suggests packing/encryption - Compile timestamp — can be forged but worth noting - Digital signature — present, valid, and from a trusted publisher? - Embedded strings and resources
Reverse Engineering
For deeper understanding of logic, disassemble or decompile with Ghidra. Time-intensive — reserve for samples where strings and PE analysis don't answer the question, or where attribution matters.
Ghidra workflow: 1. Import the binary, let auto-analysis run 2. Check the entry point and main function 3. Look for suspicious API call sequences 4. Identify any embedded strings the strings command missed (XOR-encoded or otherwise obfuscated) 5. Trace control flow around any network or file system calls
2. Dynamic Analysis
Execute the sample in an isolated, monitored environment to observe actual behaviour. Confirms or extends what static analysis suggested.
Sandbox Execution
Cuckoo Sandbox automates this — detonates the sample in an isolated VM and produces a report covering process activity, file system changes, registry changes, and network traffic in one pass.
Cuckoo workflow: 1. Submit sample to Cuckoo 2. Review the automated report: — Process tree (what spawned what) — Network connections (C2 callbacks, DNS lookups) — File system changes (dropped files, persistence artefacts) — Registry changes (Run keys, services) 3. Cross-reference IOCs against threat intel
Manual Monitoring
When sandbox output needs verification or more granular detail, monitor manually in an isolated VM:
ProcMon — file system, registry, and process activity in real time Filter by process name to isolate the sample's activity Look for: file writes outside expected directories, registry Run key modifications, spawned child processes Process Hacker / Task Manager — confirm process tree, parent-child relationships, and any process injection (unexpected threads in legitimate processes like explorer.exe or svchost.exe)
Network Traffic Analysis
Capture with Wireshark during detonation to observe:
- C2 beacon traffic — periodic connections to the same destination - DNS lookups — domains queried, including DGA-pattern domains - Data exfiltration — unusual outbound volume or destinations - Protocol abuse — non-standard protocols on standard ports (e.g. non-HTTP traffic on port 80/443)
3. Indicator Extraction and Signatures
Once behaviour is understood, extract indicators for detection and future identification.
IOCs to Document
- File hashes (MD5, SHA1, SHA256) of the sample and any dropped files - C2 IP addresses and domains - Mutex names (often hardcoded, used to prevent reinfection — reliable identifier for a specific malware family) - Registry keys created/modified for persistence - File paths and names of dropped artefacts
YARA Rules
YARA rules let you match future samples or scan a fleet for the same malware based on patterns identified during analysis.
rule example_malware_family
{
meta:
description = "Detects sample analysed 2026-06-21"
hash = "sha256_of_sample"
strings:
$s1 = "specific string from strings output"
$mutex = "MutexNameFound"
$c2 = "c2domain.example.com"
condition:
2 of them
}
# Scan other files or a directory against the rule yara example_rule.yar suspicious_file.exe yara -r example_rule.yar C:\Users\
4. Workflow Summary
1. Hash the sample, check against known threat intel 2. Static analysis: strings, PE header (PeStudio), file structure 3. If unresolved: reverse engineer key functions (Ghidra) 4. Dynamic analysis: detonate in sandbox (Cuckoo) or isolated VM 5. Monitor: process activity (ProcMon), network traffic (Wireshark) 6. Extract IOCs: hashes, C2 infrastructure, persistence mechanisms 7. Write YARA rule for detection across the environment 8. Document findings for IR and threat intel
Tips
- Always work in an isolated VM with no network access by default — enable controlled, monitored network access only when observing C2 behaviour is the specific goal
- Hash first, every time — a known hash may already have a full writeup available, saving hours of analysis
- Strings extraction is the fastest static check and frequently reveals C2 domains or file paths without needing a disassembler
- Mutex names are a high-confidence identifier for malware family — more reliable than file hashes which change per build
- Snapshot the VM before detonation and revert after — never reuse an analysis VM without reverting to clean state