Skip to content

hypnguyen1209/offensive-claude / skills/malware-analysis

malware-analysis

Unverified

Use when reverse-engineering or detecting malware — static triage + capa/YARA-X, emulation/DBI/.NET unpacking, dynamic/fileless/Volatility 3 memory analysis, C2 config extraction (Cobalt Strike/CAPE), C2 traffic detection (JA4+, beaconing)

references/dynamic-fileless-memory.md

View on GitHub
# Dynamic, Fileless & Memory Analysis

Goal: observe runtime behavior safely, and recover artifacts that never touch disk. Process injection
(T1055) is now the single most common technique in commodity malware — Picus Red Report 2026 found
T1055 in 80% of the top-10 techniques across ~1.1M samples — so memory analysis is mandatory, not
optional.

## Theory / mechanism

- **Sandbox detonation** captures behavior: API calls, file/registry/network ops, child processes.
  Build it from: isolated VM + pre-snapshot + fake services (INetSim/FakeNet-NG) + monitoring
  (ProcMon, Sysmon, API Monitor) + packet capture.
- **Fileless / in-memory** malware lives in RAM (reflective DLL, .NET `Assembly.Load(byte[])`,
  PowerShell download cradles, registry/WMI-stored payloads). Disk forensics misses it entirely;
  you need memory dumps, ETW, and script-block logging.
- **Injection families** to recognize in memory: classic CreateRemoteThread, **process hollowing**
  (unmap+remap a suspended legit process), **process ghosting** (delete-pending image section),
  **PEB masquerading** (forge command line/image path), **module stomping**, APC injection. Each
  leaves a memory tell: executable private memory with **no file backing**, or an image whose
  in-memory bytes diverge from disk.
- **Telemetry tampering**: loaders patch **AMSI** (`AmsiScanBuffer`) and **ETW** (`NtTraceEvent`/
  `EtwEventWrite`) in their own process so script/assembly scanning and event logging go dark.

## Modern 2024-2026 variants (verified)

- **Volatility 3** is the 2025 standard (Win10/11, Linux, macOS). New/relevant plugins:
  `windows.malfind` (RWX/unbacked exec memory — generic injection), `windows.hollowprocesses`
  (process hollowing), `windows.processghosting`, `windows.malware.pebmasquerade`,
  `windows.unhooked_system_calls` (syscall-stub tampering / direct syscalls), `windows.ssdt`,
  `windows.driverirp`. The **2025 Volatility Plugin Contest** added **PEScan** (threat-scores
  in-memory PEs: packer ID, section entropy, header anomalies, embedded IPs/URLs) and a **Fileless
  Malware Hunter** (RATs, miners, LOLBin abuse) + live-system analysis.
- **AMSI/ETW patch IOCs (2025 in the wild, Remcos/AsyncRAT):** `AmsiScanBuffer` overwritten with
  `B8 00 00 00 00 C3` (`mov eax,0; ret`) or `31 C0 C3` (`xor eax,eax; ret`) or
  `B8 57 00 07 80 C3` (return `E_INVALIDARG`); ETW killed by patching `NtTraceEvent` to an early
  `C3` (ret). **Null-AMSI** disables both AMSI and ETW for memory loaders.
- **Patchless AMSI bypass** (escalating 2025 trend): no memory overwrite at all — a **hardware
  breakpoint** on `AmsiScanBuffer` + a **Vectored Exception Handler** rewrites the result, evading
  memory-integrity scanners. Detect via debug-register (Dr0-Dr3/Dr7) anomalies + VEH registration,
  not byte-pattern scans.

## Complete working analysis

### A. Memory triage playbook (Volatility 3)

```bash
# orchestrated injection + fileless verdict (wraps the playbook below into one JSON)
python3 scripts/mem_triage.py -f mem.raw --vol vol --patch-hunt --json out/mem_verdict.json

# the underlying plugins:
vol -f mem.raw windows.malfind                 # injected/RWX unbacked regions
vol -f mem.raw windows.hollowprocesses         # process hollowing
vol -f mem.raw windows.processghosting         # ghosting
vol -f mem.raw windows.malware.pebmasquerade   # forged PEB image/cmdline
vol -f mem.raw windows.unhooked_system_calls   # tampered syscall stubs / direct syscalls
vol -f mem.raw windows.cmdline                 # full command lines (catch PS cradles)
vol -f mem.raw windows.netscan                 # live C2 endpoints
# hidden processes (DKOM): compare psscan vs pslist
diff <(vol -f mem.raw windows.psscan) <(vol -f mem.raw windows.pslist)
# dump a suspect region/process for static re-analysis
vol -f mem.raw -o out/ windows.vadinfo --pid 1337 --dump
```

`scripts/mem_triage.py` runs the full playbook, synthesizes a verdict (malfind/hollow/ghosting/
unhooked hits, DKOM-hidden PIDs from psscan−pslist), and with `--patch-hunt` scans malfind regions
for the AMSI/ETW patch stubs above.

### B. Fileless persistence & script-layer recovery

```bash
# PowerShell deobfuscated final layer (free if ScriptBlock logging was on)
#   Event ID 4104 (ScriptBlock), 4103 (module logging)
wevtutil qe "Microsoft-Windows-PowerShell/Operational" /q:"*[System[(EventID=4104)]]" /f:text

# WMI event-subscription persistence (no file on disk)
Get-WmiObject -Namespace root\Subscription -Class __EventFilter
Get-WmiObject -Namespace root\Subscription -Class CommandLineEventConsumer
Get-WmiObject -Namespace root\Subscription -Class __FilterToConsumerBinding
# from a dump / OBJECTS.DATA:
vol -f mem.raw windows.registry.printkey --key 'Software\Microsoft\Windows\CurrentVersion\Run'
python3 PyWMIPersistenceFinder.py OBJECTS.DATA
```

### C. Live behavioral capture (detonation)

```text
ProcMon filter: Operation in (WriteFile, RegSetValue, Process Create) AND Path contains \Run|\Tasks|\Services
Sysmon:         EID 1 (proc create + cmdline + hashes), 7 (image load), 8 (CreateRemoteThread),
                10 (process access + CallTrace), 11 (file create), 13 (reg set), 22 (DNS)
Network:        FakeNet-NG (auto-responds to C2) or INetSim; tcpdump/wireshark side capture
```

## Detection

- **Sigma — AMSI in-memory patch (process integrity / EDR memory scan):**

```yaml
title: AmsiScanBuffer In-Memory Patch
logsource: { product: windows, category: image_load }
detection:
  amsi_load: { ImageLoaded|endswith: '\amsi.dll' }
  # pair with EDR memory-scan telemetry: amsi.dll!AmsiScanBuffer prologue != on-disk
  condition: amsi_load
level: medium
tags: [attack.defense_evasion, attack.t1562.001]
```

- **Patchless bypass:** alert on processes that set debug registers (Dr0-Dr3) on `AmsiScanBuffer`
  address and register a VEH — visible via ETW `Microsoft-Windows-Threat-Intelligence` /
  `NtSetContextThread` on own threads. Byte-pattern scans will *not* catch it.
- **Injection:** Sysmon EID 8 (CreateRemoteThread) into lsass/explorer; EID 10 with `CallTrace`
  containing `UNKNOWN` (call from unbacked memory); malfind/PEScan in memory dumps.
- **Fileless persistence IOCs:** WMI `CommandLineEventConsumer`/`ActiveScriptEventConsumer` bound to
  `__IntervalTimerInstruction`; large binary Run-key values; scheduled task named like
  "Skype Updater"/"OneDrive Update" with a `powershell -enc` action.

## OPSEC

- **Capture memory BEFORE remediation** — fileless artifacts vanish on reboot/kill. Use a hardware
  or hypervisor acquisition (e.g. WinPmem, vmem snapshot) to avoid smearing.
- Detonation rules: isolated VM, snapshot first, FakeNet/INetSim instead of real network, revert
  after. Expect anti-VM/anti-sandbox (sleep, RAM/CPU/disk minimums, mouse-movement checks,
  domain-join checks) — patch sleeps or use a sandbox that fast-forwards time.
- Many 2025 loaders **self-delete** and run entirely in memory — your only evidence may be the dump;
  do not kill the process before dumping.
- Volatility analysis is on a captured image — passive and safe.

## References

- Volatility Foundation — *2025 Volatility Plugin Contest results* (PEScan, Fileless Hunter): https://volatilityfoundation.org/the-2025-volatility-plugin-contest-results-are-in/
- Hive Security — *Memory Forensics with Volatility 3: What Attackers Leave Behind* (2025 plugin map): https://hivesecurity.gitlab.io/blog/memory-forensics-volatility-attack-detect/
- CrowdStrike — *Patchless AMSI Bypass Attacks* (hardware breakpoint + VEH): https://www.crowdstrike.com/en-us/blog/crowdstrike-investigates-threat-of-patchless-amsi-bypass-attacks/
- SonicWall — *Remcos RAT Targets Europe: New AMSI and ETW Evasion Tactics* (B8 00.. C3 patch): https://www.sonicwall.com/blog/remcos-rat-targets-europe-new-amsi-and-etw-evasion-tactics-uncovered
- Sofecta Labs — *Threat Hunting: Detecting AMSI Bypass and AsyncRAT Deployment* (4103/4104): https://www.sofectalabs.io/blog/threat-hunting-detecting-amsi-bypass-and-asyncrat-deployment
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall