當專業沙箱(Cuckoo、FireEye、Hybrid Analysis)不可用時,系統管理員可利用 Linux Live 環境、核心工具鏈對受感染 Windows 系統進行離線取證分析。本文實戰演示基於檔案系統快照與登錄檔對比的靜態分析流程。
md5sum/sha256sum、mount (NTFS-3g)、reglookup/hivex (Registry 解析)、diff、find、strings、file、yararegedit /e C:\baseline.regmkdir /mnt/win
mount -t ntfs-3g -o ro /dev/sda2 /mnt/win # 唯讀掛載保護證據
find /mnt/win -type f -not -name "pagefile.sys" -not -name "hiberfil.sys" \
-exec sha256sum {} + > /evidence/baseline.sha256
cp /mnt/win/Windows/System32/config/SYSTEM /evidence/
cp /mnt/win/Windows/System32/config/SOFTWARE /evidence/
cp /mnt/win/Windows/System32/config/SAM /evidence/
cp /mnt/win/Windows/System32/config/SECURITY /evidence/
cp /mnt/win/Windows/System32/config/DEFAULT /evidence/
cp /mnt/win/Users/*/NTUSER.DAT /evidence/ # 用戶登錄檔
regedit /e C:\infected.reg(或直接複製 Registry Hive 檔案)find /mnt/win -type f -not -name "pagefile.sys" -not -name "hiberfil.sys" \
-exec sha256sum {} + > /evidence/infected.sha256
# 新增檔案(僅在 infected 出現)
comm -13 <(sort /evidence/baseline.sha256) <(sort /evidence/infected.sha256) | \
awk '{print $2}' > /evidence/new_files.txt
# 修改檔案(雜湊值不同)
join -j 2 <(sort -k2 /evidence/baseline.sha256) <(sort -k2 /evidence/infected.sha256) | \
awk '$1 != $3 {print $2}' > /evidence/modified_files.txt
# 刪除檔案(僅在 baseline 出現)
comm -23 <(sort /evidence/baseline.sha256) <(sort /evidence/infected.sha256) | \
awk '{print $2}' > /evidence/deleted_files.txt
# 使用 hivexsh 解析並對比
hivexsh /evidence/SYSTEM.baseline -c 'cd ControlSet001\Services; ls' > /evidence/svc_baseline.txt
hivexsh /evidence/SYSTEM.infected -c 'cd ControlSet001\Services; ls' > /evidence/svc_infected.txt
diff -u /evidence/svc_baseline.txt /evidence/svc_infected.txt
# 關鍵啟動項位置
# HKLM\Software\Microsoft\Windows\CurrentVersion\Run
# HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce
# HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run
# HKCU\Software\Microsoft\Windows\CurrentVersion\Run
# Services: HKLM\System\CurrentControlSet\Services\
# Scheduled Tasks: HKLM\Software\Microsoft\Windows\CurrentVersion\TaskScheduler
# 提取可疑檔案字串
strings suspicious.exe | grep -iE "http|ftp|ip|dns|cmd|powershell|registry|service|driver|inject|hook|rootkit|keylog|steal|encrypt|ransom|bitcoin|wallet|tor|onion|c2|beacon"
# YARA 規則掃描
yara -r malware_rules.yar /mnt/win
# 檢查 PE 標頭、區段、導入表、資源
peframe suspicious.exe
# 或
objdump -x suspicious.exe
readelf -h suspicious.exe # 若為 ELF
# Volatility 3
python3 vol.py -f mem.dmp windows.pslist
python3 vol.py -f mem.dmp windows.netscan
python3 vol.py -f mem.dmp windows.registry.hivelist
python3 vol.py -f mem.dmp windows.filescan
log2timeline.py (Plaso) 產生超級時間線#!/bin/bash
# forensics_diff.sh
MOUNT=$1
EVD=$2
find "$MOUNT" -type f -exec sha256sum {} + > "$EVD/current.sha256"
# 對比邏輯...
# 生成報告...