关于 firmware-analyst
面向嵌入式设备安全研究者的固件分析技能,用于授权检查固件镜像、文件系统和二进制文件,并规划隔离仿真与修复报告。部分仿真步骤依赖未随目录副本提供的脚本,使用前需确认原始材料可用。
主要功能
- 01固件识别与文件系统提取
- 02架构识别和二进制分析
- 03漏洞类别与配置检查
- 04隔离仿真和安全评估报告
- 05授权确认及缺失脚本提示
适用场景
- 01分析获准检查的固件镜像
- 02检查提取文件系统中的安全问题
- 03规划隔离的固件仿真
- 04整理嵌入式设备修复报告
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ sickn33/ agentic-awesome-skills --skill firmware-analyst安装后在 Claude Code 中输入/firmware-analyst确认已加载。
详细介绍
支持材料可用性
本目录副本包含以下内联指南,但不包含以下支持路径。这些路径属于外部前置条件,并非随附文件:
./scripts/getArch.sh./scripts/makeImage.sh./scripts/inferNetwork.sh
在使用依赖这些路径的步骤前,请索取原始支持材料或现有安装;本目录未提供经验证的下载来源。请根据该安装解析每个路径,检查其内容,并核实适用的许可证和执行前置条件。所需文件不存在时,不要运行命令,也不要声称已遵循所引用的流程。不要伪造缺失脚本,也不要将名称相同但无关的文件视为等效文件。此处已完整说明且可独立执行的步骤,可在用户授权范围内进行;请将任何依赖项缺失的步骤报告为不可用。
⚠️ 仅限授权用途 此技能仅用于教育目的或经授权的安全评估。 使用此工具前,必须获得系统所有者明确的书面许可。 滥用此工具属于违法行为,且受到严格禁止。
强制确认关卡 在运行任何会探测、利用、更改目标、在目标上建立持久访问、从目标提取数据或尝试访问目标凭据的命令前:
- 请用户说明确切的目标 URL、IP、账户或资源。
- 请用户确认已获得书面授权,并说明允许的范围。
- 展示确切的命令,并解释其预期效果。
- 等待用户在当前对话中明确确认。
未获得上述确认时,只能进行只读操作,并仅提供防御性指导。优先使用沙盒、一次性 VM 或受控实验环境。
固件获取(示例)
# Download only from the verified vendor HTTPS source; preserve its hash/signature.
# Substitute the actual approved URL, not this placeholder.
wget https://vendor.example.invalid/firmware/update.bin
# Extract from device via debug interface
# UART console access
screen /dev/ttyUSB0 115200
# Copy firmware partition
dd if=/dev/mtd0 of=/tmp/firmware.bin
# Extract via network protocols
# TFTP during boot
# HTTP/FTP from device web interface
硬件方法
UART access - Serial console connection
JTAG/SWD - Debug interface for memory access
SPI flash dump - Direct chip reading
NAND/NOR dump - Flash memory extraction
Chip-off - Physical chip removal and reading
Logic analyzer - Protocol capture and analysis
适用场景
- 检查经授权的嵌入式固件映像、已提取的文件系统或二进制安全属性
- 规划受控获取、仿真以及以修复为导向的报告
不适用场景
- 任务与从供应商处下载无关
- 需要使用本范围之外的其他领域或工具
说明
- 明确目标、限制和所需输入。
- 应用相关最佳实践并验证结果。
- 提供可执行的步骤和验证方法。
提取与仿真隔离
保持原始固件不可变,并记录哈希值、来源和版本。以非特权用户身份,在一次性 VM 中提取不受信任的映像,并设置输出和资源限制,且不得接触主机机密或外部网络。chroot 不是安全沙盒:仅可在该隔离 VM 内运行需要 root 权限的仿真实例。访问前,请检查提取出的符号链接和设备节点,并核实工具版本。不要打印或重复使用发现的凭据;请在报告中脱敏,并将发现限制在授权披露范围内。
固件分析工作流
阶段 1:识别
# Basic file identification
file firmware.bin
binwalk firmware.bin
# Entropy analysis (detect compression/encryption)
# Binwalk v3: generates entropy PNG graph
binwalk --entropy firmware.bin
binwalk -E firmware.bin # Short form
# Identify embedded file systems and auto-extract
binwalk --extract firmware.bin
binwalk -e firmware.bin # Short form
# String analysis
strings -a firmware.bin | grep -i "password\|key\|secret"
阶段 2:提取
# Binwalk v3 recursive extraction (matryoshka mode)
binwalk --extract --matryoshka firmware.bin
binwalk -eM firmware.bin # Short form
# Extract to custom directory
binwalk -e -C ./extracted firmware.bin
# Verbose output during recursive extraction
binwalk -eM --verbose firmware.bin
# Manual extraction for specific formats
# SquashFS
unsquashfs filesystem.squashfs
# JFFS2
jefferson filesystem.jffs2 -d output/
# UBIFS
ubireader_extract_images firmware.ubi
# YAFFS
unyaffs filesystem.yaffs
# Cramfs
cramfsck -x output/ filesystem.cramfs
阶段 3:文件系统分析
# Explore extracted filesystem
find . -name "*.conf" -o -name "*.cfg"
find . -name "passwd" -o -name "shadow"
find . -type f -executable
# Find hardcoded credentials
grep -r "password" .
grep -r "api_key" .
grep -rn "BEGIN RSA PRIVATE KEY" .
# Analyze web interface
find . -name "*.cgi" -o -name "*.php" -o -name "*.lua"
# Check for vulnerable binaries
checksec --dir=./bin/
阶段 4:二进制分析
# Identify architecture
file bin/httpd
readelf -h bin/httpd
# Load in Ghidra with correct architecture
# For ARM: specify ARM:LE:32:v7 or similar
# For MIPS: specify MIPS:BE:32:default
# Set up cross-compilation for testing
# ARM
arm-linux-gnueabi-gcc exploit.c -o exploit
# MIPS
mipsel-linux-gnu-gcc exploit.c -o exploit
常见漏洞类别
身份验证问题
Hardcoded credentials - Default passwords in firmware
Backdoor accounts - Hidden admin accounts
Weak password hashing - MD5, no salt
Authentication bypass - Logic flaws in login
Session management - Predictable tokens
命令注入
// Vulnerable pattern
char cmd[256];
sprintf(cmd, "ping %s", user_input);
system(cmd);
// Test payloads
; id
| cat /etc/passwd
`whoami`
$(id)
内存损坏
Stack buffer overflow - strcpy, sprintf without bounds
Heap overflow - Improper allocation handling
Format string - printf(user_input)
Integer overflow - Size calculations
Use-after-free - Improper memory management
信息泄露
Debug interfaces - UART, JTAG left enabled
Verbose errors - Stack traces, paths
Configuration files - Exposed credentials
Firmware updates - Unencrypted downloads
工具熟练度
提取工具
binwalk v3 - Firmware extraction and analysis (Rust rewrite, faster, fewer false positives)
firmware-mod-kit - Firmware modification toolkit
jefferson - JFFS2 extraction
ubi_reader - UBIFS extraction
sasquatch - SquashFS with non-standard features
分析工具
Ghidra - Multi-architecture disassembly
IDA Pro - Commercial disassembler
Binary Ninja - Modern RE platform
radare2 - Scriptable analysis
Firmware Analysis Toolkit (FAT)
FACT - Firmware Analysis and Comparison Tool
仿真
QEMU - Full system and user-mode emulation
Firmadyne - Automated firmware emulation
EMUX - ARM firmware emulator
qemu-user-static - Static QEMU for chroot emulation
Unicorn - CPU emulation framework
硬件工具
Bus Pirate - Universal serial interface
Logic analyzer - Protocol analysis
JTAGulator - JTAG/UART discovery
Flashrom - Flash chip programmer
ChipWhisperer - Side-channel analysis
仿真设置
QEMU 用户模式仿真
# Install QEMU user-mode
apt install qemu-user-static
# Copy QEMU static binary to extracted rootfs
cp /usr/bin/qemu-arm-static ./squashfs-root/usr/bin/
# Chroot into firmware filesystem
sudo chroot squashfs-root /usr/bin/qemu-arm-static /bin/sh
# Run specific binary
sudo chroot squashfs-root /usr/bin/qemu-arm-static /bin/httpd
使用 Firmadyne 进行全系统仿真
# Extract firmware
./sources/extractor/extractor.py -b brand -sql 127.0.0.1 \
-np -nk "firmware.bin" images
# Identify architecture and create QEMU image
./scripts/getArch.sh ./images/1.tar.gz
./scripts/makeImage.sh 1
# Infer network configuration
./scripts/inferNetwork.sh 1
# Run emulation
./scratch/1/run.sh
安全评估
检查清单
[ ] Firmware extraction successful
[ ] File system mounted and explored
[ ] Architecture identified
[ ] Hardcoded credentials search
[ ] Web interface analysis
[ ] Binary security properties (checksec)
[ ] Network services identified
[ ] Debug interfaces disabled
[ ] Update mechanism security
[ ] Encryption/signing verification
[ ] Known CVE check
报告模板
# Firmware Security Assessment
## Device Information
- Manufacturer:
- Model:
- Firmware Version:
- Architecture:
## Findings Summary
| Finding | Severity | Location |
|---------|----------|----------|
## Detailed Findings
### Finding 1: [Title]
- Severity: Critical/High/Medium/Low
- Location: /path/to/file
- Description:
- Proof of Concept:
- Remediation:
## Recommendations
1. ...
道德准则
适当用途
- 获得设备所有者授权的安全审计
- 漏洞赏金计划
- 学术研究
- CTF 竞赛
- 个人设备分析
绝不协助
- 未经授权地入侵设备
- 非法绕过 DRM/许可限制
- 创建恶意固件
- 未经许可攻击设备
- 工业间谍活动
响应方法
- 验证授权:确保研究场景合法
- 评估设备:了解目标设备类型和架构
- 指导获取:选择合适的固件提取方法
- 系统分析:遵循结构化分析工作流
- 识别问题:发现安全漏洞和错误配置
- 记录发现:清晰报告结果并提供修复指导
限制
- 仅当任务明确符合上述范围时,才使用此技能。
- 不要将输出视为环境特定验证、测试或专家审查的替代品。
- 如果缺少必要的输入、权限、安全边界或成功标准,请停止并要求澄清。
评论
支持 Markdown