| name | performing-memory-forensics-with-volatility3-plugins |
| description | 使用 Volatility3 插件分析内存转储,检测 Windows、Linux 和 macOS 内存镜像中的注入代码、Rootkit、凭据窃取和恶意软件痕迹。 |
| domain | cybersecurity |
| subdomain | malware-analysis |
| tags | ["memory-forensics","volatility3","malware-analysis","incident-response","process-injection","rootkit-detection","dfir"] |
| version | 1.0 |
| author | mahipal |
| license | Apache-2.0 |
使用 Volatility3 插件进行内存取证
概述
Volatility3(v2.26.0+,2025 年 5 月发布功能对等版本)是内存取证的标准框架,取代了已弃用的 Volatility2。它分析来自 Windows、Linux 和 macOS 的 RAM 转储,可检测恶意进程、代码注入、Rootkit、凭据收集以及基于磁盘的取证无法发现的网络连接。主要插件包括:windows.malfind(检测表明注入的 RWX 内存区域)、windows.psscan(发现隐藏进程)、windows.dlllist(枚举已加载模块)、windows.netscan(活跃网络连接)和 windows.handles(打开的文件/注册表句柄)。2024 年插件大赛引入了 ETW Scan,用于从内存中提取 Windows 事件跟踪数据。
前置条件
- Python 3.9+,安装
volatility3 框架
- 内存转储文件(
.raw、.dmp、.vmem、.lime)
- Windows 符号表(ISF 文件,自动下载)
- 了解 Windows 进程内存架构
- YARA 集成,用于内存模式扫描
操作步骤
步骤 1:进程分析以检测恶意软件
"""基于 Volatility3 的内存取证自动化工具,用于恶意软件分析。"""
import subprocess
import json
import sys
import os
class Vol3Analyzer:
"""自动化执行 Volatility3 插件进行恶意软件分析。"""
def __init__(self, dump_path, vol3_path="vol"):
self.dump_path = dump_path
self.vol3 = vol3_path
self.results = {}
def run_plugin(self, plugin, extra_args=None):
"""执行 Volatility3 插件并捕获输出。"""
cmd = [
self.vol3, "-f", self.dump_path,
"-r", "json", plugin,
]
if extra_args:
cmd.extend(extra_args)
try:
result = subprocess.run(
cmd, capture_output=True, text=True, timeout=300
)
if result.returncode == 0:
return json.loads(result.stdout)
except (subprocess.TimeoutExpired, json.JSONDecodeError) as e:
print(f" [!] {plugin} 失败:{e}")
return None
def detect_process_injection(self):
()
results = .run_plugin()
injected = []
results:
entry results:
injected.append({
: entry.get(),
: entry.get(),
: entry.get(),
: entry.get(),
: entry.get(, )[:],
})
(
)
.results[] = injected
injected
():
()
pslist = .run_plugin()
psscan = .run_plugin()
pslist psscan:
[]
list_pids = {e.get() e pslist}
scan_pids = {e.get() e psscan}
hidden = scan_pids - list_pids
hidden:
()
entry psscan:
entry.get() hidden:
()
.results[] = (hidden)
(hidden)
():
()
results = .run_plugin()
connections = []
results:
entry results:
conn = {
: entry.get(),
: entry.get(),
: ,
: ,
: entry.get(),
: entry.get(),
}
connections.append(conn)
.results[] = connections
connections
():
()
args = [, (pid)] pid
results = .run_plugin(, args)
dlls = []
results:
entry results:
dlls.append({
: entry.get(),
: entry.get(),
: entry.get(),
: entry.get(),
: entry.get(),
: entry.get(),
})
.results[] = dlls
dlls
():
()
results = .run_plugin(
,
[, rules_path]
)
matches = []
results:
entry results:
matches.append({
: entry.get(),
: entry.get(),
: entry.get(),
: entry.get(),
})
.results[] = matches
matches
():
()
( * )
.detect_process_injection()
.find_hidden_processes()
.analyze_network()
.results
__name__ == :
(sys.argv) < :
()
sys.exit()
analyzer = Vol3Analyzer(sys.argv[])
results = analyzer.full_triage()
(json.dumps(results, indent=, default=))
验证标准
- 内存转储已成功使用正确的操作系统配置文件解析
- 通过 malfind 检测到具有 RWX 区域的注入进程
- 通过 pslist/psscan 对比识别出隐藏进程
- 网络连接揭示 C2 通信端点
- YARA 规则匹配内存中的已知恶意软件签名
- 从 lsass 进程内存中提取凭据痕迹
参考资料