Memory Forensics with Volatility 3
A disk image shows what was stored; a memory image shows what was running: processes and their command lines, network connections, loaded DLLs, injected code, decrypted configurations, command history, even encryption keys. Fileless malware may exist only there. And memory is the one place where hiding is hard: a rootkit can remove a process from the list the operating system shows, but the process's structures are still in RAM for a scanner to find. Volatility is the standard open-source framework for analysing memory images; version 3 (Python 3, a rewrite of the retired Volatility 2) is current.
Definitions
- Memory acquisition: copying physical RAM to a file on a running system: WinPmem, DumpIt or Magnet RAM Capture on Windows; AVML or LiME on Linux; or the hypervisor's snapshot of a VM (VMware
.vmem, a QEMU dump). Hibernation files (hiberfil.sys) and crash dumps hold memory too. - Volatility 3:
vol -f image.raw <plugin>; plugins are named by OS:windows.pslist,windows.pstree,windows.psscan,windows.cmdline,windows.dlllist,windows.handles,windows.netscan,windows.malfind,windows.filescan,windows.registry.printkey,linux.pslist,linux.bash, and many more. It needs symbol tables for the exact OS build (downloaded automatically for Windows from Microsoft's symbol server when online, or provided offline; built withdwarf2jsonfor Linux kernels).-r csvor-r jsongives machine-readable output. - List walking vs scanning:
pslistfollows the kernel's linked list of processes (what Task Manager sees);psscanscans all of memory for process structures, finding exited processes and ones unlinked from the list by a rootkit. malfind: lists memory regions that are private, executable and writable (or were), with a hex dump: typical of injected or unpacked code.
A lab session
Scope: a memory image taken with the hypervisor's snapshot of the isolated analysis VM (10.10.0.20, Windows 10 lab build) two minutes after the benign lab sample labagent.exe started. The output is shortened (columns and rows trimmed, offsets abbreviated); it is an illustration of the plugins' output on a lab image, not a run you can repeat here.
lab session: Volatility 3 on a lab memory image (analysis VM, benign lab sample)
$ vol -q -f lab-win10.vmem windows.pstree
PID PPID ImageFileName CreateTime
4 0 System 2026-01-15 09:58:01
* 532 4 smss.exe 2026-01-15 09:58:01
644 620 csrss.exe 2026-01-15 09:58:03
716 620 wininit.exe 2026-01-15 09:58:03
* 852 716 services.exe 2026-01-15 09:58:03
** 1040 852 svchost.exe 2026-01-15 09:58:04
* 868 716 lsass.exe 2026-01-15 09:58:03
1204 1180 explorer.exe 2026-01-15 09:59:12
* 4512 1204 labagent.exe 2026-01-15 10:04:12
** 4630 4512 cmd.exe 2026-01-15 10:04:12
$ vol -q -f lab-win10.vmem windows.cmdline --pid 4512 4630
PID Process Args
4512 labagent.exe "C:\Users\lab\Downloads\labagent.exe"
4630 cmd.exe cmd.exe /c whoami /all > "C:\Users\lab\AppData\Local\Temp\w.txt"
$ vol -q -f lab-win10.vmem windows.netscan | grep -e Proto -e 4512
Offset Proto LocalAddr LocalPort ForeignAddr ForeignPort State PID Owner
0x…a10 TCPv4 10.10.0.20 49712 10.10.0.53 80 CLOSE_WAIT 4512 labagent.exe
$ vol -q -f lab-win10.vmem windows.malfind --pid 4512
PID Process Start VPN End VPN Tag Protection CommitCharge PrivateMemory
4512 labagent.exe 0x1d0f0000 0x1d0f0fff VadS PAGE_EXECUTE_READWRITE 1 1
4d 5a 90 00 03 00 00 00 04 00 00 00 ff ff 00 00 MZ..............
b8 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 ........@.......Reading it as an analyst:
pstreegives the story in one look:labagent.exestarted byexplorer.exe(a user double-click), and it startedcmd.exe. The system processes have their expected parents (services.exeunderwininit.exe,svchost.exeunderservices.exe, onelsass.exe).csrss.exe,wininit.exeandexplorer.exesit at the top level because their parents (a per-session copy ofsmss.exe, PID 620, anduserinit.exe, PID 1180) exit after starting them, which is normal.cmdlineshows where the program ran from and what the child did.netscanties the connection to the process, which network logs alone can't do.malfindfinds a private, executable and writable region inlabagent.exethat starts withMZ: a PE image placed in memory by the program itself, not loaded from disk. In a real case this is where the unpacked payload would be; dump it (windows.malfind --dumporwindows.vadinfo --dump) and analyse it with YARA and static tools.
Finding anomalies in process lists
Analysts don't read process lists line by line on every case; they check rules that legitimate Windows follows. The example applies four of them to a synthetic export (as from -r csv) of pslist and psscan from a different lab image, where a lab scenario hid one process and disguised another.
import pandas as pd
from io import StringIO
pslist = pd.read_csv(StringIO("""pid,ppid,name,path
4,0,System,
532,4,smss.exe,C:\\Windows\\System32\\smss.exe
716,532,wininit.exe,C:\\Windows\\System32\\wininit.exe
852,716,services.exe,C:\\Windows\\System32\\services.exe
868,716,lsass.exe,C:\\Windows\\System32\\lsass.exe
1040,852,svchost.exe,C:\\Windows\\System32\\svchost.exe
1204,1180,explorer.exe,C:\\Windows\\explorer.exe
3100,1204,svchost.exe,C:\\Users\\Public\\svchost.exe
3320,1204,scvhost.exe,C:\\Windows\\System32\\scvhost.exe
"""))
psscan = pd.concat([pslist, pd.DataFrame([
{"pid": 3900, "ppid": 1204, "name": "labhide.exe", "path": "C:\\Users\\lab\\AppData\\Roaming\\labhide.exe"}])])
EXPECTED_PARENT = {"svchost.exe": "services.exe", "services.exe": "wininit.exe", "lsass.exe": "wininit.exe"}
EXPECTED_DIR = "c:\\windows\\system32\\"
names = dict(zip(psscan.pid, psscan.name))
hidden = set(psscan.pid) - set(pslist.pid)
for pid in sorted(hidden):
print(f"HIDDEN pid {pid} {names[pid]}: found by psscan, missing from pslist (unlinked?)")
for _, p in pslist.iterrows():
parent = names.get(p.ppid, "?")
if p["name"] in EXPECTED_PARENT and parent != EXPECTED_PARENT[p["name"]]:
print(f"PARENT pid {p.pid} {p['name']} has parent {parent}, expected {EXPECTED_PARENT[p['name']]}")
if p["name"] in EXPECTED_PARENT and not str(p.path).lower().startswith(EXPECTED_DIR):
print(f"PATH pid {p.pid} {p['name']} runs from {p.path}")
for real in EXPECTED_PARENT:
if p["name"] != real and len(p["name"]) == len(real) and sorted(p["name"]) == sorted(real):
print(f"LOOKALIKE pid {p.pid} {p['name']} resembles {real}")
print("lsass instances:", int((pslist.name == "lsass.exe").sum()), "(expected exactly 1)")HIDDEN pid 3900 labhide.exe: found by psscan, missing from pslist (unlinked?)
PARENT pid 3100 svchost.exe has parent explorer.exe, expected services.exe
PATH pid 3100 svchost.exe runs from C:\Users\Public\svchost.exe
LOOKALIKE pid 3320 scvhost.exe resembles svchost.exe
lsass instances: 1 (expected exactly 1)
Each rule catches one classic disguise: a process unlinked from the list (found only by scanning), a svchost.exe whose parent is explorer.exe and whose path is C:\Users\Public (the real one always runs from System32 under services.exe), and scvhost.exe, two letters swapped. These are lab constructions, but the rules come straight from how real investigations triage memory.
How memory evidence is used in detection
- YARA over memory:
vol windows.vadyarascan --yara-file rules.yar(oryarascan) finds family strings in unpacked payloads that exist on disk only in encrypted form (YARA). - EDR memory scanning applies the same idea continuously on endpoints.
- Configuration extraction: frameworks (CAPE's extractors, community parsers) pull C2 addresses and keys from dumped memory of known families.
How to make memory forensics possible
- Plan acquisition: tested tools in the response kit, enough disk space (the image is as large as RAM), and a decision rule for when to capture memory (before isolating or rebooting a host where live malware is suspected).
- Prefer hypervisor snapshots for VMs: no tool runs inside the guest.
- Keep symbol files available offline for the OS builds you run, so analysis doesn't depend on Internet access during an incident.
Pitfalls
- Acquisition changes memory. The tool itself is loaded into RAM; document the tool and version, and accept the small footprint.
- Smear: memory changes while it is being copied, so structures can be inconsistent; expect occasional garbage and corroborate.
- Wrong symbols give empty or nonsense output; check
windows.infofirst. malfindfalse positives: just-in-time compilers (browsers, .NET, Java) legitimately create executable writable memory; judge by content and process.
Practice
1. Why can psscan find a process that pslist can't?
pslist walks the kernel's doubly linked list of process structures, which a rootkit can unlink a process from. psscan searches all of memory for the structures by their signature, so unlinked (and recently exited) processes still appear.
2. Add a rule to the example: more than one lsass.exe is an alert.
if (pslist.name == "lsass.exe").sum() != 1: print("LSASS count anomaly"). A second lsass.exe (often with a wrong parent or path) is a classic disguise.
3. A browser process shows ten PAGE_EXECUTE_READWRITE regions in malfind. Is the browser compromised?
Not necessarily: JavaScript engines' JIT compilers create such regions. Look at the content (an MZ header or known shellcode-like patterns in a non-JIT process is different), scan the regions with YARA, and compare with a clean baseline of the same browser.
Test yourself
Which Volatility 3 plugin scans memory for process structures instead of walking the process list?
- windows.pslist
- windows.psscan
- windows.cmdline
- windows.info
What does windows.malfind look for?
- Deleted files
- Private memory regions that are executable and writable, typical of injected or unpacked code
- Registry keys
- Network shares
What is the legitimate parent of svchost.exe on Windows?
- explorer.exe
- services.exe
- lsass.exe
- cmd.exe
Which tool acquires memory on Linux?
- AVML or LiME
- Sysmon
- ssdeep
- Regshot