Communitygithub.com

使用 CHIPSEC 稽核 UEFI 韌體

使用 Intel CHIPSEC 評估平台韌體配置、SPI 快閃記憶體寫入保護、BIOS 鎖、SMM/SMRR 和安全啟動變數狀態,並傾印 SPI 快閃記憶體以及對 UEFI 變數進行威脅分級。

使用 CHIPSEC 稽核 UEFI 韌體 是什麼?

該技能旨在使用 Intel 的開源平台安全評估框架 CHIPSEC,對 x86 平台進行深入的韌體安全稽核。CHIPSEC 透過載入核心驅動程式來直接存取硬體暫存器、MSR、PCI 配置空間、SPI 快閃記憶體和 UEFI 變數,以驗證諸如 BIOS 寫入保護(BIOS_CNTL、SPI 保護範圍)、SPI 快閃記憶體描述符鎖(FLOCKDN)、SMRAM/SMRR 配置以及安全啟動變數保護等關鍵防護機制是否生效。此技能對應 MITRE ATT&CK 的 T1542.001(系統韌體)技術,其核心價值在於確認阻止未授權韌體修改的前提條件是否完備,例如 SPI 快閃記憶體的 BIOS 區域是否被寫入保護、快閃記憶體描述符是否鎖定區域存取權限等。支援的作業系統包括 Linux、Windows 及 UEFI Shell,需要在受測系統上擁有 root 或管理員權限。該技能涵蓋從安裝、執行自動化測試套件、逐一檢查韌體保護模組、傾印 SPI 快閃記憶體進行離線鑑識,到列舉並分類 UEFI 變數的完整工作流程。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mukul975/Anthropic-Cybersecurity-Skills/tree/main/skills/auditing-uefi-firmware-with-chipsec

在你喜歡的 AI 中提問

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

說明文件

使用 CHIPSEC 稽核 UEFI 韌體 是做什麼的?

僅限授權使用: CHIPSEC 會載入核心驅動程式並讀寫低階硬體暫存器、SPI 快閃記憶體和 SMM。請僅在您擁有或明確授權評估的系統上執行,最好在專用的測試硬體上執行。誤用(特別是寫入/修改模組)可能導致機器變磚。切勿在生產系統上執行具寫入能力的模組。

概述

CHIPSEC 是由 Intel 先進威脅研究團隊建立的開源 平台安全評估框架。它檢查 x86 平台韌體和硬體的低階安全配置 — 這是作業系統之下的層級,也是開機套件和韌體植入物藏身之處。CHIPSEC 會載入一個已簽署的核心驅動程式(Linux、Windows,或可從 UEFI Shell 執行)來讀寫硬體暫存器、模型特定暫存器(MSR)、PCI 配置空間、SPI 快閃記憶體和 UEFI 變數,然後執行一套自動化測試,以檢查平台的防禦鎖定機制是否確實生效。

CHIPSEC 應對的威脅是 MITRE ATT&CK 的 T1542.001 — 前作業系統開機:系統韌體:攻擊者修改系統韌體(SPI 快閃記憶體上的 BIOS/UEFI 映像)以獲得隱蔽、持久且能繞過作業系統的控制權。韌體植入物可以跨越作業系統重灌和磁碟更換而持續存在,並且大多數 EDR 無法發現。CHIPSEC 的價值在於驗證防止此類植入物的 先決條件:SPI 快閃記憶體的 BIOS 區域是否已啟用寫入保護(BIOS_CNTL BLE/SMM_BWP、SPI 保護範圍)、快閃記憶體描述符是否鎖定區域存取、SMRAM/SMRR 是否有配置,以及安全啟動變數是否受到保護。它也能傾印 SPI 快閃記憶體,以便進行離線鑑識比對。

資料來源:Intel/CHIPSEC 專案 (https://github.com/chipsec/chipsec)、CHIPSEC 文件 (https://chipsec.github.io/)。

使用時機

  • 新筆電/伺服器平台或機群映像的基準韌體安全評估
  • 驗證 BIOS 寫入保護和 SPI 快閃記憶體鎖定是否已由 OEM 正確啟用
  • 韌體鑑識:傾印 SPI 快閃記憶體以與已知良好的映像進行比較
  • 驗證安全啟動變數保護和 S3 開機腳本保護
  • 尋找韌體植入物或可能導致植入的配置錯誤的證據

先決條件

  • 對目標 x86 平台(Intel 或 AMD)具有實體、root 或管理員存取權限
  • Linux(root)或 Windows(系統管理員)環境,或 UEFI Shell 環境
  • 能夠載入核心驅動程式(安全啟動可能需要允許 CHIPSEC 驅動程式,或使用 --no_driver 進行有限度的檢查)
  • Python 3.8+ 以及用於建置核心模組的 C 編譯器/建置工具(在 Linux 上)
  • 強烈建議使用專用測試硬體

安裝 CHIPSEC:

# 從 PyPI 安裝
pip install chipsec

# 或從原始碼安裝(會建置核心輔助程式/驅動程式)
git clone https://github.com/chipsec/chipsec
cd chipsec
python setup.py install        # 建置並安裝,包括 Linux 驅動程式

# 驗證
sudo chipsec_main --help
sudo chipsec_util --help

目標

  • 執行完整的自動化平台安全測試套件並解讀 PASS/FAIL/WARNING 結果
  • 驗證 BIOS 寫入保護(BIOS_CNTL)和 SPI 保護範圍
  • 驗證 SPI 快閃記憶體描述符是否鎖定區域的讀寫存取權限
  • 驗證 SMRAM/SMRR 和 SMI 處理器保護
  • 驗證安全啟動變數保護和 S3 開機腳本保護
  • 傾印 SPI 快閃記憶體並進行解碼以進行離線分析
  • 列舉 UEFI 變數並偵測異常或非預期的条目

MITRE ATT&CK 對應

技術 ID名稱戰術
T1542.001前作業系統開機:系統韌體持續性 / 防禦規避

CHIPSEC 透過驗證防止未授權韌體修改的控制項是否啟用,來防禦 T1542.001。如果 common.bios_wp(BIOS 未寫入保護)或 chipsec.modules.common.spi_lock(快閃記憶體描述符未鎖定)的結果是 FAIL,意味著具有 OS 權限的攻擊者可以改寫 SPI 快閃記憶體並植入持久性韌體 — 這正是此技術的先決條件。

工作流程

步驟 1:執行完整的自動化測試套件

執行 chipsec_main(不指定模組引數)會針對已偵測到的平台執行所有適用的安全檢查,並印出 PASS/FAIL/WARNING/INFORMATION 結果的摘要。

sudo chipsec_main

# 儲存機器可讀的輸出以便於報告/比對差異
sudo chipsec_main -j results.json -x results.xml -l chipsec.log

步驟 2:逐一執行核心韌體保護模組

common 模組組包含了與 OEM 無關的安全檢查。可以執行整個組或特定模組:

# 執行整個 common 組
sudo chipsec_main -m common

# BIOS 寫入保護:檢查 BIOS_CNTL BLE/SMM_BWP 和 SPI 保護範圍
sudo chipsec_main -m common.bios_wp

# SPI 快閃記憶體描述符鎖定(FLOCKDN)— 快閃記憶體區域存取是否已鎖定?
sudo chipsec_main -m common.spi_lock

# SMRR 程式設計 — 保護 SMRAM 免受基於快取的攻擊
sudo chipsec_main -m common.smrr

# SMM BIOS 寫入保護
sudo chipsec_main -m common.smm

# S3 恢復開機腳本保護(防止開機腳本表攻擊)
sudo chipsec_main -m common.uefi.s3bootscript

步驟 3:驗證安全啟動變數保護

# 檢查安全啟動 UEFI 變數是否受到妥善保護
sudo chipsec_main -m common.secureboot.variables

# 主動測試變數的寫入保護(僅限測試硬體):
sudo chipsec_main -m common.secureboot.variables -a modify

步驟 4:檢查 SPI 快閃記憶體區域存取權限

# 報告 SPI 快閃記憶體區域、描述符和存取權限
sudo chipsec_util spi info

# 檢查 SPI 存取控制模組
sudo chipsec_main -m common.spi_access

步驟 5:傾印 SPI 快閃記憶體以進行離線鑑識

傾印快閃記憶體可讓您解碼韌體區塊並與已知良好的 OEM 映像進行比較。

# 將整個 SPI 快閃記憶體傾印到檔案
sudo chipsec_util spi dump rom.bin

# 解碼傾印的映像:提取韌體區塊、檔案、NVRAM 變數等。
sudo chipsec_util decode rom.bin

步驟 6:列舉並分類 UEFI 變數

# 從執行時期介面列出所有 UEFI 變數
sudo chipsec_util uefi var-list

# 直接從 SPI 映像列出變數(離線)
sudo chipsec_util uefi var-find PK
sudo chipsec_util uefi var-read db <GUID> db.bin

# 解碼 UEFI 韌體結構
sudo chipsec_util uefi decode rom.bin

步驟 7:在沒有核心驅動程式的情況下進行有限度的評估

如果無法載入驅動程式(例如在鎖定的安全啟動環境下),某些檢查仍可以唯讀模式執行。

sudo chipsec_main -n            # --no_driver:跳過需要驅動程式的檢查
sudo chipsec_main -p <PLATFORM> # 若自動偵測失敗,則強制指定平台代碼

步驟 8:分類結果並報告

  • bios_wp / spi_lock 結果為 FAIL → 韌體可從 OS 端改寫:T1542.001 風險高。
  • secureboot.variables 結果為 FAIL → 安全啟動原則可能被篡改。
  • 將 spi dump 結果與 OEM 的已知良好映像進行比較(對韌體區塊進行雜湊處理),以偵測未授權的修改。
  • 在報告中記錄平台、BIOS 版本,以及每個 FAIL/WARNING 結果及相關的暫存器值。

工具和資源

工具用途來源
chipsec_main自動化平台安全測試套件https://github.com/chipsec/chipsec
chipsec_util手動硬體/韌體存取(spi、uefi、decode)https://chipsec.github.io/
UEFIToolGUI/CLI 解析已傾印的 UEFI 映像https://github.com/LongSoft/UEFITool
Binarly fwhunt韌體漏洞/植入物狩獵規則https://github.com/binarly-io/fwhunt-scan
NSA UEFI Secure Boot 指南強化參考https://media.defense.gov/

核心模組參考

模組檢查項目
common.bios_wpBIOS_CNTL BLE / SMM_BWP 和 SPI 保護範圍
common.spi_lockSPI 快閃記憶體描述符 FLOCKDN
common.spi_accessSPI 快閃記憶體區域讀寫權限
common.smrr系統管理範圍暫存器程式設計
common.smmSMM BIOS 寫入保護
common.secureboot.variables安全啟動變數保護
common.uefi.s3bootscriptS3 恢復開機腳本保護

驗證標準

  • CHIPSEC 已安裝且驅動程式會載入(若無則記錄使用 -n)
  • 已執行完整的 chipsec_main 套件,並已儲存 JSON/XML/日誌輸出
  • 已解讀 common.bios_wp 的結果(寫入保護狀態)
  • 已解讀 common.spi_lock / spi_access 的結果(描述符鎖定狀態)
  • 已記錄 SMRR/SMM 模組結果
  • 已檢查安全啟動變數保護
  • 已傾印並解碼 SPI 快閃記憶體以進行離線分析
  • 已列舉並分類 UEFI 變數
  • 所有 FAIL/WARNING 發現均已記錄平台/BIOS 版本
  • 寫入/修改模組未在生產硬體上執行

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,

相關技能