AGENT SKILL

forensics-memory-analysis-volatility3-detect

Linux volatile memory forensics. Process injection detection (RWX regions, hollowing, reflective loading), memory-resident malware, DKOM rootkit indicators, heap/stack anomalies, kernel memory integrity, and credential extraction patterns.

License 许可
MIT
最近更新
2026-09-01
Stars
★ 0
Forks
0

01 前言 Front Matter

name
forensics-memory-analysis-volatility3-detect
tags
[ "forensics", "memory", "analysis", "volatility3", "memory-recon" ]
capec
[]
model
sonnet
tools
[ "Read", "Bash", "Glob", "Grep", "WebSearch" ]
skills
[ "shared-memory", "threats/mitre-attack-mapper" ]
maxTurns
30
nist_csf
[]
description
Linux volatile memory forensics. Process injection detection (RWX regions, hollowing, reflective loading), memory-resident malware, DKOM rootkit indicators, heap/stack anomalies, kernel memory integrity, and credential extraction patterns.
mitre_attack
[ "T1003", "T1014", "T1027", "T1059", "T1595" ]

02 资源文件 1

03 SKILL.md 正文

Memory Recon

Purpose: Volatile memory forensics specialist. Detects injection, memory-only malware, rootkit DKOM manipulation, kernel memory anomalies, and credential artifacts in live memory.


Core Focus Areas

  • Process injection: RWX regions, anonymous executable mappings, reflective DLL/ELF loading
  • Process hollowing: Mismatched on-disk vs in-memory image content
  • Memory-resident malware: No-disk-artifact payloads, fileless execution
  • DKOM rootkits: Direct Kernel Object Manipulation, hidden tasks via task_struct unlink
  • Kernel memory integrity: Syscall table hooks, function pointer overwrites, IDT manipulation
  • Credential artifacts: Password hashes, tokens, SSH keys, TLS private keys in heap
  • Heap/stack anomalies: Heap spray patterns, stack pivoting indicators
  • eBPF program maps: Suspicious eBPF programs with map-based exfil

Key Techniques & Tools

Live Memory Mapping Analysis

# RWX regions across all processes
for pid in $(ps -eo pid --no-headers | tr -d ' '); do
  grep "rwxp" /proc/$pid/maps 2>/dev/null | \
    awk -v pid=$pid '{print "RWX PID " pid ": " $0}'
done | head -30

# Anonymous executable mappings (shellcode / fileless)
for pid in $(ps -eo pid --no-headers | tr -d ' '); do
  awk '/^[0-9a-f].* x.* $/{print FILENAME" anon-exec: "$0}' \
    /proc/$pid/maps 2>/dev/null
done | head -20

# Suspicious shared memory objects
ls -la /dev/shm/ 2>/dev/null
ipcs -m 2>/dev/null  # SysV shared memory segments

# Processes with very large anonymous memory regions (heap spray)
for pid in $(ps -eo pid --no-headers | tr -d ' '); do
  anon_kb=$(awk '/^[0-9a-f].* [rw-][w-][x-]p / && $6=="" {
    split($1,a,"-"); kb=strtonum("0x"a[2])-strtonum("0x"a[1]); total+=kb/1024
  } END{print total}' /proc/$pid/maps 2>/dev/null)
  comm=$(cat /proc/$pid/comm 2>/dev/null)
  [ "${anon_kb%.*}" -gt 500 ] 2>/dev/null && echo "LARGE ANON $anon_kb KB: PID $pid ($comm)"
done 2>/dev/null | head -10

Process Memory Dump

# Dump specific process memory regions
gcore -o /tmp/proc_dump <PID> 2>/dev/null

# Dump via /proc/mem (requires appropriate permissions)
python3 -c "
import sys
pid = int(sys.argv[1]) if len(sys.argv)>1 else None
if not pid: print('Usage: script.py <PID>'); exit()
maps = open(f'/proc/{pid}/maps').readlines()
mem = open(f'/proc/{pid}/mem', 'rb', 0)
for line in maps:
    parts = line.split()
    if 'rwxp' not in parts[1]: continue
    start, end = [int(x,16) for x in parts[0].split('-')]
    mem.seek(start); data = mem.read(end-start)
    open(f'/tmp/dump_{pid}_{hex(start)}.bin','wb').write(data)
    print(f'Dumped {end-start} bytes from {hex(start)}-{hex(end)}')
mem.close()
" <PID> 2>/dev/null

# strings extraction from heap
strings /proc/<PID>/mem 2>/dev/null | \
  grep -iE "(password|passwd|secret|token|key|BEGIN|ssh-rsa)" | head -20

Credential Artifacts in Memory

# Search all process memory for credential patterns
for pid in $(ps -eo pid --no-headers | tr -d ' '); do
  strings /proc/$pid/mem 2>/dev/null | \
    grep -iE "(password|passwd|secret|api_key|bearer|eyJ|ssh-rsa|BEGIN.*PRIVATE)" | \
    head -3 | awk -v pid=$pid '{print "CRED PID " pid ": " $0}'
done 2>/dev/null | head -30

# Browser memory — session tokens
for pid in $(pgrep -x "chrome\|chromium\|brave\|firefox" 2>/dev/null); do
  strings /proc/$pid/mem 2>/dev/null | \
    grep -oE 'eyJ[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}' | \
    head -3 | awk -v pid=$pid '{print "JWT PID " pid ": " $0}'
done 2>/dev/null | head -10

# SSH agent keys in memory
strings /proc/$(pgrep ssh-agent)/mem 2>/dev/null | \
  grep -A2 "BEGIN.*PRIVATE\|RSA PRIVATE\|EC PRIVATE" | head -20

Kernel Memory Analysis

# /proc/kcore — kernel virtual address space
strings /proc/kcore 2>/dev/null | \
  grep -iE "(rootkit|hide|hook|intercept)" | head -10

# Kernel symbol table — detect modified addresses
cat /proc/kallsyms 2>/dev/null | grep -E "^[0-9a-f]{16} [tT] (sys_call_table|idt_table|nf_hooks)" | head -10

# Live syscall table check (via kernel module or bpftool)
bpftool prog list 2>/dev/null | head -20  # loaded eBPF programs

# Loaded kernel modules (compare against baseline)
lsmod 2>/dev/null | sort > /tmp/modules_live.txt
diff ./cybersec-shared/baselines/kernel.md /tmp/modules_live.txt 2>/dev/null | head -20

# Hidden kernel modules (in memory but not in lsmod)
cat /proc/modules 2>/dev/null | awk '{print $1}' | sort > /tmp/kmod_proc.txt
lsmod 2>/dev/null | awk 'NR>1 {print $1}' | sort > /tmp/kmod_lsmod.txt
comm -23 /tmp/kmod_proc.txt /tmp/kmod_lsmod.txt | head -10

eBPF Forensics

# List all loaded eBPF programs
bpftool prog list 2>/dev/null

# eBPF programs with suspicious names or types
bpftool prog list 2>/dev/null | grep -iE "(kprobe|tracepoint|sock|xdp|perf)" | head -20

# eBPF maps (potential data exfil channel)
bpftool map list 2>/dev/null | head -20

# Pinned eBPF objects (persistence mechanism)
find /sys/fs/bpf -type f 2>/dev/null | head -20

# eBPF prog details + bytecode inspection
bpftool prog dump xlated id <PROG_ID> 2>/dev/null | head -30

Volatility Framework (Offline/Memory Image)

# Profile detection (if image available)
volatility -f /tmp/memory.img imageinfo 2>/dev/null

# Process list (detect DKOM-hidden processes)
volatility -f /tmp/memory.img --profile=Linux linux_pslist 2>/dev/null | head -20
volatility -f /tmp/memory.img --profile=Linux linux_pstree 2>/dev/null | head -20

# Modules (detect hidden LKMs)
volatility -f /tmp/memory.img --profile=Linux linux_lsmod 2>/dev/null | head -20

# Check syscall table hooks
volatility -f /tmp/memory.img --profile=Linux linux_check_syscall 2>/dev/null

# Check IDT for hooks
volatility -f /tmp/memory.img --profile=Linux linux_check_idt 2>/dev/null

# Network connections from memory
volatility -f /tmp/memory.img --profile=Linux linux_netstat 2>/dev/null | head -20

# String search in memory image
volatility -f /tmp/memory.img strings --string-file=/tmp/ioc_strings.txt 2>/dev/null | head -20

MITRE ATT&CK Mapping

Finding Technique
RWX anonymous memory region T1055 – Process Injection
Process hollowing (mismatched image) T1055.012 – Process Hollowing
Memory-only payload (no disk artifact) T1027.011 – Fileless Storage
Syscall table hook T1014 – Rootkit
DKOM hidden task T1014 – Rootkit
eBPF exfil/C2 map T1071 – Application Layer Protocol
Credential strings in heap T1003 – OS Credential Dumping
eBPF tracepoint keylogger T1056.001 – Keylogging

Rules for Agents

  1. RWX anonymous mappings = HIGH — dump region and pass to @reverse-engineer
  2. DKOM-hidden processes confirmed = CRITICAL — escalate immediately
  3. Credentials found in memory = HIGH — redact values, log type and PID only in iocs.md
  4. Suspicious eBPF programs = HIGH — dump and analyse bytecode
  5. Always pair with @kernel-analyst for kernel-level confirmation
  6. Heavy root usage expected — always verify AgentRootPermission before /proc/mem access
  7. Sync all memory IOCs to shared memory at session end

04 同仓库更多 Skills