使用 Hindsight 分析瀏覽器鑑識 是做什麼的?
概述
Hindsight 是一款開源的瀏覽器鑑識工具,專為解析 Google Chrome 及其他 Chromium 核心瀏覽器(Microsoft Edge、Brave、Opera、Vivaldi)的遺留資料而設計。它能從多個瀏覽器資料庫檔案中提取並關聯資料,建立統一的網頁活動時間軸。Hindsight 可解析 URL、下載記錄、快取記錄、書籤、自動填入記錄、儲存密碼、偏好設定、瀏覽器擴充功能、HTTP Cookie、Local Storage(HTML5 Cookie)、登入資料及分頁/索引標籤資訊。該工具能產出多種輸出格式(XLSX、JSON、SQLite)的按時間順序排列的時間軸,使調查人員能夠重建使用者網頁活動,適用於事件應變、內部威脅調查及刑事案件。
使用時機
- 調查需要透過 Hindsight 分析瀏覽器鑑識的安全事件時
- 為此領域建立偵測規則或威脅獵殺查詢時
- 安全營運中心(SOC)分析師需要此分析類型的結構化程序時
- 驗證相關攻擊手法之安全監控覆蓋率時
先決條件
- Python 3.8+ 並已安裝 Hindsight(
pip install pyhindsight)
- 可存取鑑識映像中的瀏覽器設定檔目錄
- 瀏覽器設定檔資料(未受 OS 層級加密)
- Timeline Explorer 或試算表應用程式以供分析
瀏覽器設定檔位置
| 瀏覽器 | Windows 設定檔路徑 |
|---|
| Chrome | %LOCALAPPDATA%\Google\Chrome\User Data\Default\ |
| Edge | %LOCALAPPDATA%\Microsoft\Edge\User Data\Default\ |
| Brave | %LOCALAPPDATA%\BraveSoftware\Brave-Browser\User Data\Default\ |
| Opera | %APPDATA%\Opera Software\Opera Stable\ |
| Vivaldi | %LOCALAPPDATA%\Vivaldi\User Data\Default\ |
| Chrome (macOS) | ~/Library/Application Support/Google/Chrome/Default/ |
| Chrome (Linux) | ~/.config/google-chrome/Default/ |
關鍵遺留資料檔案
| 檔案 | 內容 |
|---|
| History | URL 造訪記錄、下載記錄、關鍵字搜尋 |
| Cookies | HTTP Cookie,包含網域、到期日、值 |
| Web Data | 自動填入項目、已儲存的信用卡資訊 |
| Login Data | 已儲存的使用者名稱/密碼(加密) |
| Bookmarks | JSON 格式的書籤樹 |
| Preferences | 瀏覽器設定與擴充功能 |
| Local Storage/ | 每個網域的 HTML5 Local Storage |
| Session Storage/ | 每個網域的工作階段專用儲存 |
| Network Action Predictor | 之前輸入過的 URL |
| Shortcuts | 網址列捷徑與預測 |
| Top Sites | 常造訪的網站 |
執行 Hindsight
命令列
hindsight.exe -i "C:\Evidence\Users\suspect\AppData\Local\Google\Chrome\User Data\Default" -o C:\Output\chrome_analysis
hindsight.exe -i "/path/to/profile" -o /output/analysis -b Chrome
hindsight.exe -i "C:\Evidence\Chrome\Default" -o C:\Output\chrome --format jsonl
hindsight.exe -i "C:\Evidence\Chrome\Default" -o C:\Output\chrome --cache
Web UI
hindsight_gui.exe
遺留資料分析細節
URL 歷史與造訪記錄
下載記錄
Cookie 分析
Python 分析指令碼
import sqlite3
import os
import json
import sys
from datetime import datetime, timedelta
CHROME_EPOCH = datetime(1601, 1, 1)
def chrome_time_to_datetime(chrome_ts: int):
"""將 Chrome 時間戳記轉換為 datetime。"""
if chrome_ts == 0:
return None
try:
return CHROME_EPOCH + timedelta(microseconds=chrome_ts)
except (OverflowError, OSError):
return None
def analyze_chrome_history(profile_path: str, output_dir: str) -> dict:
"""分析 Chrome History 資料庫以取得鑑識證據。"""
history_db = os.path.join(profile_path, "History")
if not os.path.exists(history_db):
return {"error": "History 資料庫未找到"}
os.makedirs(output_dir, exist_ok=True)
conn = sqlite3.connect(f"file:{history_db}?mode=ro", uri=True)
cursor = conn.cursor()
cursor.execute("""
SELECT u.url, u.title, v.visit_time, u.visit_count,
v.transition & 0xFF as transition_type
FROM visits v JOIN urls u ON v.url = u.id
ORDER BY v.visit_time DESC LIMIT 5000
""")
visits = [{
"url": r[0], "title": r[1],
"visit_time": str(chrome_time_to_datetime(r[2])),
"total_visits": r[3], "transition": r[4]
} for r in cursor.fetchall()]
cursor.execute("""
SELECT target_path, tab_url, start_time, end_time,
received_bytes, total_bytes, mime_type, state
FROM downloads ORDER BY start_time DESC LIMIT 1000
""")
downloads = [{
"path": r[0], "source_url": r[1],
"start_time": str(chrome_time_to_datetime(r[2])),
"end_time": str(chrome_time_to_datetime(r[3])),
"received_bytes": r[4], "total_bytes": r[5],
"mime_type": r[6], "state": r[7]
} for r in cursor.fetchall()]
cursor.execute("""
SELECT k.term, u.url, k.url_id
FROM keyword_search_terms k JOIN urls u ON k.url_id = u.id
ORDER BY u.last_visit_time DESC LIMIT 1000
""")
searches = [{"term": r[0], "url": r[1]} for r in cursor.fetchall()]
conn.close()
report = {
"analysis_timestamp": datetime.now().isoformat(),
"profile_path": profile_path,
"total_visits": len(visits),
"total_downloads": len(downloads),
"total_searches": len(searches),
"visits": visits,
"downloads": downloads,
"searches": searches
}
report_path = os.path.join(output_dir, "browser_forensics.json")
with open(report_path, "w") as f:
json.dump(report, f, indent=2)
return report
def main():
if len(sys.argv) < 3:
print("用法:python process.py <chrome_profile_path> <output_dir>")
sys.exit(1)
analyze_chrome_history(sys.argv[1], sys.argv[2])
if __name__ == "__main__":
main()
參考資料
輸出範例
$ python hindsight.py -i /evidence/chrome-profile -o /analysis/hindsight_output
Hindsight v2024.01 - Chrome/Chromium 瀏覽器鑑識分析
================================================================
設定檔:/evidence/chrome-profile(Chrome 120.0.6099.130)
作業系統:Windows 10
[+] 解析 History 資料庫中...
URL 記錄: 12,456
下載記錄: 234
搜尋字詞: 567
[+] 解析 Cookies 資料庫中...
Cookie 記錄: 8,923
加密 Cookie: 6,712
[+] 解析 Web Data(自動填入)中...
自動填入項目: 1,234
信用卡項目: 2(加密)
[+] 解析 Login Data 中...
已儲存憑證: 45(加密)
[+] 解析書籤中...
書籤項目: 189
--- 瀏覽記錄(最後 10 筆) ---
時間戳記(UTC) | URL | 標題 | 造訪次數
2024-01-15 14:32:05.123 | https://mail.corporate.com/inbox | 企業郵件 | 45
2024-01-15 14:33:12.456 | https://drive.google.com/file/d/1aBcDe... | Q4_Financial_Report.xlsx | 1
2024-01-15 14:35:44.789 | https://mega.nz/folder/xYz123 | MEGA - 安全雲端 | 3
2024-01-15 14:36:01.234 | https://mega.nz/folder/xYz123#upload | MEGA - 上傳 | 8
2024-01-15 14:42:15.567 | https://pastebin.com/raw/kL9mN2pQ | Pastebin(原始內容) | 1
2024-01-15 15:01:33.890 | https://192.168.1.50:8443/admin | 管理後台 | 12
2024-01-15 15:15:22.111 | https://transfer.sh/upload | transfer.sh | 2
2024-01-15 15:30:45.222 | https://vpn-gateway.corporate.com | VPN 登入 | 5
2024-01-15 16:00:00.333 | https://whatismyipaddress.com | 我的 IP 是什麼 | 1
2024-01-15 16:05:12.444 | https://protonmail.com/inbox | ProtonMail | 3
--- 下載記錄(可疑) ---
時間戳記(UTC) | 檔案名稱 | URL 來源 | 大小
2024-01-15 14:33:15.000 | Q4_Financial_Report.xlsm | https://phish-domain.com/docs/report | 245 KB
2024-01-15 14:34:02.000 | update_client.exe | https://cdn.evil-updates.com/client.exe | 1.2 MB
--- Cookie(工作階段 Token) ---
網域 | 名稱 | 到期時間 | Secure | HttpOnly
.corporate.com | SESSION_ID | 2024-01-16 14:32 | 是 | 是
.mega.nz | session | 工作階段 | 是 | 是
.protonmail.com | AUTH-TOKEN | 2024-02-15 00:00 | 是 | 是
報告已儲存至:/analysis/hindsight_output/Hindsight_Report.xlsx