memory-forensics
Master memory forensics techniques including memory acquisition, process analysis, and artifact extraction using Volatility and related tools. Use when analyzing memory dumps, investigating incidents, or performing malware analysis from RAM captures.
Memory Forensics
Comprehensive techniques for acquiring, analyzing, and extracting artifacts from memory dumps for incident response and malware analysis.
Use this skill when
Do not use this skill when
Instructions
resources/implementation-playbook.md.Memory Acquisition
Live Acquisition Tools
Windows
# WinPmem (Recommended)
winpmem_mini_x64.exe memory.rawDumpIt
DumpIt.exeBelkasoft RAM Capturer
GUI-based, outputs raw format
Magnet RAM Capture
GUI-based, outputs raw format
Linux
# LiME (Linux Memory Extractor)
sudo insmod lime.ko "path=/tmp/memory.lime format=lime"/dev/mem (limited, requires permissions)
sudo dd if=/dev/mem of=memory.raw bs=1M/proc/kcore (ELF format)
sudo cp /proc/kcore memory.elfmacOS
# osxpmem
sudo ./osxpmem -o memory.rawMacQuisition (commercial)
Virtual Machine Memory
# VMware: .vmem file is raw memory
cp vm.vmem memory.rawVirtualBox: Use debug console
vboxmanage debugvm "VMName" dumpvmcore --filename memory.elfQEMU
virsh dump <domain> memory.raw --memory-onlyHyper-V
Checkpoint contains memory state
Volatility 3 Framework
Installation and Setup
# Install Volatility 3
pip install volatility3Install symbol tables (Windows)
Download from https://downloads.volatilityfoundation.org/volatility3/symbols/
Basic usage
vol -f memory.raw <plugin>With symbol path
vol -f memory.raw -s /path/to/symbols windows.pslistEssential Plugins
Process Analysis
# List processes
vol -f memory.raw windows.pslistProcess tree (parent-child relationships)
vol -f memory.raw windows.pstreeHidden process detection
vol -f memory.raw windows.psscanProcess memory dumps
vol -f memory.raw windows.memmap --pid <PID> --dumpProcess environment variables
vol -f memory.raw windows.envars --pid <PID>Command line arguments
vol -f memory.raw windows.cmdlineNetwork Analysis
# Network connections
vol -f memory.raw windows.netscanNetwork connection state
vol -f memory.raw windows.netstatDLL and Module Analysis
# Loaded DLLs per process
vol -f memory.raw windows.dlllist --pid <PID>Find hidden/injected DLLs
vol -f memory.raw windows.ldrmodulesKernel modules
vol -f memory.raw windows.modulesModule dumps
vol -f memory.raw windows.moddump --pid <PID>Memory Injection Detection
# Detect code injection
vol -f memory.raw windows.malfindVAD (Virtual Address Descriptor) analysis
vol -f memory.raw windows.vadinfo --pid <PID>Dump suspicious memory regions
vol -f memory.raw windows.vadyarascan --yara-rules rules.yarRegistry Analysis
# List registry hives
vol -f memory.raw windows.registry.hivelistPrint registry key
vol -f memory.raw windows.registry.printkey --key "Software\Microsoft\Windows\CurrentVersion\Run"Dump registry hive
vol -f memory.raw windows.registry.hivescan --dumpFile System Artifacts
# Scan for file objects
vol -f memory.raw windows.filescanDump files from memory
vol -f memory.raw windows.dumpfiles --pid <PID>MFT analysis
vol -f memory.raw windows.mftscanLinux Analysis
# Process listing
vol -f memory.raw linux.pslistProcess tree
vol -f memory.raw linux.pstreeBash history
vol -f memory.raw linux.bashNetwork connections
vol -f memory.raw linux.sockstatLoaded kernel modules
vol -f memory.raw linux.lsmodMount points
vol -f memory.raw linux.mountEnvironment variables
vol -f memory.raw linux.envarsmacOS Analysis
# Process listing
vol -f memory.raw mac.pslistProcess tree
vol -f memory.raw mac.pstreeNetwork connections
vol -f memory.raw mac.netstatKernel extensions
vol -f memory.raw mac.lsmodAnalysis Workflows
Malware Analysis Workflow
# 1. Initial process survey
vol -f memory.raw windows.pstree > processes.txt
vol -f memory.raw windows.pslist > pslist.txt2. Network connections
vol -f memory.raw windows.netscan > network.txt3. Detect injection
vol -f memory.raw windows.malfind > malfind.txt4. Analyze suspicious processes
vol -f memory.raw windows.dlllist --pid <PID>
vol -f memory.raw windows.handles --pid <PID>5. Dump suspicious executables
vol -f memory.raw windows.pslist --pid <PID> --dump6. Extract strings from dumps
strings -a pid.<PID>.exe > strings.txt7. YARA scanning
vol -f memory.raw windows.yarascan --yara-rules malware.yarIncident Response Workflow
# 1. Timeline of events
vol -f memory.raw windows.timeliner > timeline.csv2. User activity
vol -f memory.raw windows.cmdline
vol -f memory.raw windows.consoles3. Persistence mechanisms
vol -f memory.raw windows.registry.printkey \
--key "Software\Microsoft\Windows\CurrentVersion\Run"4. Services
vol -f memory.raw windows.svcscan5. Scheduled tasks
vol -f memory.raw windows.scheduled_tasks6. Recent files
vol -f memory.raw windows.filescan | grep -i "recent"Data Structures
Windows Process Structures
// EPROCESS (Executive Process)
typedef struct _EPROCESS {
KPROCESS Pcb; // Kernel process block
EX_PUSH_LOCK ProcessLock;
LARGE_INTEGER CreateTime;
LARGE_INTEGER ExitTime;
// ...
LIST_ENTRY ActiveProcessLinks; // Doubly-linked list
ULONG_PTR UniqueProcessId; // PID
// ...
PEB Peb; // Process Environment Block
// ...
} EPROCESS;// PEB (Process Environment Block)
typedef struct _PEB {
BOOLEAN InheritedAddressSpace;
BOOLEAN ReadImageFileExecOptions;
BOOLEAN BeingDebugged; // Anti-debug check
// ...
PVOID ImageBaseAddress; // Base address of executable
PPEB_LDR_DATA Ldr; // Loader data (DLL list)
PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
// ...
} PEB;
VAD (Virtual Address Descriptor)
typedef struct _MMVAD {
MMVAD_SHORT Core;
union {
ULONG LongFlags;
MMVAD_FLAGS VadFlags;
} u;
// ...
PVOID FirstPrototypePte;
PVOID LastContiguousPte;
// ...
PFILE_OBJECT FileObject;
} MMVAD;// Memory protection flags
#define PAGE_EXECUTE 0x10
#define PAGE_EXECUTE_READ 0x20
#define PAGE_EXECUTE_READWRITE 0x40
#define PAGE_EXECUTE_WRITECOPY 0x80
Detection Patterns
Process Injection Indicators
# Malfind indicators
- PAGE_EXECUTE_READWRITE protection (suspicious)
- MZ header in non-image VAD region
- Shellcode patterns at allocation start
Common injection techniques
1. Classic DLL Injection
- VirtualAllocEx + WriteProcessMemory + CreateRemoteThread
2. Process Hollowing
- CreateProcess (SUSPENDED) + NtUnmapViewOfSection + WriteProcessMemory
3. APC Injection
- QueueUserAPC targeting alertable threads
4. Thread Execution Hijacking
- SuspendThread + SetThreadContext + ResumeThread
Rootkit Detection
# Compare process lists
vol -f memory.raw windows.pslist > pslist.txt
vol -f memory.raw windows.psscan > psscan.txt
diff pslist.txt psscan.txt # Hidden processesCheck for DKOM (Direct Kernel Object Manipulation)
vol -f memory.raw windows.callbacksDetect hooked functions
vol -f memory.raw windows.ssdt # System Service Descriptor TableDriver analysis
vol -f memory.raw windows.driverscan
vol -f memory.raw windows.driverirpCredential Extraction
# Dump hashes (requires hivelist first)
vol -f memory.raw windows.hashdumpLSA secrets
vol -f memory.raw windows.lsadumpCached domain credentials
vol -f memory.raw windows.cachedumpMimikatz-style extraction
Requires specific plugins/tools
YARA Integration
Writing Memory YARA Rules
rule Suspicious_Injection
{
meta:
description = "Detects common injection shellcode" strings:
// Common shellcode patterns
$mz = { 4D 5A }
$shellcode1 = { 55 8B EC 83 EC } // Function prologue
$api_hash = { 68 ?? ?? ?? ?? 68 ?? ?? ?? ?? E8 } // Push hash, call
condition:
$mz at 0 or any of ($shellcode)
}
rule Cobalt_Strike_Beacon
{
meta:
description = "Detects Cobalt Strike beacon in memory"
strings:
$config = { 00 01 00 01 00 02 }
$sleep = "sleeptime"
$beacon = "%s (admin)" wide
condition:
2 of them
}
Scanning Memory
# Scan all process memory
vol -f memory.raw windows.yarascan --yara-rules rules.yarScan specific process
vol -f memory.raw windows.yarascan --yara-rules rules.yar --pid 1234Scan kernel memory
vol -f memory.raw windows.yarascan --yara-rules rules.yar --kernelString Analysis
Extracting Strings
# Basic string extraction
strings -a memory.raw > all_strings.txtUnicode strings
strings -el memory.raw >> all_strings.txtTargeted extraction from process dump
vol -f memory.raw windows.memmap --pid 1234 --dump
strings -a pid.1234.dmp > process_strings.txtPattern matching
grep -E "(https?://|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})" all_strings.txtFLOSS for Obfuscated Strings
# FLOSS extracts obfuscated strings
floss malware.exe > floss_output.txtFrom memory dump
floss pid.1234.dmp