mcpField
C
collecting-volatile-evidence-from-compromised-host

collecting-volatile-evidence-from-compromised-host

github.com/mukul975安全35.2k143 次安装8 周前更新
代码仓库

关于 collecting-volatile-evidence-from-compromised-host

面向事件响应与取证人员的易失性证据采集技能,指导在隔离或修复前获取内存、网络、进程和会话状态,并通过哈希与保管链记录维护证据完整性。

主要功能

  1. 01按易失性顺序采集数据
  2. 02获取内存转储与网络状态
  3. 03记录进程、用户和系统配置
  4. 04计算证据 SHA256 哈希
  5. 05维护证据保管链

适用场景

  1. 01调查无文件恶意软件
  2. 02保全活动 C2 会话证据
  3. 03分析内部数据窃取或横向移动

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill collecting-volatile-evidence-from-compromised-host

安装后在 Claude Code 中输入/collecting-volatile-evidence-from-compromised-host确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

LICENSE
assets/
template.md
references/
api-reference.md
standards.md
workflows.md
scripts/
agent.py
process.py

详细介绍

从受感染主机收集易失性证据

何时使用

  • 已确认安全事件并识别出受感染主机
  • 在系统隔离、关机或修复开始之前
  • 怀疑存在内存驻留恶意软件(无文件攻击)
  • 需要捕获网络连接、运行中的进程和系统状态
  • 法律程序可能需要保全取证证据
  • 事件需要结合易失性数据进行根因分析

前提条件

  • USB 或网络共享上的取证收集工具包(可信工具)
  • 用于内存采集的 WinPmem/LiME
  • 用于磁盘镜像的写阻断器或取证工作站
  • 证据链文档表格
  • 具有完整性验证的安全证据存储
  • 收集证据的授权(内部人员案件需法律/人力资源批准)

工作流

第 1 步:准备收集环境
# Mount forensic USB toolkit (do NOT install tools on compromised system)
# Verify toolkit integrity
sha256sum /mnt/forensic_usb/tools/* > /tmp/toolkit_hashes.txt
diff /mnt/forensic_usb/tools/known_good_hashes.txt /tmp/toolkit_hashes.txt

# Create evidence output directory with timestamps
EVIDENCE_DIR="/mnt/evidence/$(hostname)_$(date +%Y%m%d_%H%M%S)"
mkdir -p "$EVIDENCE_DIR"
echo "Collection started: $(date -u)" > "$EVIDENCE_DIR/collection_log.txt"
echo "Collector: $(whoami)" >> "$EVIDENCE_DIR/collection_log.txt"
echo "System: $(hostname)" >> "$EVIDENCE_DIR/collection_log.txt"
第 2 步:捕获系统内存(易失性最高)
# Windows - WinPmem memory acquisition
winpmem_mini_x64.exe "$EVIDENCE_DIR\memdump_$(hostname).raw"

# Linux - LiME kernel module for memory acquisition
insmod /mnt/forensic_usb/lime.ko "path=$EVIDENCE_DIR/memdump_$(hostname).lime format=lime"

# Linux - Alternative using /proc/kcore
dd if=/proc/kcore of="$EVIDENCE_DIR/kcore_dump.raw" bs=1M

# macOS - osxpmem
osxpmem -o "$EVIDENCE_DIR/memdump_$(hostname).aff4"

# Hash the memory dump immediately
sha256sum "$EVIDENCE_DIR/memdump_"* > "$EVIDENCE_DIR/memory_hash.sha256"
第 3 步:捕获网络状态
# Active network connections
# Windows
netstat -anob > "$EVIDENCE_DIR/netstat_connections.txt" 2>&1
Get-NetTCPConnection | Export-Csv "$EVIDENCE_DIR/tcp_connections.csv" -NoTypeInformation
Get-NetUDPEndpoint | Export-Csv "$EVIDENCE_DIR/udp_endpoints.csv" -NoTypeInformation

# Linux
ss -tulnp > "$EVIDENCE_DIR/socket_stats.txt"
netstat -anp > "$EVIDENCE_DIR/netstat_all.txt" 2>/dev/null
cat /proc/net/tcp > "$EVIDENCE_DIR/proc_net_tcp.txt"
cat /proc/net/udp > "$EVIDENCE_DIR/proc_net_udp.txt"

# ARP cache
arp -a > "$EVIDENCE_DIR/arp_cache.txt"

# Routing table
route print > "$EVIDENCE_DIR/routing_table.txt"  # Windows
ip route show > "$EVIDENCE_DIR/routing_table.txt"  # Linux

# DNS cache
ipconfig /displaydns > "$EVIDENCE_DIR/dns_cache.txt"  # Windows
# Linux: varies by resolver, check systemd-resolve or nscd
systemd-resolve --statistics > "$EVIDENCE_DIR/dns_stats.txt" 2>/dev/null

# Active firewall rules
netsh advfirewall show allprofiles > "$EVIDENCE_DIR/firewall_rules.txt"  # Windows
iptables -L -n -v > "$EVIDENCE_DIR/iptables_rules.txt"  # Linux
第 4 步:捕获运行中的进程
# Windows - Detailed process list
tasklist /V /FO CSV > "$EVIDENCE_DIR/process_list_verbose.csv"
wmic process list full > "$EVIDENCE_DIR/wmic_process_full.txt"
Get-Process | Select-Object Id,ProcessName,Path,StartTime,CPU,WorkingSet |
  Export-Csv "$EVIDENCE_DIR/ps_processes.csv" -NoTypeInformation

# Windows - Process with command line and parent
wmic process get ProcessId,Name,CommandLine,ParentProcessId,ExecutablePath /FORMAT:CSV > \
  "$EVIDENCE_DIR/process_commandlines.csv"

# Linux - Full process tree
ps auxwwf > "$EVIDENCE_DIR/process_tree.txt"
ps -eo pid,ppid,user,args --forest > "$EVIDENCE_DIR/process_forest.txt"
cat /proc/*/cmdline 2>/dev/null | tr '\0' ' ' > "$EVIDENCE_DIR/proc_cmdline_all.txt"

# Process modules/DLLs loaded
# Windows
listdlls.exe -accepteula > "$EVIDENCE_DIR/loaded_dlls.txt"
# Linux
for pid in $(ls /proc/ | grep -E '^[0-9]+$'); do
  echo "=== PID $pid ===" >> "$EVIDENCE_DIR/proc_maps.txt"
  cat "/proc/$pid/maps" 2>/dev/null >> "$EVIDENCE_DIR/proc_maps.txt"
done

# Open file handles
handle.exe -accepteula > "$EVIDENCE_DIR/open_handles.txt"  # Windows (Sysinternals)
lsof > "$EVIDENCE_DIR/open_files.txt"  # Linux
第 5 步:捕获已登录用户和会话
# Windows
query user > "$EVIDENCE_DIR/logged_in_users.txt"
query session > "$EVIDENCE_DIR/active_sessions.txt"
net session > "$EVIDENCE_DIR/net_sessions.txt" 2>&1
net use > "$EVIDENCE_DIR/mapped_drives.txt" 2>&1

# Linux
who > "$EVIDENCE_DIR/who_output.txt"
w > "$EVIDENCE_DIR/w_output.txt"
last -50 > "$EVIDENCE_DIR/last_logins.txt"
lastlog > "$EVIDENCE_DIR/lastlog.txt"
cat /var/log/auth.log | tail -200 > "$EVIDENCE_DIR/recent_auth.txt" 2>/dev/null
第 6 步:捕获系统配置状态
# System time (critical for timeline)
date -u > "$EVIDENCE_DIR/system_time_utc.txt"
w32tm /query /status > "$EVIDENCE_DIR/ntp_status.txt"  # Windows
ntpq -p > "$EVIDENCE_DIR/ntp_status.txt"  # Linux

# Environment variables
set > "$EVIDENCE_DIR/environment_vars.txt"  # Windows
env > "$EVIDENCE_DIR/environment_vars.txt"  # Linux

# Scheduled tasks / Cron jobs
schtasks /query /fo CSV /v > "$EVIDENCE_DIR/scheduled_tasks.csv"  # Windows
crontab -l > "$EVIDENCE_DIR/crontab_current.txt" 2>/dev/null  # Linux
ls -la /etc/cron.* > "$EVIDENCE_DIR/cron_dirs.txt" 2>/dev/null

# Services
sc queryex type=service state=all > "$EVIDENCE_DIR/services_all.txt"  # Windows
systemctl list-units --type=service --all > "$EVIDENCE_DIR/systemd_services.txt"  # Linux

# Windows Registry - key autostart locations
reg export "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "$EVIDENCE_DIR/reg_run_hklm.reg" /y
reg export "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "$EVIDENCE_DIR/reg_run_hkcu.reg" /y
reg export "HKLM\SYSTEM\CurrentControlSet\Services" "$EVIDENCE_DIR/reg_services.reg" /y
第 7 步:对所有证据进行哈希并记录证据链
# Generate SHA256 hashes for all collected evidence
cd "$EVIDENCE_DIR"
sha256sum * > evidence_manifest.sha256

# Create chain of custody record
cat > "$EVIDENCE_DIR/chain_of_custody.txt" << EOF
CHAIN OF CUSTODY RECORD
========================
Case ID: IR-YYYY-NNN
Collection Date: $(date -u)
Collected By: $(whoami)
System: $(hostname)
System IP: $(hostname -I 2>/dev/null || ipconfig | grep IPv4)
Collection Method: Live forensic collection via trusted USB toolkit

Evidence Items:
$(ls -la "$EVIDENCE_DIR/" | grep -v chain_of_custody)

SHA256 Manifest: evidence_manifest.sha256
Transfer: [TO BE COMPLETED]
Storage Location: [TO BE COMPLETED]
EOF

关键概念

概念描述
易失性顺序RFC 3227 - 优先收集最易失的数据:寄存器 > 缓存 > 内存 > 磁盘
实时取证在关机前从运行中的系统收集证据
证据链跟踪证据从收集到法庭处理过程的文档记录
取证完整性确保证据收集不会改变原始证据
可信工具使用来自外部介质的经过验证的工具,而不是来自受感染系统的工具
证据完整性收集后立即对所有证据进行 SHA256 哈希
洛卡德交换原理每一次接触都会留下痕迹 - 尽量减少调查人员产生的痕迹

工具与系统

工具用途
WinPmemWindows 内存采集
LiME(Linux Memory Extractor)Linux 内核内存采集
Sysinternals Suite进程、句柄和 DLL 分析(Windows)
Velociraptor大规模远程取证收集
KAPE(Kroll Artifact Parser)Windows 上的自动化工件收集
CyLR跨平台实时响应收集
GRR Rapid Response远程实时取证框架

常见场景

  1. 无文件恶意软件攻击:基于 PowerShell 的攻击,磁盘上没有文件。内存转储是包含恶意脚本的关键证据。
  2. 活动 C2 会话:攻击者拥有实时连接。网络连接和进程数据可揭示 C2 基础设施。
  3. 内部人员数据窃取:员工复制文件。进程列表、映射驱动器和网络连接显示数据外泄活动。
  4. 受感染的 Web 服务器:检测到 Web shell。内存中可能包含尚未写入磁盘的其他后门。
  5. 正在进行的横向移动:攻击者在系统之间移动。内存中的身份验证令牌和网络会话可揭示影响范围。

输出格式

  • 带有 SHA256 哈希的内存转储文件(.raw 或 .lime 格式)
  • 网络状态捕获(连接、ARP、DNS、路由)
  • 包含命令行和父进程的进程列表
  • 用户会话和身份验证数据
  • 系统配置快照
  • 带有 SHA256 校验和的证据清单
  • 证据链文档

评论

支持 Markdown