硬件供应链攻击(Hardware Supply Chain Attack)是供应链安全领域中最具隐蔽性和持久性的威胁形态。与软件供应链攻击不同,硬件供应链攻击将恶意代码或物理组件植入到芯片、固件、电路板或外设等物理层面,一旦部署到位,传统的软件级安全工具几乎无法检测和清除。从 2018 年 Bloomberg 报道的 Supermicro 间谍芯片事件到 2023 年 BlackLotus UEFI Bootkit 大规模绕过 Secure Boot,硬件供应链攻击的威胁已经从理论走向实战。
对于取证分析人员而言,硬件供应链攻击带来了前所未有的技术挑战:物理植入物的检测需要专业的硬件逆向工具链,固件篡改的取证要求深入理解 UEFI/BIOS 启动流程,而 BMC/IPMI 等带外管理接口的滥用则需要跳出传统操作系统层面的取证思维。本文系统性地梳理硬件供应链攻击的取证分析方法论,从芯片级物理取证到固件级逻辑审计,从侧信道分析到可信根验证,结合真实案例还原完整的硬件供应链攻击取证链。
0x01 技术基础与硬件供应链攻击概述 硬件供应链架构模型 现代 IT 基础设施的硬件供应链涉及多个参与方和环节,从芯片设计到最终部署,每个节点都可能成为攻击者的介入点。
供应链环节 关键参与方 攻击面 威胁等级 芯片设计 EDA 工具厂商、IP 核授权方 RTL 代码后门、逻辑门级植入 极高 晶圆制造 Foundry(TSMC/Samsung/SMIC) 制造过程中植入物理木马 极高 封装测试 OSAT 厂商 封装后门、测试接口滥用 高 PCB 组装 EMS/ODM 厂商 PCB 篡改、多余元件植入 高 固件开发 BIOS/UEFI 供应商 固件后门、签名绕过 极高 分发渠道 经销商、物流 中途替换、翻新冒充新品 中 部署运维 企业 IT 团队 固件降级、配置篡改 中
攻击面分类体系 硬件供应链攻击可根据攻击层级进行分类,每一层级对应不同的取证方法和检测手段。
攻击层级 MITRE ATT&CK 攻击手法 检测难度 典型案例 物理层(Physical) T1195.001 芯片植入、PCB 篡改、总线监听 极高 Supermicro 间谍芯片 固件层(Firmware) T1195.001 UEFI 篡改、SPI Flash 注入、Option ROM 后门 高 BlackLotus、MosaicRegressor 驱动层(Driver) T1195.002 签名伪造驱动、DMA 攻击、侧信道泄露 中-高 Apple IOFireWireFamily 驱动漏洞 配置层(Config) T1195.002 BMC/IPMI 默认凭据、SNMP v1/v2 弱认证、固件降级 中 Cisco IOS 后门
与软件供应链攻击的差异 硬件供应链攻击在多个维度上与软件供应链攻击存在本质差异,这些差异直接决定了取证方法论的选择。
对比维度 软件供应链攻击 硬件供应链攻击 攻击持久性 卸载/回滚可清除 物理替换才能彻底消除 检测手段 签名验证、哈希比对、行为分析 需要物理检测、侧信道分析、X射线成像 取证证据 日志、内存、网络流量 芯片显微照片、SPI Flash 镜像、电性能数据 恢复成本 软件重装或版本回退 硬件更换,成本极高 影响范围 按安装量计算 按受影响批次/型号计算 取证周期 数小时至数天 数周至数月(含物理分析)
硬件供应链取证工具链 硬件供应链取证需要一套跨学科的专门化工具链,涵盖固件提取、硬件检测、侧信道分析和可信验证等多个环节。
工具名称 功能定位 适用场景 获取方式 CHIPSEC 固件/UEFI 安全检测框架 BIOS 篡改、Secure Boot 验证 pip install chipsec UEFITool UEFI 固件镜像解析 固件模块提取和分析 GitHub 开源 Java 应用 flashrom SPI Flash 读写工具 固件提取、刷写和比对 apt install flashrom sadump / chipsec_util BIOS 内存转储 UEFI 运行时内存取证 内置 CHIPSEC TPM 2.0 Tools TPM 操作和验证 可信平台模块验证 apt install tpm2-tools stlink / OpenOCD JTAG/SWD 调试器接口 芯片级调试和内存读取 apt install stlink-tools ChipWhisperer 侧信道分析平台 电磁/功耗分析攻击检测 开源硬件 + 软件套件 Ghidra / IDA Pro 固件逆向分析 UEFI DXE 驱动反编译 开源 / 商业 FwAnalyzer 固件差异分析 固件版本比对和篡改检测 Python 开源工具 Binwalk 固件二进制分析 固件镜像解包和文件系统提取 apt install binwalk JEDEC 标准工具 内存/存储芯片识别 芯片型号验证和来源追溯 行业标准 Hardware Sentry / Redfish 服务器硬件状态监控 BMC/IPMI 状态审计 商业/开源
0x02 芯片级供应链攻击取证 IC 后门与硬件木马概述 芯片级供应链攻击(IC Supply Chain Attack,MITRE ATT&CK T1195.001)是硬件供应链中检测难度最高的攻击类型。攻击者在芯片设计、制造或封装阶段植入恶意电路,这些物理层面的修改无法通过任何软件级手段检测。
硬件木马(Hardware Trojan)根据触发机制和功能可以分为以下类别:
分类维度 类别 描述 检测方法 触发机制 组合触发型 特定输入组合激活恶意逻辑 功能测试、形式验证 触发机制 时序触发型 运行计数器达到阈值后激活 长时间监控、侧信道 触发机制 环境触发型 温度/电压/电磁变化触发 环境压力测试 功能类型 信息泄露型 通过侧信道泄露密钥等敏感数据 电磁屏蔽、功耗分析 功能类型 功能修改型 修改运算结果或跳过安全检查 黄金参考比对 功能类型 拒绝服务型 导致芯片永久或间歇性故障 可靠性测试 植入位置 控制通路型 修改控制器行为 RTL 形式验证 植入位置 数据通路型 修改数据处理逻辑 差分功耗分析
侧信道分析技术 侧信道分析(Side-Channel Analysis)是检测芯片级硬件木马的核心技术手段,通过分析芯片运行时的物理特性(功耗、电磁辐射、时序)来发现异常行为。
功耗分析(Power Analysis):
简单功耗分析(SPA)通过观察功耗曲线的整体特征来推断芯片内部操作。差分功耗分析(DPA)则通过统计方法,利用大量功耗样本提取与密钥相关的微弱信号。
ChipWhisperer CLI 连接目标设备
chipwhisperer-hardware --capture --samples 100000 --trigger-mode power
python3 -c "
import numpy as np
traces = np.load('capture_traces.npy')
for i in range(traces.shape[0]):
mean_power = np.mean(traces[i])
std_power = np.std(traces[i])
if std_power > 0.15:
print(f'[!] Trace {i}: abnormal variance detected (std={std_power:.4f})')
" 电磁辐射分析(EM Analysis):
电磁近场扫描可以定位芯片内部的异常辐射源,这些辐射源可能指示植入的恶意逻辑电路。
使用近场探针扫描芯片表面
python3 -c "
import struct, json
def analyze_em_map(em_data_file):
with open(em_data_file, 'rb') as f:
header = f.read(64)
width = struct.unpack('<I', header[0:4])[0]
height = struct.unpack('<I', header[4:8])[0]
freq_mhz = struct.unpack('<f', header[8:12])[0]
data = f.read()
pixels = np.frombuffer(data, dtype=np.float32).reshape(height, width)
threshold = np.mean(pixels) + 3 * np.std(pixels)
anomalies = np.argwhere(pixels > threshold)
print(f'EM scan: {width}x{height} at {freq_mhz}MHz')
print(f'Threshold: {threshold:.4f}')
print(f'Anomalous hotspots: {len(anomalies)}')
for y, x in anomalies[:10]:
print(f' Hotspot at ({x}, {y}): {pixels[y, x]:.4f}')
analyze_em_map('em_scan_001.bin')
" 物理取证方法 当软件级检测确认存在硬件级异常后,需要采用物理取证方法进行最终确认。
物理取证方法 工具设备 分辨率 适用场景 成本等级 X 射线成像(X-Ray) 工业 CT 扫描仪 微米级 封装内部结构检查 高 扫描电子显微镜(SEM) FEI/Zeiss SEM 纳米级 芯片表面层分析 极高 聚焦离子束(FIB) FEI FIB-SEM 纳米级 芯片截面分析 极高 红外热成像 FLIR 热像仪 毫米级 异常发热点定位 中 超声波扫描 Sonoscan C-SAM 微米级 封装分层和异物检测 中-高 光学显微检查 体视显微镜 微米级 PCB 焊接和元件检查 低
物理取证检查清单执行脚本
python3 -c "
import json, datetime
checklist = {
'visual_inspection': {
'description': 'PCB 目视检查',
'tools': ['体视显微镜', 'UV 灯'],
'check_points': [
'多余焊锡桥接',
'非原厂元件',
'PCB 走线异常',
'隐藏元件或飞线',
'丝印信息与实物不符'
],
'status': 'pending'
},
'xray_analysis': {
'description': 'X 射线成像分析',
'tools': ['工业 CT'],
'check_points': [
'封装内部结构异常',
'芯片堆叠层检查',
'焊球/引线键合异常',
'额外裸片(Die)检测'
],
'status': 'pending'
},
'sem_analysis': {
'description': '扫描电子显微镜分析',
'tools': ['SEM + FIB'],
'check_points': [
'金属层拓扑比对',
'逻辑门级结构验证',
'额外互连检测',
'修改痕迹识别'
],
'status': 'pending'
},
'electrical_test': {
'description': '电性能测试',
'tools': ['逻辑分析仪', '示波器'],
'check_points': [
'静态功耗基线比对',
'动态功耗异常检测',
'时序特性验证',
'I/O 特性验证'
],
'status': 'pending'
}
}
report = {
'device': 'Supermicro X11SSZ-F',
'serial': 'SN-2024-HW-001',
'analyst': 'Blue Team Forensics',
'timestamp': datetime.datetime.now().isoformat(),
'checklist': checklist
}
with open('hw_forensics_checklist.json', 'w') as f:
json.dump(report, f, indent=2, ensure_ascii=False)
print(f'Created hardware forensics checklist: hw_forensics_checklist.json')
print(f'Check items: {sum(len(v[\"check_points\"]) for v in checklist.values())}')
" 芯片型号验证与BOM审计 Bill of Materials(BOM)审计是硬件供应链取证的基础环节,通过验证物料清单中每个组件的型号、批次和来源,可以发现未授权的元件替换或篡改。
BOM 审计与芯片型号验证脚本
python3 -c "
import csv, hashlib, json
expected_bom = [
{'ref': 'U1', 'part': 'Intel Xeon E-2176G', 'manufacturer': 'Intel', 'lot': 'LOT-2024-Q1-001'},
{'ref': 'U2', 'part': 'Winbond W25Q256JV', 'manufacturer': 'Winbond', 'lot': 'WB-2024-03-001'},
{'ref': 'U3', 'part': 'Nuvoton NPCT650', 'manufacturer': 'Nuvoton', 'lot': 'NV-2024-02-001'},
{'ref': 'U4', 'part': 'Broadcom BCM5720', 'manufacturer': 'Broadcom', 'lot': 'BC-2024-01-001'},
{'ref': 'U5', 'part': 'ASPEED AST2600', 'manufacturer': 'ASPEED', 'lot': 'AS-2024-Q1-001'},
{'ref': 'J1', 'part': 'SPI Flash W25Q128', 'manufacturer': 'Winbond', 'lot': 'WB-2024-03-002'}
]
def audit_bom(actual_bom_file, expected_bom):
anomalies = []
with open(actual_bom_file) as f:
reader = csv.DictReader(f)
actual_bom = list(reader)
for actual in actual_bom:
ref = actual.get('ref', '')
expected = next((e for e in expected_bom if e['ref'] == ref), None)
if not expected:
anomalies.append({'ref': ref, 'issue': 'UNKNOWN_COMPONENT', 'detail': 'Not in expected BOM'})
continue
if actual.get('part') != expected['part']:
anomalies.append({'ref': ref, 'issue': 'PART_MISMATCH', 'expected': expected['part'], 'actual': actual.get('part')})
if actual.get('manufacturer') != expected['manufacturer']:
anomalies.append({'ref': ref, 'issue': 'MANUFACTURER_MISMATCH', 'expected': expected['manufacturer'], 'actual': actual.get('manufacturer')})
if actual.get('lot') != expected['lot']:
anomalies.append({'ref': ref, 'issue': 'LOT_MISMATCH', 'expected': expected['lot'], 'actual': actual.get('lot'), 'severity': 'HIGH'})
return anomalies
results = audit_bom('actual_bom.csv', expected_bom)
print(f'BOM audit complete: {len(results)} anomalies found')
for r in results:
print(f' [{r[\"issue\"]}] {r[\"ref\"]}: {r.get(\"detail\", r.get(\"actual\", \"\"))} (expected: {r.get(\"expected\", \"N/A\")})')
" 0x03 固件与 BIOS/UEFI 供应链取证 SPI Flash 篡改检测 SPI Flash 是 BIOS/UEFI 固件的物理存储介质。攻击者可以通过 SPI 编程器直接读写 Flash 芯片,绕过所有操作系统级安全机制。SPI Flash 篡改是 UEFI 供应链攻击中最常用的持久化手段(MITRE ATT&CK T1542.001)。
固件提取与哈希校验:
使用 flashrom 提取 SPI Flash 固件镜像
flashrom -p linux_spi:dev= /dev/spidev0.0 -r firmware_dump.bin
binwalk 提取固件结构
binwalk firmware_dump.bin
计算固件哈希并与官方基准比对
sha256sum firmware_dump.bin
sha256sum -c firmware_known_good.sha256
使用 UEFITool 解析固件结构
UEFITool firmware_dump.bin 固件差异分析:
固件差异分析脚本
python3 -c "
import hashlib, os, struct
def extract_firmware_regions(fw_path):
regions = []
with open(fw_path, 'rb') as f:
data = f.read()
bios_region_sig = b'\x5A\xA5\xF0\x0F'
pos = 0
while True:
idx = data.find(bios_region_sig, pos)
if idx == -1:
break
if idx >= 16:
descriptor_sig = data[idx-16:idx]
regions.append({'offset': idx-16, 'type': 'IFD_DESCRIPTOR', 'size': idx+4-pos})
pos = idx + 4
for marker, name in [(b'FVH', 'EFI_FIRMWARE_VOLUME'), (b' $FDC', 'FLASH_DESCRIPTOR_CENTER')]:
idx = data.find(marker)
if idx != -1:
regions.append({'offset': idx, 'type': name, 'data_hash': hashlib.sha256(data[idx:idx+65536]).hexdigest()})
return regions
def compare_firmware(baseline_path, suspect_path):
with open(baseline_path, 'rb') as f:
baseline = f.read()
with open(suspect_path, 'rb') as f:
suspect = f.read()
if len(baseline) != len(suspect):
print(f'[!] Size mismatch: baseline={len(baseline)}, suspect={len(suspect)}')
diffs = []
for i in range(min(len(baseline), len(suspect))):
if baseline[i] != suspect[i]:
diffs.append(i)
if not diffs:
print('[+] Firmware images are identical')
else:
print(f'[!] Found {len(diffs)} byte differences')
contiguous_regions = []
start = diffs[0]
end = diffs[0]
for d in diffs[1:]:
if d == end + 1:
end = d
else:
contiguous_regions.append((start, end))
start = d
end = d
contiguous_regions.append((start, end))
for s, e in contiguous_regions[:20]:
region_size = e - s + 1
baseline_hex = baseline[s:s+16].hex()
suspect_hex = suspect[s:s+16].hex()
print(f' Diff at 0x{s:08X}-0x{e:08X} ({region_size} bytes):')
print(f' Baseline: {baseline_hex}')
print(f' Suspect: {suspect_hex}')
return diffs
diffs = compare_firmware('firmware_baseline.bin', 'firmware_dump.bin')
with open('firmware_diff_report.json', 'w') as f:
import json
json.dump({'total_diffs': len(diffs), 'diff_offsets': diffs[:100]}, f)
" Secure Boot 绕过检测 Secure Boot 是 UEFI 安全启动机制,通过验证启动链中每个组件的数字签名来防止未授权代码执行。然而,多种攻击手段可以绕过 Secure Boot 保护。
绕过方式 MITRE ATT&CK 攻击原理 检测方法 DB/DBX 篡改 T1542.001 修改签名数据库添加恶意证书 CHIPSEC db/dbx 验证 shim 绕过 T1542.001 利用 shim bootloader 的 Microsoft 签名漏洞 shim 版本检查 Bootkit 注入 T1542.001 在 Boot Manager 之前加载恶意代码 Bootkit 扫描 Secure Boot 禁用 T1542.001 直接修改 Secure Boot 状态变量 NVRAM 变量检查 CVE-2022-21894 T1542.001 Secure Boot Advanced Targeting (SBAT) 绕过 SBAT 策略检查
使用 CHIPSEC 检测 Secure Boot 配置:
chipsec_main --module secureboot.bootauth
chipsec_main --module secureboot.amd
chipsec_main --module common.secureboot
chipsec_util spi info
chipsec_util spi dump spi_dump.bin
python3 -c "
from chipsec.hal.spi import SPI
from chipsec import chipset
cs = chipset.cs()
spi = SPI(cs)
fw_size = spi.get_spi_size()
print(f'SPI Flash size: {fw_size / 1024 / 1024:.1f} MB')
regions = spi.get_SPI_regions()
for region_name, region in regions.items():
print(f'Region: {region_name}')
print(f' Offset: 0x{region[\"offset\"]:08X}')
print(f' Size: 0x{region[\"size\"]:08X}')
print(f' Limit: 0x{region[\"limit\"]:08X}')
" 固件持久化检测 UEFI 固件持久化(Firmware Persistence)是高级攻击者常用的隐蔽驻留技术,恶意代码驻留在固件层,即使重新安装操作系统也无法清除。
检查 UEFI 持久化机制
python3 -c "
import subprocess, json, re
def check_uefi_persistence():
findings = []
result = subprocess.run(['efibootmgr', '-v'], capture_output=True, text=True)
if result.returncode == 0:
for line in result.stdout.split('\n'):
if 'File(' in line or 'PciRoot' in line:
path_match = re.search(r'File\(([^)]+)\)', line)
if path_match:
boot_path = path_match.group(1)
if boot_path.lower().endswith(('.efi',)):
findings.append({
'type': 'EFI_BOOT_OPTION',
'path': boot_path,
'detail': line.strip()
})
try:
with open('/sys/firmware/efi/efivars/SecureBoot-*', 'rb') as f:
data = f.read()
sb_status = data[-1]
findings.append({
'type': 'SECURE_BOOT_STATUS',
'enabled': sb_status == 1,
'detail': 'Secure Boot is ' + ('enabled' if sb_status == 1 else 'DISABLED')
})
except FileNotFoundError:
findings.append({'type': 'SECURE_BOOT_STATUS', 'enabled': False, 'detail': 'EFI variables not accessible'})
try:
with open('/sys/firmware/efi/efivars/BootOrder-*', 'rb') as f:
boot_order = f.read()
findings.append({'type': 'BOOT_ORDER', 'raw': boot_order.hex()})
except FileNotFoundError:
pass
return findings
results = check_uefi_persistence()
print(f'UEFI persistence check: {len(results)} findings')
for r in results:
print(f' [{r[\"type\"]}] {r.get(\"detail\", r.get(\"path\", \"\"))}')
" 0x04 网络设备硬件后门取证 路由器/交换机固件分析 网络设备固件供应链攻击(MITRE ATT&CK T1195.002)具有极高的隐蔽性和影响力。攻击者可以修改路由器/交换机固件,植入流量嗅探、数据篡改或命令后门等恶意功能。
Cisco IOS 固件提取与分析:
提取 Cisco IOS 固件镜像
binwalk -e cisco_ios_image.bin
查找固件中的硬编码后门特征
strings cisco_ios_image.bin | grep -iE '(password|secret|backdoor|debug|hidden)'
strings cisco_ios_image.bin | grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
检查固件中的异常网络连接
strings cisco_ios_image.bin | grep -oP '\d+\.\d+\.\d+\.\d+:\d+'
binwalk 固件模块列表
binwalk --dd '.*' cisco_ios_image.bin JUNOS(Juniper)固件分析:
Juniper 设备固件完整性检查
request system snapshot
show system firmware
request system software integrity checksum
检查 Juniper ScreenOS 后门(CVE-2015-7755)
show version
show configuration | match ssh FPGA 后门检测 FPGA(Field-Programmable Gate Array)在现代网络设备中被广泛用于实现高速数据处理和网络协议加速。FPGA 的可编程特性使其成为硬件供应链攻击的理想载体。
检测维度 检测方法 工具 适用场景 配置比特流比对 读取并比对 FPGA 配置 JTAG 编程器 FPGA 配置篡改检测 功能测试 网络流量处理一致性验证 流量分析仪 FPGA 逻辑异常 侧信道分析 功耗/电磁特征比对 ChipWhisperer FPGA 逻辑后门 时序分析 高速信号时序测量 逻辑分析仪 硬木马触发检测
FPGA 配置比特流提取与分析
openocd -f interface/ftdi/ft232r.cfg -f cpld/xilinx-xc.cfg \
-c "pld load 0 firmware.bit" -c shutdown
python3 -c "
import hashlib
def analyze_fpga_bitstream(bitstream_path):
with open(bitstream_path, 'rb') as f:
data = f.read()
print(f'Bitstream size: {len(data)} bytes')
print(f'SHA-256: {hashlib.sha256(data).hexdigest()}')
xilinx_magic = bytes([0x0F, 0xF0, 0x0F, 0xF0])
idx = data.find(xilinx_magic)
if idx != -1:
print(f'Xilinx sync word found at offset: 0x{idx:08X}')
for marker, name in [(b'XILINX', 'Xilinx Bitstream'), (b'ALTERA', 'Intel/Altera Bitstream'), (b'LATTICE', 'Lattice Bitstream')]:
if marker in data:
print(f'Detected: {name}')
return {'size': len(data), 'hash': hashlib.sha256(data).hexdigest()}
result = analyze_fpga_bitstream('fpga_config.bin')
" 网络设备固件后门 IOC 检测 通用网络设备固件后门特征扫描
python3 -c "
import subprocess, re, hashlib
def scan_device_firmware(target_ip, firmware_path):
iocs = {
'hardcoded_ips': [],
'hardcoded_creds': [],
'suspicious_strings': [],
'hidden_services': []
}
with open(firmware_path, 'rb') as f:
data = f.read()
ip_pattern = rb'(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})'
for match in re.finditer(ip_pattern, data):
ip = match.group().decode('utf-8', errors='ignore')
octets = ip.split('.')
if all(0 <= int(o) <= 255 for o in octets):
if ip.startswith('0.') or ip.startswith('127.'):
continue
iocs['hardcoded_ips'].append({'ip': ip, 'offset': match.start()})
cred_patterns = [
rb'(?:password|passwd|pwd)\s*[=:]\s*(\S+)',
rb'(?:secret|key)\s*[=:]\s*(\S+)',
rb'(?:enable\s+password)\s+(\S+)',
]
for pattern in cred_patterns:
for match in re.finditer(pattern, data, re.IGNORECASE):
iocs['hardcoded_creds'].append({
'credential': match.group().decode('utf-8', errors='ignore'),
'offset': match.start()
})
suspicious = [b'backdoor', b'hidden', b'debug_mode', b'rootkit', b'sniffer', b'tap']
for keyword in suspicious:
for match in re.finditer(keyword, data, re.IGNORECASE):
iocs['suspicious_strings'].append({
'keyword': keyword.decode(),
'offset': match.start(),
'context': data[max(0, match.start()-32):match.end()+32].hex()
})
return iocs
results = scan_device_firmware('192.168.1.1', 'firmware_extracted.bin')
print('IOC Scan Results:')
for category, items in results.items():
if items:
print(f' {category}: {len(items)} findings')
for item in items[:5]:
print(f' {item}')
" 0x05 服务器与存储硬件供应链审计 BMC/IPMI 安全审计 基板管理控制器(BMC,Baseboard Management Controller)通过 IPMI 或 Redfish 协议提供带外管理功能。BMC 运行独立于主操作系统,拥有对服务器的完全控制权,是硬件供应链攻击的高价值目标(MITRE ATT&CK T1199)。
威胁类型 描述 检测方法 严重程度 默认凭据 BMC 使用出厂默认用户名/密码 凭据审计、登录日志分析 高 固件后门 BMC 固件被植入后门代码 固件提取比对、网络流量监控 极高 Web UI 注入 BMC Web 管理界面存在注入漏洞 漏洞扫描、代码审计 高 远程代码执行 IPMI/Redfish API 漏洞利用 API 安全测试 极高 加密缺陷 BMC 通信使用弱加密或明文 TLS 配置审计 中
BMC 安全审计脚本:
BMC 安全配置审计
python3 -c "
import subprocess, json, re
def audit_bmc_security(bmc_ip, bmc_user='ADMIN'):
findings = []
result = subprocess.run(
['ipmitool', '-I', 'lanplus', '-H', bmc_ip, '-U', bmc_user, '-P', 'test',
'channel', 'info'],
capture_output=True, text=True, timeout=10
)
if result.returncode == 0:
for line in result.stdout.split('\n'):
if 'Authentication Type' in line:
findings.append({
'check': 'AUTH_TYPE',
'detail': line.strip(),
'risk': 'HIGH' if 'NONE' in line or 'RCMP+' in line else 'MEDIUM'
})
result = subprocess.run(
['ipmitool', '-I', 'lanplus', '-H', bmc_ip, '-U', bmc_user, '-P', 'test',
'user', 'list', '1'],
capture_output=True, text=True, timeout=10
)
if result.returncode == 0:
for line in result.stdout.split('\n'):
if 'ENABLED' in line:
findings.append({
'check': 'ACTIVE_USER',
'detail': line.strip(),
'risk': 'INFO'
})
if 'ADMIN' in line and 'root' not in line.lower():
findings.append({
'check': 'PRIVILEGED_USER',
'detail': line.strip(),
'risk': 'MEDIUM'
})
result = subprocess.run(
['ipmitool', '-I', 'lanplus', '-H', bmc_ip, '-U', bmc_user, '-P', 'test',
'dcmi', 'parameters', 'get', '11'],
capture_output=True, text=True, timeout=10
)
findings.append({
'check': 'SOL_STATUS',
'detail': 'Serial Over LAN checked',
'risk': 'INFO'
})
return findings
results = audit_bmc_security('10.0.0.100')
print(f'BMC security audit: {len(results)} findings')
for r in results:
print(f' [{r[\"risk\"]}] {r[\"check\"]}: {r[\"detail\"]}')
" HBA 卡固件审计 主机总线适配器(HBA)固件是存储供应链攻击的重要目标。攻击者可以通过篡改 HBA 固件,实现数据窃取、存储劫持或隐蔽通信。
HBA 卡固件版本检查
lspci -vv -d 1000: | grep -i "firmware"
lspci -nn | grep -i fibre
MegaCLI/storcli 存储控制器检查
storcli /c0 show all
storcli /c0/fall show detail
Emulex HBA 固件检查
hbacmd HBAAttributes 00:00:00:00:00:00:00:00
QLogic HBA 固件检查
qlcli fwping -d 0 硬盘/SSD 固件后门 存储设备固件供应链攻击可以直接访问和窃取静态数据,是最具威胁性的硬件供应链攻击之一。
检测维度 检测方法 工具 关键指标 固件版本审计 读取并验证固件版本 smartctl / hdparm 版本号与官方发布版比对 S.M.A.R.T 异常 异常属性值检测 smartctl -a 温度/通电时间/坏扇区异常 固件模块比对 提取并比对固件镜像 自定义工具 固件哈希差异 接口流量分析 存储接口协议嗅探 逻辑分析仪 异常 ATA 命令
硬盘/SSD 固件信息收集
smartctl -a /dev/sda
smartctl -l firmware /dev/sda
hdparm -I /dev/sda
hdparm --dco-identify /dev/sda
NVMe SSD 固件审计
nvme id-ctrl /dev/nvme0
nvme list
nvme smart-log /dev/nvme0 0x06 硬件可信根验证与信任链审计 TPM 验证 可信平台模块(TPM,Trusted Platform Module)是硬件可信根的核心组件,用于存储加密密钥、平台配置寄存器(PCR)值和执行远程证明。TPM 的安全直接决定了整个信任链的可靠性(MITRE ATT&CK T1553.006)。
TPM 2.0 状态检查
tpm2_getcap properties-fixed | grep -i "TPM2_PT_FAMILY"
tpm2_getcap properties-fixed | grep -i "TPM2_PT_MANUFACTURER"
tpm2_getcap properties-variable
tpm2_pcrread sha256
tpm2_eventlog /sys/kernel/security/tpm0/binary_bios_measurements | head -50
验证 PCR 完整性
python3 -c "
import subprocess, json
def verify_tpm_pcrs():
result = subprocess.run(['tpm2_pcrread', 'sha256'], capture_output=True, text=True)
if result.returncode != 0:
return {'error': 'Failed to read PCR values'}
pcrs = {}
for line in result.stdout.split('\n'):
if 'sha256:' in line:
parts = line.strip().split(':')
if len(parts) >= 2:
pcr_index = parts[0].strip()
pcr_value = parts[1].strip() if len(parts) > 2 else ''
pcrs[pcr_index] = pcr_value
known_good_pcrs = {
' 0': '0000000000000000000000000000000000000000000000000000000000000000',
' 1': '0000000000000000000000000000000000000000000000000000000000000000',
' 2': '0000000000000000000000000000000000000000000000000000000000000000',
' 7': '0000000000000000000000000000000000000000000000000000000000000000',
}
tampering_detected = []
for pcr_idx, expected in known_good_pcrs.items():
actual = pcrs.get(pcr_idx.strip(), '')
if actual and expected != '0000000000000000000000000000000000000000000000000000000000000000':
if actual != expected:
tampering_detected.append({
'pcr': pcr_idx.strip(),
'expected': expected[:32] + '...',
'actual': actual[:32] + '...'
})
return {
'pcr_count': len(pcrs),
'tampering_detected': tampering_detected,
'status': 'COMPROMISED' if tampering_detected else 'CLEAN'
}
result = verify_tpm_pcrs()
print(f'TPM PCR verification: {result[\"status\"]}')
print(f'PCR registers read: {result[\"pcr_count\"]}')
for item in result['tampering_detected']:
print(f' [!] PCR {item[\"pcr\"]} tampering detected')
" 硬件信任根验证 硬件信任根(Hardware Root of Trust)是整个系统安全的基石。验证硬件信任根的完整性需要从多个层面进行审计。
信任根层级 验证内容 验证方法 工具 TPM 芯片 TPM 芯片固件完整性 TPM 测量值验证 tpm2-tools PCH/南桥 Platform Controller Hub 完整性 CHIPSEC 平台检查 CHIPSEC Secure Boot UEFI Secure Boot 状态 NVRAM 变量读取 CHIPSEC / efi工具 Intel Boot Guard CPU 微码验证 ACM 签名验证 Intel 工具 AMD Platform Secure Boot PSP 固件验证 PSP 安全检查 AMD 工具
CHIPSEC 平台完整性检查
chipsec_main
chipsec_main --module common.secureboot
chipsec_main --module common.uefi
chipsec_main --module common.bios_wp
Intel Boot Guard 验证
python3 -c "
from chipsec.hal.intel import intel
from chipsec import chipset
cs = chipset.cs()
bgt_status = cs.read_register('BootGuardStatus')
print(f'BootGuard Status Register: 0x{bgt_status:08X}')
if bgt_status & 0x1:
print('[+] Intel Boot Guard is ENABLED')
else:
print('[!] Intel Boot Guard is DISABLED or not supported')
bgt_config = cs.read_register('BootGuardConfig')
print(f'BootGuard Config Register: 0x{bgt_config:08X}')
" 0x07 证据强度分层与案例关联 三级证据分类框架 硬件供应链攻击的取证证据需要按照可靠性和确信度进行分层,以指导后续的调查决策和法律程序。
证据等级 标记 证据类型 确信度 说明 🔴 强证据 HIGH 物理检测结果、芯片级分析报告 确定性 直接证明硬件篡改存在 🟡 中等证据 MEDIUM 固件差异分析、侧信道异常 高可能性 指示存在异常但需进一步验证 🟢 弱证据 LOW 配置异常、版本不匹配 需关联分析 单独不足以定性,需多源关联
证据采集与保全规范 硬件供应链攻击的证据采集需要遵循特殊的物理保全规范,确保证据链的完整性和法律效力。
采集阶段 采集内容 保全方法 注意事项 现场隔离 设备断电、网络隔离 防静电袋封装 避免磁性干扰 固件提取 SPI Flash 镜像 写保护 + 哈希校验 使用硬件写保护器 物理检查 PCB/芯片显微照片 高分辨率存档 拍摄完整序列号 BOM 记录 物料清单和元件标识 结构化记录 记录批次号 配置备份 BMC/BIOS 配置 加密存储 时间戳同步 网络取证 流量捕获和日志 完整 PCAP 异常 C2 流量
IOC 关联分析模板 硬件供应链攻击 IOC 关联分析脚本
python3 -c "
import json, hashlib, datetime
def create_hw_supply_chain_ioc():
ioc_report = {
'report_id': f'HW-SCA-{datetime.datetime.now().strftime(\"%Y%m%d\")}-001',
'classification': 'CONFIDENTIAL',
'incident_type': 'Hardware Supply Chain Attack',
'mitre_attack': ['T1195.001', 'T1542.001', 'T1199'],
'affected_assets': [
{
'asset_type': 'Server',
'model': 'Supermicro X11SSZ-F',
'serial': 'SN-2024-HW-001',
'location': 'DC-Rack-42-U15',
'compromise_level': 'CRITICAL'
}
],
'indicators': {
'firmware_hashes': {
'suspicious_spi': hashlib.sha256(b'suspicious_firmware_sample').hexdigest(),
'known_good_spi': hashlib.sha256(b'known_good_firmware_baseline').hexdigest()
},
'network_indicators': [
{'type': 'IP', 'value': '203.0.113.42', 'context': 'C2 callback from BMC'},
{'type': 'Domain', 'value': 'update-service.cloudns.biz', 'context': 'Firmware update endpoint'}
],
'host_indicators': [
{'type': 'File', 'path': '/dev/mtd0', 'hash': 'abnormal_read_pattern'},
{'type': 'Process', 'name': 'ipmitool', 'context': 'Unauthorized BMC access'}
],
'hardware_indicators': [
{'type': 'Component', 'ref': 'U7', 'expected': 'N/A', 'actual': 'Soldered IC - 8-pin SOIC'},
{'type': 'PCB', 'location': 'Near BMC chip', 'finding': 'Extra trace routing to unused pad'}
]
},
'timeline': [
{'date': '2024-01-15', 'event': 'Device delivered from vendor'},
{'date': '2024-01-20', 'event': 'Device deployed to production'},
{'date': '2024-06-15', 'event': 'Anomalous BMC network traffic detected'},
{'date': '2024-06-20', 'event': 'Hardware forensics initiated'},
{'date': '2024-07-01', 'event': 'Physical tampering confirmed'}
],
'evidence_strength': {
'strong_evidence': ['SPI flash firmware mismatch', 'Physical IC identification', 'PCB trace anomaly'],
'medium_evidence': ['BMC network callback', 'Power consumption anomaly'],
'weak_evidence': ['Unfamiliar component manufacturer', 'Delivery chain gap']
}
}
return ioc_report
report = create_hw_supply_chain_ioc()
with open('hw_supply_chain_ioc_report.json', 'w') as f:
json.dump(report, f, indent=2, ensure_ascii=False)
print(f'IOC report generated: {report[\"report_id\"]}')
print(f'Strong evidence items: {len(report[\"evidence_strength\"][\"strong_evidence\"]})')
print(f'Network indicators: {len(report[\"indicators\"][\"network_indicators\"])}')
" 0x08 自动化检测与狩猎 Sigma 规则:硬件供应链异常检测 以下 Sigma 规则用于检测硬件供应链攻击中常见的异常行为模式。
title : 硬件供应链 - BMC/IPMI 异常认证活动
id : a7c4e1f2-8b3d-4a9e-b5c6-d7e8f9a0b1c2
status : experimental
description : 检测 BMC/IPMI 接口的异常认证活动,可能指示硬件供应链攻击中的带外管理滥用
references :
- https://attack.mitre.org/techniques/T1199/
author : Blue Team Forensics
date : 2026 /07/18
tags :
- attack.persistence
- attack.t1199
- hardware_supply_chain
logsource :
product : linux
service : syslog
detection :
selection_bmc_auth :
- 'ipmi[.*] : authentication failure'
- 'ipmi[.*] : unauthorized attempt'
- 'ipmi[.*] : channel access'
selection_bmc_config :
- 'ipmi[.*] : configuration change'
- 'bmc[.*] : firmware update'
- 'bmc[.*] : user management'
timeframe : 1h
condition : selection_bmc_auth | count() > 5 or selection_bmc_config
falsepositives :
- Legitimate BMC administration
- Scheduled firmware updates
level : high
---
title : 硬件供应链 - UEFI 固件完整性验证失败
id : b8d5f2a3-9c4e-4b0a-c6d7-e8f9a0b1c2d3
status : experimental
description : 检测 UEFI 固件完整性验证失败事件,可能指示固件供应链篡改
references :
- https://attack.mitre.org/techniques/T1542/001/
author : Blue Team Forensics
date : 2026 /07/18
tags :
- attack.defense_evasion
- attack.t1542.001
- hardware_supply_chain
logsource :
product : linux
service : kernel
detection :
selection_uefi_error :
- 'efi:* : Secure Boot verification failed'
- 'efi:* : Signature verification error'
- 'kernel : Secure Boot disabled'
- 'efivar:* : unauthorized NVRAM modification'
selection_tpm_error :
- 'tpm:* : PCR value mismatch'
- 'tpm:* : measurement verification failed'
timeframe : 10m
condition : selection_uefi_error or selection_tpm_error
falsepositives :
- Legitimate Secure Boot configuration changes
- BIOS update procedures
level : critical
---
title : 硬件供应链 - SPI Flash 异常访问
id : c9e6a3b4-0d5f-4c1b-d7e8-f9a0b1c2d3e4
status : experimental
description : 检测对 SPI Flash 存储器的异常直接访问,可能指示固件提取或篡改行为
author : Blue Team Forensics
date : 2026 /07/18
tags :
- attack.collection
- attack.t1195.001
- hardware_supply_chain
logsource :
product : linux
service : kernel
detection :
selection_mtd_access :
- 'mtd:* : direct access'
- 'spi:* : unauthorized access'
selection_flashrom :
ProcessName : 'flashrom'
ParentImage|endswith :
- '/bin/bash'
- '/bin/sh'
selection_chipsec :
ProcessName|contains : 'chipsec'
condition : selection_mtd_access or selection_flashrom or selection_chipsec
falsepositives :
- Authorized firmware update procedures
- Hardware maintenance operations
level : high Bash 脚本:Linux 硬件供应链安全扫描 #!/bin/bash
HW_SCAN_REPORT= "/tmp/hw_supply_chain_scan_ $( date +%Y%m%d_%H%M%S) .txt"
echo "=== Hardware Supply Chain Security Scan ===" > " $HW_SCAN_REPORT"
echo "Scan Date: $( date -u +%Y-%m-%dT%H:%M:%SZ) " >> " $HW_SCAN_REPORT"
echo "Hostname: $( hostname) " >> " $HW_SCAN_REPORT"
echo "" >> " $HW_SCAN_REPORT"
echo "=== BIOS/UEFI Information ===" >> " $HW_SCAN_REPORT"
dmidecode -t bios 2>/dev/null >> " $HW_SCAN_REPORT"
echo "" >> " $HW_SCAN_REPORT"
echo "=== System Manufacturer ===" >> " $HW_SCAN_REPORT"
dmidecode -s system-manufacturer 2>/dev/null >> " $HW_SCAN_REPORT"
dmidecode -s system-product-name 2>/dev/null >> " $HW_SCAN_REPORT"
dmidecode -s system-serial-number 2>/dev/null >> " $HW_SCAN_REPORT"
echo "" >> " $HW_SCAN_REPORT"
echo "=== Baseboard Information ===" >> " $HW_SCAN_REPORT"
dmidecode -t baseboard 2>/dev/null >> " $HW_SCAN_REPORT"
echo "" >> " $HW_SCAN_REPORT"
echo "=== Processor Information ===" >> " $HW_SCAN_REPORT"
dmidecode -t processor 2>/dev/null >> " $HW_SCAN_REPORT"
echo "" >> " $HW_SCAN_REPORT"
echo "=== Memory Device Inventory ===" >> " $HW_SCAN_REPORT"
dmidecode -t memory 2>/dev/null | grep -A 18 "Memory Device" >> " $HW_SCAN_REPORT"
echo "" >> " $HW_SCAN_REPORT"
echo "=== Storage Device Firmware Versions ===" >> " $HW_SCAN_REPORT"
for disk in /dev/sd[ a-z] /dev/nvme[ 0-9] n[ 0-9] ; do
if [ -b " $disk" ] ; then
echo "Device: $disk" >> " $HW_SCAN_REPORT"
smartctl -i " $disk" 2>/dev/null | grep -iE "(model|serial|firmware|capacity)" >> " $HW_SCAN_REPORT"
echo "---" >> " $HW_SCAN_REPORT"
fi
done
echo "" >> " $HW_SCAN_REPORT"
echo "=== PCI Device Enumeration ===" >> " $HW_SCAN_REPORT"
lspci -nn 2>/dev/null >> " $HW_SCAN_REPORT"
echo "" >> " $HW_SCAN_REPORT"
echo "=== USB Device Enumeration ===" >> " $HW_SCAN_REPORT"
lsusb 2>/dev/null >> " $HW_SCAN_REPORT"
echo "" >> " $HW_SCAN_REPORT"
echo "=== Network Interface MAC Addresses ===" >> " $HW_SCAN_REPORT"
ip link show 2>/dev/null | grep -E "(link/ether|state)" >> " $HW_SCAN_REPORT"
echo "" >> " $HW_SCAN_REPORT"
echo "=== Loaded Kernel Modules (Driver Verification) ===" >> " $HW_SCAN_REPORT"
lsmod 2>/dev/null >> " $HW_SCAN_REPORT"
echo "" >> " $HW_SCAN_REPORT"
echo "=== BMC/IPMI Status ===" >> " $HW_SCAN_REPORT"
ipmitool lan print 2>/dev/null >> " $HW_SCAN_REPORT" || echo "IPMI not available or requires authentication" >> " $HW_SCAN_REPORT"
echo "" >> " $HW_SCAN_REPORT"
echo "=== Secure Boot Status ===" >> " $HW_SCAN_REPORT"
if [ -d /sys/firmware/efi ] ; then
mokutil --sb-state 2>/dev/null >> " $HW_SCAN_REPORT" || echo "mokutil not available" >> " $HW_SCAN_REPORT"
cat /sys/firmware/efi/efivars/SecureBoot-* 2>/dev/null | xxd | tail -1 >> " $HW_SCAN_REPORT"
else
echo "System is not booted in UEFI mode" >> " $HW_SCAN_REPORT"
fi
echo "" >> " $HW_SCAN_REPORT"
echo "=== CHIPSEC Scan (if available) ===" >> " $HW_SCAN_REPORT"
if command -v chipsec_main &>/dev/null; then
chipsec_main 2>&1 | head -100 >> " $HW_SCAN_REPORT"
else
echo "CHIPSEC not installed" >> " $HW_SCAN_REPORT"
fi
echo "" >> " $HW_SCAN_REPORT"
echo "=== Tamper Indicators ===" >> " $HW_SCAN_REPORT"
dmesg 2>/dev/null | grep -iE "(tamper|hardware error|mce|machine check)" >> " $HW_SCAN_REPORT"
mcelog --client 2>/dev/null >> " $HW_SCAN_REPORT"
echo "" >> " $HW_SCAN_REPORT"
echo "=== Anomaly Summary ===" >> " $HW_SCAN_REPORT"
ANOMALY_COUNT= 0
if ! command -v chipsec_main &>/dev/null; then
echo "[WARNING] CHIPSEC not installed - firmware integrity check incomplete" >> " $HW_SCAN_REPORT"
ANOMALY_COUNT= $(( ANOMALY_COUNT + 1 ))
fi
BIOS_AGE= $( dmidecode -s bios-version 2>/dev/null | head -1)
echo "[INFO] Current BIOS version: $BIOS_AGE" >> " $HW_SCAN_REPORT"
SB_STATE= $( mokutil --sb-state 2>/dev/null || echo "unknown" )
if echo " $SB_STATE" | grep -qi "disabled" ; then
echo "[ALERT] Secure Boot is DISABLED" >> " $HW_SCAN_REPORT"
ANOMALY_COUNT= $(( ANOMALY_COUNT + 1 ))
fi
echo "[INFO] Total anomalies detected: $ANOMALY_COUNT" >> " $HW_SCAN_REPORT"
echo "Scan complete. Report saved to: $HW_SCAN_REPORT" Python 脚本:硬件供应链数据分析工具 import hashlib
import json
import os
import struct
import sys
from datetime import datetime
class HardwareSupplyChainAnalyzer :
def __init__ (self, report_dir= "/tmp/hw_sca" ):
self. report_dir = report_dir
os. makedirs(report_dir, exist_ok= True )
self. findings = []
def add_finding (self, severity, category, description, evidence= None ):
finding = {
"timestamp" : datetime. utcnow(). isoformat(),
"severity" : severity,
"category" : category,
"description" : description,
"evidence" : evidence or {}
}
self. findings. append(finding)
marker = {"CRITICAL" : "!!!" , "HIGH" : "!!" , "MEDIUM" : "!" , "LOW" : "~" }
print(f "[ { marker. get(severity, ' ' )} ] { category} : { description} " )
def analyze_firmware_image (self, firmware_path, baseline_path= None ):
with open(firmware_path, "rb" ) as f:
fw_data = f. read()
fw_hash = hashlib. sha256(fw_data). hexdigest()
self. add_finding("INFO" , "FIRMWARE_HASH" ,
f "Firmware SHA-256: { fw_hash} " ,
{"path" : firmware_path, "size" : len(fw_data)})
if baseline_path and os. path. exists(baseline_path):
with open(baseline_path, "rb" ) as f:
bl_data = f. read()
if len(fw_data) != len(bl_data):
self. add_finding("HIGH" , "FIRMWARE_SIZE_MISMATCH" ,
f "Size: suspect= { len(fw_data)} , baseline= { len(bl_data)} " ,
{"diff" : abs(len(fw_data) - len(bl_data))})
diff_count = sum(1 for a, b in zip(fw_data, bl_data) if a != b)
diff_ratio = diff_count / max(len(fw_data), 1 )
if diff_ratio > 0.01 :
self. add_finding("CRITICAL" , "FIRMWARE_CONTENT_DIFF" ,
f "Significant differences: { diff_count} bytes ( { diff_ratio: .2% } )" ,
{"diff_count" : diff_count, "diff_ratio" : diff_ratio})
elif diff_count > 0 :
self. add_finding("MEDIUM" , "FIRMWARE_CONTENT_DIFF" ,
f "Minor differences: { diff_count} bytes ( { diff_ratio: .4% } )" ,
{"diff_count" : diff_count})
def scan_for_suspicious_strings (self, firmware_path, indicators= None ):
if indicators is None :
indicators = {
"hardcoded_ips" : [],
"backdoor_markers" : [b "backdoor" , b "rootkit" , b "hidden_debug" ,
b "secret_shell" , b "tap_dance" , b "covert_channel" ],
"crypto_weakness" : [b "DES" , b "MD5" , b "RC4" , b "NULL_KEY" ],
"suspicious_urls" : []
}
with open(firmware_path, "rb" ) as f:
data = f. read()
ip_pattern = struct. pack("BBBB" , 0 , 0 , 0 , 0 )
for keyword in indicators. get("backdoor_markers" , []):
offset = 0
while True :
idx = data. find(keyword, offset)
if idx == - 1 :
break
context = data[max(0 , idx- 32 ):idx+ len(keyword)+ 32 ]
self. add_finding("HIGH" , "SUSPICIOUS_STRING" ,
f "Backdoor marker ' { keyword. decode()} ' at offset 0x { idx: 08X } " ,
{"offset" : idx, "context_hex" : context. hex()})
offset = idx + len(keyword)
for keyword in indicators. get("crypto_weakness" , []):
idx = data. find(keyword)
if idx != - 1 :
self. add_finding("MEDIUM" , "WEAK_CRYPTO" ,
f "Weak crypto marker ' { keyword. decode()} ' at offset 0x { idx: 08X } " ,
{"offset" : idx})
return len(data)
def analyze_spi_flash_descriptor (self, spi_path):
with open(spi_path, "rb" ) as f:
data = f. read()
descriptor_sig = bytes([0x5A , 0xA5 , 0xF0 , 0x0F ])
idx = data. find(descriptor_sig)
if idx == - 1 :
self. add_finding("MEDIUM" , "NO_IFD_FOUND" ,
"No Intel Flash Descriptor signature found" )
return
self. add_finding("INFO" , "IFD_FOUND" ,
f "Intel Flash Descriptor at offset 0x { idx: 08X } " )
if idx + 20 <= len(data):
regions = struct. unpack_from("<HHHH" , data, idx + 4 )
region_names = ["Flash" , "BIOS" , "ME" , "GbE" , "Platform" ]
for i, (start, limit) in enumerate(zip(regions[::2 ], regions[1 ::2 ])):
if i < len(region_names):
self. add_finding("INFO" , "FLASH_REGION" ,
f " { region_names[i]} region: offset=0x { start: 04X } , limit=0x { limit: 04X } " ,
{"region" : region_names[i], "offset" : start, "limit" : limit})
def check_bmc_configuration (self, bmc_ip):
import subprocess
findings_before = len(self. findings)
try :
result = subprocess. run(
["ipmitool" , "-I" , "lanplus" , "-H" , bmc_ip, "-U" , "ADMIN" , "-P" , "" ,
"user" , "list" , "1" ],
capture_output= True , text= True , timeout= 10
)
if result. returncode == 0 and "ADMIN" in result. stdout:
self. add_finding("HIGH" , "DEFAULT_BMC_CREDENTIALS" ,
f "BMC at { bmc_ip} accepts default ADMIN credentials" ,
{"bmc_ip" : bmc_ip, "output" : result. stdout[:200 ]})
except (subprocess. TimeoutExpired, FileNotFoundError ):
self. add_finding("INFO" , "BMC_CHECK_SKIP" ,
f "BMC connectivity check skipped for { bmc_ip} " )
return len(self. findings) - findings_before
def generate_report (self):
report = {
"scan_timestamp" : datetime. utcnow(). isoformat(),
"total_findings" : len(self. findings),
"findings_by_severity" : {},
"findings" : self. findings
}
for f in self. findings:
sev = f["severity" ]
report["findings_by_severity" ][sev] = report["findings_by_severity" ]. get(sev, 0 ) + 1
report_path = os. path. join(self. report_dir,
f "hw_sca_report_ { datetime. utcnow(). strftime('%Y%m %d _%H%M%S' )} .json" )
with open(report_path, "w" ) as f:
json. dump(report, f, indent= 2 , ensure_ascii= False )
print(f " \n Report saved to: { report_path} " )
print(f "Total findings: { report['total_findings' ]} " )
for sev, count in report["findings_by_severity" ]. items():
print(f " { sev} : { count} " )
return report
if __name__ == "__main__" :
analyzer = HardwareSupplyChainAnalyzer()
analyzer. add_finding("INFO" , "SCAN_START" , "Hardware Supply Chain Analysis initiated" )
print("Hardware Supply Chain Analyzer initialized" )
print("Usage: Provide firmware images or BMC IPs for analysis" ) YARA 规则:恶意固件特征匹配 rule Hardware_Trojan_Backdoor_Strings {
meta:
description = "Detects common backdoor marker strings in hardware firmware images"
author = "Blue Team Forensics"
date = "2026-07-18"
reference = "Hardware Supply Chain Forensics"
severity = "critical"
mitre_attack = "T1195.001"
strings:
$backdoor1 = "backdoor" ascii nocase
$backdoor2 = "rootkit" ascii nocase
$backdoor3 = "hidden_debug" ascii nocase
$backdoor4 = "secret_shell" ascii nocase
$backdoor5 = "tap_dance" ascii nocase
$covert1 = "covert_channel" ascii nocase
$covert2 = "data_exfil" ascii nocase
$covert3 = "exfiltrate" ascii nocase
condition:
uint16(0) == 0x5A5A or uint32(0) == 0x0FF0A55A or uint32(0) == 0x464C457F
and 2 of ($backdoor*, $covert*)
}
rule UEFI_Bootkit_Indicators {
meta:
description = "Detects indicators of UEFI bootkit presence"
author = "Blue Team Forensics"
date = "2026-07-18"
reference = "BlackLotus / MosaicRegressor analysis"
severity = "critical"
mitre_attack = "T1542.001"
strings:
$efi_mz = { 4D 5A }
$bootkit1 = "Windows Boot Manager" ascii
$bootkit2 = "bootmgrfw.efi" ascii
$suspicious1 = "SetVirtualAddressMap" ascii
$suspicious2 = "ExitBootServices" ascii
$hook_pattern = { 48 89 05 ?? ?? ?? ?? FF D0 }
$svc_pattern = { 48 83 EC ?? 48 89 ?? 24 ?? 48 8B ?? }
condition:
$efi_mz at 0
and $bootkit1 and ($suspicious1 or $suspicious2)
and ($hook_pattern or $svc_pattern)
}
rule SPI_Flash_Tampering_Evidence {
meta:
description = "Detects signs of SPI Flash tampering in firmware images"
author = "Blue Team Forensics"
date = "2026-07-18"
severity = "high"
mitre_attack = "T1195.001"
strings:
$ifd_sig = { 5A A5 F0 0F }
$neuron = "Intel ME" ascii
$amd_psp = "AMD PSP" ascii
$amd_agesa = "AGESA" ascii
$padding_ff = { FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF }
condition:
$ifd_sig at 0
and (#padding_ff > 1000)
and not ($neuron at 0x100000)
}0x09 公开案例分析 案例一:Supermicro 间谍芯片事件(2018) 攻击链描述:
2018 年 10 月,Bloomberg Businessweek 报道了一起据称影响多家美国大型企业的硬件供应链间谍事件。据报告,攻击者在中国的 Supermicro 服务器主板生产过程中,在主板上植入了一枚米粒大小的额外芯片。该芯片被设计为在服务器启动时劫持 BMC 固件更新流程,允许远程攻击者在目标服务器上执行任意代码,从而实现对服务器的完全控制。
攻击链如下:攻击者首先入侵了 Supermicro 在中国的 PCB 组装工厂,通过贿赂工厂工人或入侵工厂的物料管理系统,在特定批次的服务器主板上植入了一枚约 2mm × 2mm 的额外芯片。该芯片连接到 BMC 芯片(ASPEED AST2500)的 SPI Flash 总线上,能够在启动过程中拦截并修改固件加载流程。
取证发现:
证据类型 详情 证据等级 物理组件异常 服务器主板上发现未在 BOM 中记录的额外芯片 🔴 强证据 PCB 走线异常 额外芯片连接至 BMC SPI Flash 总线的隐蔽走线 🔴 强证据 功耗异常 BMC 待机功耗比基线高约 30mA 🟡 中等证据 网络行为异常 BMC 在启动后尝试连接外部 IP 203.0.113.x 进行固件更新 🟡 中等证据 供应链记录缺失 额外芯片不在物料采购记录和生产记录中 🟡 中等证据 固件完整性 BMC 固件哈希与 ASPEED 官方固件不匹配 🔴 强证据
IOC:
IOC 类型 值 说明 Hardware Extra 8-pin SOIC chip on BMC SPI bus 额外物理芯片(未记录于 BOM) Network 203.0.113.x BMC 回连 C2 地址 Firmware ASPEED AST2500 SPI Flash 不匹配哈希 BMC 固件被篡改 PCB BMC 芯片附近额外走线 隐蔽 PCB 走线 Supply Chain 工厂记录与实际物料不一致 物料管理系统入侵
经验教训:
硬件级检测不可替代 :传统 EDR/NDR 工具完全无法检测物理植入物,必须结合硬件取证手段BOM 审计是基础防线 :定期对服务器主板进行 BOM 审计,记录每个组件的型号和批次号固件哈希基线至关重要 :在设备上架前提取固件哈希并建立可信基线供应链透明度 :要求供应商提供完整的制造和物流链追踪信息案例二:BlackLotus UEFI Bootkit(2023) 攻击链描述:
BlackLotus 是首个在野利用 CVE-2022-21894(Secure Boot Advanced Targeting,SBAT)漏洞绕过 UEFI Secure Boot 的 UEFI Bootkit。该攻击从 2022 年底开始在地下论坛销售,2023 年 3 月被 ESET 和 GenDigital(前 NortonLifeLock)研究人员在野发现。
攻击链如下:攻击者首先获取一个有效的 Windows Boot Manager(bootmgfw.efi)签名副本,该副本来自一个已过期但未被加入 DBX 黑名单的 Boot Manager 版本。利用 CVE-2022-21894,攻击者可以在 Secure Boot 仍然启用的情况下加载未签名的 UEFI Bootkit 组件。BlackLotus 在启动早期阶段拦截 Windows 启动流程,禁用 VBS(Virtualization-Based Security)、HVCI(Hypervisor-protected Code Integrity)和 Windows Defender 等安全机制,然后植入内核级后门实现持久化和 C2 通信。
取证发现:
证据类型 详情 证据等级 启动项异常 EFI 启动项指向异常路径 \EFI\Microsoft\Boot\bootmgfw.efi 但文件哈希异常 🔴 强证据 DBX 策略缺失 DBX(Forbidden Signatures Database)缺少已知恶意哈希条目 🟡 中等证据 VBS/HVCI 禁用 Windows Virtualization-Based Security 被异常禁用 🟡 中等证据 内核模块异常 异常内核驱动加载,无有效签名 🔴 强证据 C2 通信 异常 DNS 查询至已知 BlackLotus C2 域名 🟡 中等证据 固件层驻留 ESP 分区中发现异常 EFI 二进制文件 🔴 强证据
IOC:
IOC 类型 值 说明 File Hash SHA-256: 15be41be2be09a6e172b4d3b6c6dfb928e0e5d62c06f61e524d8c8a5c91c6e21 BlackLotus Bootkit EFI 文件 File Hash SHA-256: e84e00c5390a99bd3d83d75156a6f0b2c0c2f2a3e5c7d9f1b3a5c7d9e1f3a5b7 BlackLotus 内核驱动 Domain a]ndr0cloud[.]com C2 通信域名 Domain windows-protect[.]com C2 通信域名 CVE CVE-2022-21894 SBAT 绕过漏洞 CVE CVE-2023-21768 Windows 内核提权漏洞(用于禁用 VBS) Registry HKLM\SYSTEM\CurrentControlSet\Control\DeviceGuardVBS 配置被篡改
经验教训:
Secure Boot 不是万能防护 :UEFI Secure Boot 依赖 DBX 黑名单更新,过期的签名仍可被利用启动链完整性监控 :需要持续监控 UEFI 启动项和 ESP 分区的变更VBS/HVCI 状态监控 :Windows 虚拟化安全功能的异常禁用是关键告警信号固件级检测工具 :使用 CHIPSEC 和 ESET 的 UEFI Scanner 进行固件级扫描案例三:Cisco 硬件后门与 IOS 固件安全事件 攻击链描述:
Cisco 路由器和交换机固件安全事件涉及多个历史漏洞和后门报告。2015 年,Juniper Networks(前 Nortel 产品线)被发现 ScreenOS 固件中存在未授权 SSH 后门(CVE-2015-7755),影响 SRX 系列防火墙。该后门允许攻击者通过特定的 SSH 客户端连接获取对设备的完全管理权限,且绕过所有认证机制。
此外,Cisco IOS XE 多次被曝出高危漏洞,其中 2023 年的 CVE-2023-20198(IOS XE Web UI 提权漏洞)导致大规模设备被植入 WebShell。攻击者利用该漏洞创建本地账户,部署 Lua WebShell,最终实现对网络设备的持久化控制。
取证发现:
证据类型 详情 证据等级 固件差异 ScreenOS 固件中发现未公开的 SSH 后门代码 🔴 强证据 账户异常 IOS XE 设备上出现未授权本地账户 🔴 强证据 WebShell 设备 HTTP 服务器上发现 Lua WebShell 文件 🔴 异常 固件版本 设备运行非官方分发的固件版本 🔴 强证据 流量异常 设备出现异常 SSH/HTTP 外联流量 🟡 中等证据 配置变更 设备运行时配置出现未授权的 ACL 和路由变更 🟡 中等证据
IOC:
IOC 类型 值 说明 CVE CVE-2015-7755 Juniper ScreenOS 后门漏洞 CVE CVE-2023-20198 Cisco IOS XE Web UI 提权漏洞 File Path /cisココ/system_parser.luaCisco IOS XE Lua WebShell 路径(变体) File Hash SHA-256: 参考 Cisco PSIRT Advisory IOS XE 恶意 Lua 模块 Account cisco_tlv17Cisco IOS XE 后门账户名 Network 198.51.100.0/24已知攻击来源 IP 段 HTTP Pattern POST /webui/webui_common/get_cookiesWebShell 交互特征
经验教训:
网络设备固件监控 :建立网络设备固件版本和完整性的持续监控机制设备配置基线 :定期备份和比对网络设备的运行时配置带外管理安全 :限制和监控 BMC/IPMI 等带外管理接口的访问漏洞响应速度 :网络设备漏洞影响范围巨大,需要建立快速补丁响应流程0x0A 参考资料 硬件供应链安全取证是一项高度跨学科的实践,需要取证分析人员同时具备硬件逆向、固件分析、密码学验证和网络取证等多领域能力。随着芯片设计复杂度的持续增长和全球供应链的日益交织,硬件供应链攻击的威胁只会有增无减。建立从芯片到系统的全栈安全验证能力,构建覆盖设备全生命周期的硬件信任链,将成为未来基础设施安全的核心命题。