# Malware Behavioral Analysis

> Use when you need to understand what malware does at runtime beyond a sandbox summary, covering API call sequences, process injection chains, persistence installation order, and defense evasion in action. Covers reading API traces, mapping behavior to MITRE ATT&CK, analyzing injection techniques (hollowing, APC, mapping), persistence mechanisms (Run keys, services, scheduled tasks, WMI), and correlating multi-process activity into one timeline. Use when a sandbox report needs expert interpretation, when manual dynamic analysis is required, or when building behavior-based detections from observed techniques.

- Skill: `mizazhaider-ceh/malware-behavioral-analysis` (Agent Skill)
- Install (CLI): `npx get-skill add mizazhaider-ceh/malware-behavioral-analysis`
- Raw SKILL.md: https://api.skillmd.com/api/skills/mizazhaider-ceh/malware-behavioral-analysis/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Docs & Writing
- Author: mizazhaider-ceh (https://skillmd.com/u/mizazhaider-ceh)
- Updated: 2026-11-22
- Page: https://skillmd.com/skills/mizazhaider-ceh/malware-behavioral-analysis

---


Behavioral analysis reads what the malware actually did, in order, and
turns a pile of API calls into a story: it arrived this way, it persisted
that way, it talked to this server, it injected into that process. Sandbox
summaries give you the outline; this skill is about the close reading that
catches the technique variant the summary missed, the second persistence
mechanism, the injection target that tells you what data it wanted. Scope:
analyze behavior only from samples you are authorized to handle, in
isolated lab environments, during authorized DFIR or malware research. All
dynamic work stays inside the lab; nothing here justifies running malware
anywhere else.

## Quick Workflow

1. Start from the sandbox report's process tree and timeline; note every
   process the sample touched.
2. Walk the API trace per process in chronological order, flagging the
   technique primitives (alloc, write, create thread, registry set).
3. Identify injection: match VirtualAllocEx plus WriteProcessMemory plus
   CreateRemoteThread (or variants) to a target process.
4. Identify persistence: registry Run keys, services, scheduled tasks,
   startup folder, WMI, in the order installed.
5. Map each behavior cluster to MITRE ATT&CK technique IDs.
6. Correlate across processes into one timeline: dropper to payload to
   beacon.
7. Extract the defender artifacts: Sigma-ready event patterns, IOCs with
   context, and the behavior narrative for the report.

## 1. Reading API traces

An API trace is a log of every interesting call with arguments and return
values. Read for verbs, not volume: filter to the calls that change
system state and skim the rest.

```text
Typical loader trace (abridged, chronological):
  CreateFileW("C:\Users\x\AppData\Local\Temp\pay.dll") -> handle
  WriteFile(handle, <240 KB buffer>)                    ; drop payload
  RegSetValueEx(HKCU\...\Run, "NimbusSync", "rundll32 ...pay.dll,Run")
  CreateProcessW("rundll32.exe", SUSPENDED)             ; hollowing target
  NtUnmapViewOfSection(target)                         ; hollow it
  WriteProcessMemory(target, <payload>)                ; fill it
  SetThreadContext(target, entry=payload)              ; redirect
  ResumeThread(target)                                 ; go
```

Key arguments to capture: file paths written, registry paths and values,
target process names, memory protection flags (PAGE_EXECUTE_READWRITE on a
remote process is the injection smell), and command lines. When a trace is
millions of calls, filter by category first (file, registry, process,
network) and read one category at a time.

## 2. Process injection: recognizing the variants

The primitive sequence is allocate, write, execute in another process.
Variants differ in the execute step:

- **Classic injection**: VirtualAllocEx, WriteProcessMemory,
  CreateRemoteThread. Loudest, most common. T1055.
- **Process hollowing**: CreateProcess suspended, NtUnmapViewOfSection,
  WriteProcessMemory, SetThreadContext, ResumeThread. The target looks
  legitimate (svchost, explorer). T1055.012.
- **APC injection**: OpenThread, QueueUserAPC, then an alertable wait.
  Quieter; watch for QueueUserAPC calls with a payload address.
  T1055.004.
- **Module stomping / mapping**: NtMapViewOfSection into the target.
  Shows as mapped image loads rather than writes. T1055.
- **Thread execution hijacking**: GetThreadContext, SetThreadContext on a
  running thread. No new thread created.

Confirm with memory forensics when the trace is ambiguous:

```bash
vol -f mem.dmp windows.malfind.Malfind
```

Example malfind output shape:

```text
PID 1232 (explorer.exe)  VAD 0x1a0000  Prot: PAGE_EXECUTE_READWRITE
  MZ header present, no mapped file -> injected code
```

Dump the region, hash it, and triage it as its own sample. The injected
payload is often the real implant while the original file was just a
dropper.

## 3. Persistence mechanisms in install order

Malware usually installs persistence early, right after confirming it
runs. Common mechanisms and their traces:

```text
1. Registry Run key
   RegSetValueEx HKCU\Software\Microsoft\Windows\CurrentVersion\Run
   Value: "NimbusSync" = "rundll32.exe C:\...\pay.dll,Run"   [T1547.001]

2. Scheduled task
   schtasks /create /tn "NimbusUpdate" /tr "C:\...\pay.exe" /sc minute /mo 60
   Trace: COM Task Scheduler API or schtasks child process            [T1053.005]

3. Service
   CreateServiceW("NimbusSvc", ..., SERVICE_AUTO_START)               [T1543.003]

4. Startup folder
   CopyFile -> C:\Users\x\AppData\Roaming\Microsoft\Windows\Start Menu\
              Programs\Startup\update.lnk                             [T1547.001]

5. WMI event subscription
   IWbemServices::PutInstance with __EventFilter + CommandLineEventConsumer
                                                                      [T1546.003]
```

Record install order: it tells you which mechanism the malware prefers and
which are fallbacks. Defenders must remove all of them; incident reports
that list only the first one cause reinfection.

## 4. Defense evasion in the trace

Watch for the evasion calls interleaved with real work: IsDebuggerPresent
or CheckRemoteDebuggerPresent before unpacking (T1622), Sleep or
NtDelayExecution with huge values before the payload (T1497.003), WMI
queries for VM artifacts (T1497.001), and attempts to disable defenses:
registry writes to disable Defender, `net stop` on security services,
or deleting shadow copies via vssadmin (T1490, ransomware tell). An
evasion call that succeeds changes your analysis plan (longer detonation,
hardened VM); an evasion call that fails is still evidence of intent and
goes in the report.

## 5. Building the behavior timeline

Merge all processes into one chronological narrative:

```text
T+0s    sample.exe starts (user double-clicked invoice.doc.exe)
T+2s    drops pay.dll to AppData\Local\Temp
T+3s    writes HKCU Run key "NimbusSync"
T+4s    spawns rundll32.exe suspended, hollows it, injects pay.dll
T+6s    injected code resolves APIs via hashing (no new imports)
T+9s    DNS beacon.example-cdn[.]net, HTTP POST /api/v2/beacon
T+69s   second beacon (60s interval confirmed)
```

Each line needs a source: which trace, which PID, which call. The timeline
is the artifact the incident lead and the report reader actually use.

## 6. From behavior to behavior-based detection

Translate technique clusters into Sigma-style logic:

```yaml
title: Nimbus loader hollowing pattern
detection:
  selection:
    ParentImage|endswith: '\sample.exe'
    Image|endswith: '\rundll32.exe'
    CommandLine|contains: 'AppData\Local\Temp'
  condition: selection
```

Behavior detections survive hash changes and catch variants the file
rules miss. Prefer parent-child process relationships and command-line
patterns over single event types; they are harder for the malware to
change without rewriting its logic.

## Edge cases

- Fileless execution: no file writes at all, everything in memory.
  Behavior analysis is the only view; capture RAM and analyze the
  injected regions.
- Living-off-the-land: the malware uses powershell, wmic, rundll32 with
  no dropped payload. The trace looks almost legitimate; focus on
  command-line arguments and parentage anomalies.
- Multi-process chains longer than three hops: draw the tree before
  reading traces, or you will lose the thread.
- Traces with heavy API hashing: you see resolved addresses, not names.
  Resolve by breakpointing the hash resolver or by matching call
  patterns to known sequences.
- Malware that cleans up after itself (deletes dropper, clears logs):
  the absence is evidence; note what should be there and is not.
- Time-dependent behavior: some payloads only act at certain hours.
  Check the VM clock against the sample's expectations.
- Behavior that differs between runs: nondeterministic C2 or
  environment checks. Run three times and diff the timelines before
  concluding.

## Escalation

- If injection targets a critical system process and the payload resists
  dumping, escalate to kernel-level memory acquisition; user-mode dumps
  may miss it.
- If persistence uses a mechanism you cannot fully trace (custom WMI,
  bootkit behavior), escalate to a specialist and flag the host as
  potentially still compromised until proven otherwise.
- If behavior indicates worm-like spreading or lateral movement,
  escalate to the incident lead immediately; analysis continues only in
  tighter isolation.
- If the behavior timeline contradicts the static triage verdict,
  escalate for re-triage: one of the two views is looking at the wrong
  file or the wrong layer.

## Detection and defender view

Behavioral analysis produces the detections that survive the next
variant. For each confirmed technique, write the detection in the
defender's language: a Sigma rule for the process tree or registry
pattern, an EDR hunt query for the injection primitive sequence, a
network signature for the beacon interval. Map everything to ATT&CK so
the SOC can pivot from your report to their existing coverage: "we
detect T1055.012 via rule X, we do not detect T1546.003, gap noted".
Track which behavior detections fire in production and which go quiet;
quiet rules for dead techniques get retired, firing rules get tuned.
The behavior timeline also feeds tabletop exercises: it is the most
realistic attack narrative the blue team will get this quarter.

## Key references

- MITRE ATT&CK (technique reference):
  https://attack.mitre.org/
- Process Monitor documentation:
  https://learn.microsoft.com/en-us/sysinternals/downloads/procmon
- Volatility 3 documentation:
  https://volatility3.readthedocs.io/
- x64dbg documentation:
  https://x64dbg.com/
- Sigma rule specification:
  https://github.com/SigmaHQ/sigma
- MITRE ATT&CK T1055 (Process Injection) sub-techniques:
  https://attack.mitre.org/techniques/T1055/
- MITRE ATT&CK T1547 (Boot or Logon Autostart Execution):
  https://attack.mitre.org/techniques/T1547/

