AGENT SKILL

forensics-memory-analysis-volatility3-plugins-linux-processes-exploit

Process forensic reconnaissance. Parent-child tree anomalies, injected memory regions (RWX), deleted executables, LD_PRELOAD/VDSO abuse, ptrace attach state, capability audit, namespaces, and runtime behavior triage.

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

01 前言 Front Matter

name
forensics-memory-analysis-volatility3-plugins-linux-processes-exploit
tags
[ "forensics", "memory", "analysis", "volatility3", "plugins", "linux", "processes", "processes-recon" ]
capec
[]
model
sonnet
tools
[ "Read", "Bash", "Glob", "Grep", "WebSearch" ]
skills
[ "shared-memory", "threats/mitre-attack-mapper" ]
maxTurns
30
nist_csf
[]
description
Process forensic reconnaissance. Parent-child tree anomalies, injected memory regions (RWX), deleted executables, LD_PRELOAD/VDSO abuse, ptrace attach state, capability audit, namespaces, and runtime behavior triage.
mitre_attack
[ "T1014", "T1055.008", "T1595" ]

02 资源文件 1

03 SKILL.md 正文

Process Recon

Purpose: Live process triage with behavior, lineage, and memory-injection focus. Detects rootkit-hidden processes, injected code, and unusual privilege escalation at runtime.


Core Focus Areas

  • Process tree anomalies: Unexpected parent-child relationships, orphaned processes
  • Injected memory regions: RWX memory mappings, anonymous executable mappings
  • Deleted executables: Processes running from deleted binaries (/proc/<pid>/exe (deleted))
  • LD_PRELOAD/VDSO abuse: Library injection via environment or /etc/ld.so.preload
  • Capability audit: Processes with excessive Linux capabilities
  • Namespace isolation: Unexpected PID/network/mount namespaces
  • ptrace state: Processes under active debugger attachment
  • Hidden processes: PID gaps between /proc and ps output

Key Techniques & Tools

Process Tree & Lineage

# Full process tree with PID/PPID/command
ps auxf 2>/dev/null | head -50
pstree -apnl 2>/dev/null | head -50

# Orphaned processes (PPID=1 but not expected)
ps -eo pid,ppid,comm,args --no-headers 2>/dev/null | \
  awk '$2==1 && $3!="systemd" && $3!="init"' | head -20

# Processes with unusual parent (e.g. shell spawned by webserver)
ps -eo pid,ppid,comm,user,args --no-headers 2>/dev/null | \
  awk '$4=="www-data" || $4=="apache" || $4=="nginx" {print}' | head -10

# Processes in unexpected user contexts
ps -eo pid,user,comm,args --no-headers 2>/dev/null | \
  grep -v "^[[:space:]]*[0-9]* root\|daemon\|dbus\|polkitd" | head -20

Injected Memory Detection

# RWX memory regions (classic injection indicator)
for pid in $(ps -eo pid --no-headers); do
  cat /proc/$pid/maps 2>/dev/null | \
    awk '/rwxp/{print FILENAME": "$0}' FILENAME="/proc/$pid/maps" | head -2
done | grep "rwxp" | head -20

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

# pmap — detailed memory layout
pmap -x <PID> 2>/dev/null | grep -E "rwx|--x"

Deleted Executables & LD_PRELOAD

# Processes running from deleted files (malware/rootkit technique)
ls -la /proc/*/exe 2>/dev/null | grep "(deleted)" | \
  while read line; do
    pid=$(echo "$line" | grep -oE '/proc/[0-9]+' | head -1 | tr -d '/proc/')
    cmd=$(cat /proc/$pid/cmdline 2>/dev/null | tr '\0' ' ')
    echo "DELETED EXEC: PID $pid → $cmd"
  done

# LD_PRELOAD set in any process environment
grep -r "LD_PRELOAD\|LD_LIBRARY_PATH" /proc/*/environ 2>/dev/null | \
  tr '\0' '\n' | grep -v "^Binary" | head -20

# /etc/ld.so.preload (system-wide injection)
cat /etc/ld.so.preload 2>/dev/null && \
  echo "⚠ /etc/ld.so.preload EXISTS" || echo "OK: /etc/ld.so.preload not found"

# Open library files — spot injected .so files
lsof 2>/dev/null | grep "\.so" | \
  grep -v "^lsof\|/usr/lib\|/usr/local/lib\|/lib" | head -20

Capability Audit

# Processes with elevated capabilities
for pid in $(ps -eo pid --no-headers); do
  caps=$(cat /proc/$pid/status 2>/dev/null | grep "^Cap" | awk '{print $2}')
  comm=$(cat /proc/$pid/comm 2>/dev/null)
  # CapEff non-zero on non-root process
  eff=$(echo "$caps" | grep "CapEff" | awk '{print $2}')
  [ "$eff" != "0000000000000000" ] && [ -n "$eff" ] && \
    echo "CAPS: PID $pid ($comm) CapEff=$eff"
done 2>/dev/null | head -20

# Detailed capability decode
getpcaps $(ps -eo pid --no-headers | tr -d ' ') 2>/dev/null | \
  grep -v "= $\|: $" | head -20

Namespace & Container Anomalies

# Check process namespaces vs PID 1 (different = isolated/containerized)
ls -la /proc/1/ns/ 2>/dev/null
for pid in $(ps -eo pid --no-headers | tr -d ' ' | head -20); do
  diff <(ls -la /proc/1/ns/ 2>/dev/null | awk '{print $11}') \
       <(ls -la /proc/$pid/ns/ 2>/dev/null | awk '{print $11}') | \
    grep "^<\|^>" | grep -v "^---" | \
    awk -v pid=$pid '{print "DIFF NS PID " pid ": " $0}'
done 2>/dev/null | head -20

# lsns — list all namespaces
lsns 2>/dev/null | head -20

# Unexpected network namespaces
ip netns list 2>/dev/null

ptrace & Debugger State

# Processes currently being ptrace'd (debugger attached)
for pid in $(ps -eo pid --no-headers); do
  ptrace=$(cat /proc/$pid/status 2>/dev/null | grep "TracerPid" | awk '{print $2}')
  [ "$ptrace" != "0" ] && [ -n "$ptrace" ] && \
    echo "TRACED: PID $pid by PID $ptrace ($(cat /proc/$ptrace/comm 2>/dev/null))"
done | head -10

# Check ptrace scope
cat /proc/sys/kernel/yama/ptrace_scope 2>/dev/null

Hidden Process Detection

# Compare /proc PIDs vs ps output (rootkit detection)
comm -23 \
  <(ls /proc | grep -E '^[0-9]+$' | sort -n) \
  <(ps -eo pid --no-headers | tr -d ' ' | sort -n) | \
  while read hidden_pid; do
    echo "HIDDEN PID: $hidden_pid"
    cat /proc/$hidden_pid/cmdline 2>/dev/null | tr '\0' ' '
    echo
  done

# unhide — dedicated hidden process scanner
sudo unhide proc 2>/dev/null | head -20
sudo unhide-tcp 2>/dev/null | head -20

Resource & Open File Audit

# Processes with many open files (exfil or data staging)
lsof 2>/dev/null | awk 'NR>1 {print $2}' | sort | uniq -c | sort -rn | head -10

# Processes with network sockets + unusual binary path
lsof -i 2>/dev/null | \
  grep -v "^lsof\|sshd\|chrome\|firefox\|brave\|systemd" | head -20

# Processes running from /tmp, /dev/shm, or home dir (suspicious)
ls -la /proc/*/exe 2>/dev/null | \
  grep -E "/tmp/|/dev/shm/|/home/|/var/tmp/" | head -10

MITRE ATT&CK Mapping

Finding Technique
RWX anonymous memory region T1055 – Process Injection
LD_PRELOAD set on process T1574.006 – Dynamic Linker Hijacking
/etc/ld.so.preload modified T1574.006 – Dynamic Linker Hijacking
Deleted executable still running T1070.004 – File Deletion
Hidden process (PID gap) T1014 – Rootkit
Process with unexpected capabilities T1548 – Abuse Elevation Control Mechanism
ptrace from unexpected process T1055.008 – Ptrace System Calls
Shell spawned by web process T1059 – Command and Scripting Interpreter

Rules for Agents

  1. ANY process running from a deleted binary = HIGH — escalate immediately
  2. /etc/ld.so.preload exists = CRITICAL rootkit indicator
  3. RWX anonymous mappings = HIGH — dump and analyse with @memory-analyst
  4. PID gaps (hidden process) = CRITICAL — run unhide and escalate
  5. Log all anomalous PIDs with cmdline, PPID, user, and binary path to iocs.md
  6. Cross-validate with @kernel-analyst for DKOM/eBPF hiding techniques
  7. Sync all process IOCs to shared memory at session end

04 同仓库更多 Skills