Communitygithub.com

分析Windows登錄檔以提取鑑識證據

使用RegRipper等工具提取並分析Windows登錄檔,以調查使用者活動、惡意軟體持久化機制及系統配置。

分析Windows登錄檔以提取鑑識證據 是什麼?

此技能專注於從Windows系統中提取和分析登錄檔(Registry Hives),以支援數位鑑識調查。其核心用途包括:識別惡意軟體使用的自動執行與持久化機制、重建使用者活動(如執行過的程式、存取的檔案)、追蹤USB裝置連線歷史,以及提取系統與網路配置資訊。 技能支援多種平台,包括SIFT Workstation或任何具備Python環境的鑑識分析工作站。主要工具包含RegRipper(自動化外掛架構)、python-registry程式庫,以及Eric Zimmerman開發的Registry Explorer等。工作流程涵蓋:從鑑識映像中提取SAM、SYSTEM、SOFTWARE及NTUSER.DAT等登錄檔、使用RegRipper自動分析各類型登錄檔、透過python-registry腳本進行定向提取(如使用者協助程式History、MRU清單、自動執行機碼),最後產出結構化的報告。 此技能特別適用於惡意軟體調查、內部威脅分析,以及任何需要重建Windows系統使用者操作的場景。產出結果包括系統資訊、自動執行項目、使用者活動記錄、USB裝置連線紀錄及安裝軟體清單,幫助調查人員快速鎖定可疑活動。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mukul975/Anthropic-Cybersecurity-Skills/tree/main/skills/analyzing-windows-registry-for-artifacts

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

分析Windows登錄檔以提取鑑識證據 是做什麼的?

何時使用

  • 調查Windows系統上的使用者活動時 (例如事故應變)
  • 識別惡意軟體使用的自動執行/持久化機制
  • 追蹤已安裝軟體、USB裝置與網路連線
  • 在內部威脅調查中重建使用者行為
  • 將登錄檔時間戳與其他鑑識證據進行關聯

先備條件

  • 鑑識映像或已提取的登錄檔案
  • RegRipper、Registry Explorer (Eric Zimmerman) 或 python-registry
  • 可存取登錄檔存放位置 (SAM、SYSTEM、SOFTWARE、NTUSER.DAT、UsrClass.dat)
  • 了解Windows登錄檔結構 (Hives, Keys, Values)
  • SIFT Workstation 或鑑識分析環境

工作流程

步驟 1:從鑑識映像中提取登錄檔

# 以唯讀模式掛載鑑識映像
mkdir /mnt/evidence
mount -o ro,loop,offset=$((2048*512)) /cases/case-2024-001/images/evidence.dd /mnt/evidence

# 複製系統登錄檔
cp /mnt/evidence/Windows/System32/config/SAM /cases/case-2024-001/registry/
cp /mnt/evidence/Windows/System32/config/SYSTEM /cases/case-2024-001/registry/
cp /mnt/evidence/Windows/System32/config/SOFTWARE /cases/case-2024-001/registry/
cp /mnt/evidence/Windows/System32/config/SECURITY /cases/case-2024-001/registry/
cp /mnt/evidence/Windows/System32/config/DEFAULT /cases/case-2024-001/registry/

# 複製使用者專屬登錄檔
cp /mnt/evidence/Users/*/NTUSER.DAT /cases/case-2024-001/registry/
cp /mnt/evidence/Users/*/AppData/Local/Microsoft/Windows/UsrClass.dat /cases/case-2024-001/registry/

# 複製交易紀錄 (用於損毀登錄檔復原)
cp /mnt/evidence/Windows/System32/config/*.LOG* /cases/case-2024-001/registry/logs/

# 計算所有提取登錄檔的雜湊值
sha256sum /cases/case-2024-001/registry/* > /cases/case-2024-001/registry/hive_hashes.txt

步驟 2:使用RegRipper進行自動化提取

# 安裝RegRipper
git clone https://github.com/keydet89/RegRipper3.0.git /opt/regripper

# 對NTUSER.DAT (使用者設定檔) 執行RegRipper
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/NTUSER.DAT \
   -f ntuser > /cases/case-2024-001/analysis/ntuser_report.txt

# 對SYSTEM登錄檔執行
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/SYSTEM \
   -f system > /cases/case-2024-001/analysis/system_report.txt

# 對SOFTWARE登錄檔執行
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/SOFTWARE \
   -f software > /cases/case-2024-001/analysis/software_report.txt

# 對SAM登錄檔 (使用者帳戶) 執行
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/SAM \
   -f sam > /cases/case-2024-001/analysis/sam_report.txt

# 執行特定外掛
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/NTUSER.DAT \
   -p userassist > /cases/case-2024-001/analysis/userassist.txt

perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/SYSTEM \
   -p usbstor > /cases/case-2024-001/analysis/usbstor.txt

步驟 3:提取持久化與自動執行項目

# 使用python-registry進行定向提取
pip install python-registry

python3 << 'PYEOF'
from Registry import Registry

# 開啟SOFTWARE登錄檔
reg = Registry.Registry("/cases/case-2024-001/registry/SOFTWARE")

# 檢查Run機碼 (自動啟動)
autorun_paths = [
    "Microsoft\\Windows\\CurrentVersion\\Run",
    "Microsoft\\Windows\\CurrentVersion\\RunOnce",
    "Microsoft\\Windows\\CurrentVersion\\RunServices",
    "Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\Run",
    "Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Run"
]

for path in autorun_paths:
    try:
        key = reg.open(path)
        print(f"\n=== {path} (上次修改:{key.timestamp()}) ===")
        for value in key.values():
            print(f"  {value.name()}: {value.value()}")
    except Registry.RegistryKeyNotFoundException:
        pass

# 檢查已安裝的服務
key = reg.open("Microsoft\\Windows NT\\CurrentVersion\\Svchost")
print(f"\n=== Svchost 群組 ===")
for value in key.values():
    print(f"  {value.name()}: {value.value()}")
PYEOF

# 檢查NTUSER.DAT中的使用者自訂自動執行
python3 << 'PYEOF'
from Registry import Registry

reg = Registry.Registry("/cases/case-2024-001/registry/NTUSER.DAT")

user_autorun = [
    "Software\\Microsoft\\Windows\\CurrentVersion\\Run",
    "Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce",
    "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StartupApproved\\Run"
]

for path in user_autorun:
    try:
        key = reg.open(path)
        print(f"\n=== {path} (上次修改:{key.timestamp()}) ===")
        for value in key.values():
            print(f"  {value.name()}: {value.value()}")
    except Registry.RegistryKeyNotFoundException:
        pass
PYEOF

步驟 4:分析使用者活動鑑識證據

# 提取UserAssist資料 (程式執行記錄,使用ROT13編碼)
python3 << 'PYEOF'
from Registry import Registry
import codecs, struct, datetime

reg = Registry.Registry("/cases/case-2024-001/registry/NTUSER.DAT")

ua_path = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\UserAssist"
key = reg.open(ua_path)

for guid_key in key.subkeys():
    count_key = guid_key.subkey("Count")
    print(f"\n=== {guid_key.name()} ===")
    for value in count_key.values():
        decoded_name = codecs.decode(value.name(), 'rot_13')
        data = value.value()
        if len(data) >= 16:
            run_count = struct.unpack('<I', data[4:8])[0]
            focus_count = struct.unpack('<I', data[8:12])[0]
            timestamp = struct.unpack('<Q', data[60:68])[0] if len(data) >= 68 else 0
            if timestamp > 0:
                ts = datetime.datetime(1601,1,1) + datetime.timedelta(microseconds=timestamp//10)
                print(f"  {decoded_name}: 執行次數={run_count}, 聚焦次數={focus_count}, 最後執行={ts}")
            else:
                print(f"  {decoded_name}: 執行次數={run_count}, 聚焦次數={focus_count}")
PYEOF

# 提取最近文件 (MRU 清單)
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/NTUSER.DAT \
   -p recentdocs > /cases/case-2024-001/analysis/recentdocs.txt

# 提取瀏覽器輸入的網址
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/NTUSER.DAT \
   -p typedurls > /cases/case-2024-001/analysis/typedurls.txt

# 提取在檔案總管輸入的路徑
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/NTUSER.DAT \
   -p typedpaths > /cases/case-2024-001/analysis/typedpaths.txt

步驟 5:提取系統與網路資訊

# 從SYSTEM登錄檔取得電腦名稱與作業系統版本
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/SYSTEM \
   -p compname > /cases/case-2024-001/analysis/system_info.txt

# 網路介面與配置
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/SYSTEM \
   -p nic2 >> /cases/case-2024-001/analysis/system_info.txt

# 無線網路歷史
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/SOFTWARE \
   -p networklist > /cases/case-2024-001/analysis/network_history.txt

# 時區設定
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/SYSTEM \
   -p timezone > /cases/case-2024-001/analysis/timezone.txt

# 關機時間
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/SYSTEM \
   -p shutdown > /cases/case-2024-001/analysis/shutdown.txt

# 從Uninstall機碼取得已安裝軟體
perl /opt/regripper/rip.pl -r /cases/case-2024-001/registry/SOFTWARE \
   -p uninstall > /cases/case-2024-001/analysis/installed_software.txt

關鍵概念

概念說明
Registry hive儲存登錄檔區段的二進位檔案 (如 SAM、SYSTEM、SOFTWARE、NTUSER.DAT)
MRU (最近使用)記錄最近存取的檔案、命令與搜尋字詞的清單
UserAssist使用ROT13編碼的登錄檔項目,記錄包含時間戳的程式執行紀錄
ShimCache應用程式相容性快取,記錄曾執行的程式
AmCache詳細的執行歷史紀錄,包含執行檔的SHA-1雜湊值
BAM/DAM背景/桌面活動調節器,在Windows 10以上記錄程式執行
Last Write Time登錄檔機碼上的時間戳,表示最後修改時間
交易紀錄可在不正常關機後復原登錄檔狀態的日誌檔案

工具與系統

工具用途
RegRipper以插件架構進行自動化登錄檔證據提取
Registry ExplorerEric Zimmerman的圖形化介面工具,可互動式分析登錄檔
python-registry用於程式化解析登錄檔的Python函式庫
RECmdEric Zimmerman的命令列登錄檔分析工具
yarp另一個基於Python的登錄檔解析器
AppCompatCacheParser專用的ShimCache/AppCompatCache解析工具
AmcacheParser專用的AmCache.hve分析工具
ShellBags Explorer專門分析ShellBag鑑識證據的工具

常見情境

情境 1:惡意軟體持久化調查 提取SOFTWARE與NTUSER.DAT登錄檔,檢查所有Run/RunOnce機碼的未授權項目,檢查服務中是否有可疑新增項目,檢查排程工作相關登錄機碼,將自動執行時間戳與惡意軟體執行時間軸進行關聯。

情境 2:使用者活動重建 分析UserAssist獲取程式執行歷史、檢查RecentDocs了解被存取的檔案、檢查TypedPaths獲取檔案總管導覽路徑、提取ShellBags了解資料夾存取模式,建構事發時間視窗內的使用者活動時間軸。

情境 3:未授權軟體偵測 解析Uninstall機碼取得所有已安裝應用程式、比對核准軟體基線、檢查BAM/DAM中近期執行但不在核准清單中的程式、檢查AppCompatCache以取得即使已解除安裝的執行證據。

情境 4:USB資料竊取調查 從SYSTEM登錄檔提取USBSTOR項目以取得已連線的裝置、將裝置序號與MountedDevices進行關聯、檢查NTUSER.DAT的MountPoints2以了解使用者對卸除式媒體的存取、檢查SetupAPI記錄以取得首次連線時間戳。

輸出格式

登錄檔分析摘要:
  系統:DESKTOP-ABC123 (Windows 10 專業版 Build 19041)
  時區:東部標準時間 (UTC-5)
  最後關機:2024-01-18 23:45:12 UTC

  自動執行項目:
    HKLM Run:     5 個項目 (1 個可疑:"updater.exe" -> C:\ProgramData\svc\updater.exe)
    HKCU Run:     3 個項目 (均為合法)
    服務:         142 個項目 (2 個不明:"WinDefSvc", "SysMonAgent")

  使用者活動 (NTUSER.DAT):
    UserAssist 程式:  234 個項目
    最近文件:         89 個項目
    輸入的網址:       45 個項目
    輸入的路徑:       12 個項目

  已連線的USB裝置:
    - Kingston DataTraveler (序號:0019E06B4521) - 首次:2024-01-10,最後:2024-01-18
    - WD My Passport (序號:575834314131) - 首次:2024-01-15,最後:2024-01-15

  已安裝軟體:     127 個應用程式
  可疑發現:       3 個標記待審查項目

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,

相關技能