| name | reverse-engineering-firmware-analysis |
| description | Firmware extraction and IoT security analysis (RE Level 5) for routers and embedded systems. Use when analyzing IoT firmware, extracting embedded filesystems (SquashFS/JFFS2/CramFS), finding hardcoded credentials, performing CVE scans, or auditing embedded system security. Handles encrypted firmware with known decryption schemes. Completes in 2-8 hours with binwalk+firmadyne+QEMU emulation. |
| allowed-tools | Read, Glob, Grep, Bash, Task, TodoWrite |
LIBRARY-FIRST PROTOCOL (MANDATORY)
Before writing ANY code, you MUST check:
Step 1: Library Catalog
- Location:
.claude/library/catalog.json
- If match >70%: REUSE or ADAPT
Step 2: Patterns Guide
- Location:
.claude/docs/inventories/LIBRARY-PATTERNS-GUIDE.md
- If pattern exists: FOLLOW documented approach
Step 3: Existing Projects
- Location:
D:\Projects\*
- If found: EXTRACT and adapt
Decision Matrix
| Match | Action |
|---|
| Library >90% | REUSE directly |
| Library 70-90% | ADAPT minimally |
| Pattern exists | FOLLOW pattern |
| In project | EXTRACT |
| No match | BUILD (add to library after) |
When to Use This Skill
Use this skill when analyzing malware samples, reverse engineering binaries for security research, conducting vulnerability assessments, extracting IOCs from suspicious files, validating software for supply chain security, or performing CTF challenges and binary exploitation research.
When NOT to Use This Skill
Do NOT use for unauthorized reverse engineering of commercial software, analyzing binaries on production systems, reversing software without legal authorization, violating terms of service or EULAs, or analyzing malware outside isolated environments. Avoid for simple string extraction (use basic tools instead).
Success Criteria
- All security-relevant behaviors identified (network, file, registry, process activity)
- Malicious indicators extracted with confidence scores (IOCs, C2 domains, encryption keys)
- Vulnerabilities documented with CVE mapping where applicable
- Analysis completed within sandbox environment (VM/container with snapshots)
- Findings validated through multiple analysis methods (static + dynamic + symbolic)
- Complete IOC report generated (STIX/MISP format for threat intelligence sharing)
- Zero false positives in vulnerability assessments
- Exploitation proof-of-concept created (if vulnerability research)
Edge Cases & Challenges
- Anti-analysis techniques (debugger detection, VM detection, timing checks)
- Obfuscated or packed binaries requiring unpacking
- Multi-stage malware with encrypted payloads
- Kernel-mode rootkits requiring specialized analysis
- Symbolic execution state explosion (>10,000 paths)
- Binary analysis timeout on complex programs (>24 hours)
- False positives from legitimate software behavior
- Encrypted network traffic requiring SSL interception
Guardrails (CRITICAL SECURITY RULES)
- NEVER execute unknown binaries on host systems (ONLY in isolated VM/sandbox)
- NEVER analyze malware without proper containment (air-gapped lab preferred)
- NEVER reverse engineer software without legal authorization
- NEVER share extracted credentials or encryption keys publicly
- NEVER bypass licensing mechanisms for unauthorized use
- ALWAYS use sandboxed environments with network monitoring
- ALWAYS take VM snapshots before executing suspicious binaries
- ALWAYS validate findings through multiple analysis methods
- ALWAYS document analysis methodology with timestamps
- ALWAYS assume binaries are malicious until proven safe
- ALWAYS use network isolation to prevent malware communication
- ALWAYS sanitize IOCs before sharing (redact internal IP addresses)
Evidence-Based Validation
All reverse engineering findings MUST be validated through:
- Multi-method analysis - Static + dynamic + symbolic execution confirm same behavior
- Sandbox validation - Execute in isolated environment, capture all activity
- Network monitoring - Packet capture validates network-based findings
- Memory forensics - Validate runtime secrets through memory dumps
- Behavioral correlation - Cross-reference with known malware signatures (YARA, ClamAV)
- Reproducibility - Second analyst can replicate findings from analysis artifacts
Reverse Engineering: Firmware Analysis
What This Skill Does
Extracts and analyzes firmware from IoT devices, routers, and embedded systems:
- Extraction (30min-2hrs): Use binwalk to extract SquashFS/JFFS2/CramFS filesystems
- Service Analysis (1-3hrs): Map init scripts, daemons, network listeners
- Vulnerability Assessment (1-3hrs): Find hardcoded credentials, CVEs, injection points
- Binary Analysis (1-2hrs): Apply Levels 1-4 to extracted binaries
Timebox: 2-8 hours total
Prerequisites
Tools
- binwalk - Firmware extraction (
binwalk -Me firmware.bin)
- unsquashfs - SquashFS extraction
- file - File type identification
- QEMU (optional) - Emulate extracted binaries
- Jefferson (optional) - JFFS2 extraction
- strings - For string analysis on firmware
MCP Servers
filesystem - Navigate extracted firmware
security-manager - CVE scanning
connascence-analyzer - Code quality analysis
memory-mcp - Store findings
sequential-thinking - Decision gate for binary analysis
⚠️ CRITICAL SECURITY WARNING
NEVER execute firmware binaries or extracted files on your host system!
All firmware extraction, binary execution, and emulation MUST be performed in:
- Isolated VM (VMware/VirtualBox with network isolation and snapshots)
- Docker container with strict security policies and no host filesystem access
- E2B sandbox via sandbox-configurator skill with monitored execution
- Firmware analysis environment (QEMU with
-snapshot, firmadyne sandbox)
Consequences of unsafe execution:
- Backdoor installation and persistent network access
- Extraction of hardcoded credentials compromising related devices
- Malware propagation to development infrastructure
- IoT botnet recruitment (Mirai, Hajime variants)
- Compromise of cloud API keys and services
Safe Practices:
- Extract firmware in isolated containers with no network access
- Use QEMU emulation with snapshot mode (
-snapshot flag)
- Never connect emulated devices to production networks
- Validate extracted credentials in isolated environments only
- Monitor all network connections during firmware emulation
- Treat all IoT firmware as potentially compromised
- Use read-only mounts for extracted filesystems
Quick Start
/re:firmware router-firmware.bin
/re:firmware iot-device.img --extract-only
/re:firmware camera-fw.bin --analyze-services true
/re:firmware router.bin --analyze-binary /usr/sbin/httpd
Phase 1: Firmware Identification (5-10 minutes)
Step 1: Basic File Analysis
file firmware.bin
Step 2: Entropy Analysis
Check if firmware is encrypted or compressed:
binwalk --entropy firmware.bin
Interpretation:
- Entropy 0.9-1.0: Encrypted firmware (need decryption key)
- Entropy 0.6-0.8: Compressed sections (normal)
- Entropy 0.3-0.5: Uncompressed data
Step 3: Component Identification
binwalk --signature firmware.bin
Components:
- Bootloader: u-boot, Das U-Boot
- Kernel: Linux kernel (compressed with LZMA/gzip)
- Root Filesystem: SquashFS, JFFS2, CramFS, UBIFS
- Configuration: JFFS2 partition for persistent data
Phase 2: Filesystem Extraction (30 minutes - 2 hours)
Step 1: Automatic Extraction
binwalk --extract --matryoshka firmware.bin
Step 2: Verify Extraction
cd _firmware.bin.extracted/squashfs-root/
ls -la
Step 3: Manual Extraction (if automatic fails)
For SquashFS:
binwalk firmware.bin | grep -i squashfs
dd if=firmware.bin bs=1 skip=1048576 of=squashfs.img
unsquashfs -dest ./squashfs-root squashfs.img
ls ./squashfs-root/
For JFFS2:
pip install jefferson
jefferson jffs2.img --dest ./jffs2-root
extract-firmware.sh firmware.bin
For CramFS:
sudo apt install cramfsprogs
sudo mount -t cramfs -o loop cramfs.img /mnt/cramfs
cramfsck -x ./cramfs-root cramfs.img
Step 4: Handle Encrypted Firmware
binwalk --entropy firmware.bin
tplink-safeloader -d firmware.bin -o decrypted.bin
binwalk -e --dd='.*' firmware.bin
Phase 3: Service Discovery (1-3 hours)
Step 1: Identify Init System
ls ./squashfs-root/etc/init.d/
Step 2: Analyze Startup Services
cat ./squashfs-root/etc/rc.d/*
cat ./squashfs-root/etc/init.d/rcS
Key Services to Map:
- telnetd: Telnet server (port 23)
- httpd: Web server (port 80/443)
- dropbear/sshd: SSH server (port 22)
- ftpd: FTP server (port 21)
- upnpd: UPnP daemon
- dnsmasq: DNS/DHCP server
Step 3: Find Network Listeners
grep -r "0.0.0.0" ./squashfs-root/etc/
grep -r "bind(" ./squashfs-root/usr/sbin/ 2>/dev/null
grep -r "listen(" ./squashfs-root/usr/sbin/ 2>/dev/null
grep -rE ":[0-9]{2,5}" ./squashfs-root/etc/ | grep -E "(80|443|23|22|21)"
Step 4: Map CGI Scripts and Web Interface
ls ./squashfs-root/www/
ls ./squashfs-root/usr/www/
find ./squashfs-root/www/ -name "*.cgi" -o -name "*.sh"
grep -E "(system|popen|exec)" ./squashfs-root/www/cgi-bin/*.cgi
Output Summary:
Network Services Detected:
- telnetd on 0.0.0.0:23 (CRITICAL: Unauthenticated shell access)
- httpd on 0.0.0.0:80 (Web interface)
- dropbear on 0.0.0.0:22 (SSH with password auth)
- upnpd on 0.0.0.0:1900 (UPnP potential SSRF)
CGI Scripts Found:
- /cgi-bin/admin.cgi (Command injection vulnerable)
- /cgi-bin/login.cgi (Credential check)
- /cgi-bin/upgrade.cgi (Firmware upload)
Phase 4: Credential Hunting (30 minutes - 1 hour)
Step 1: Check Shadow and Passwd Files
cat ./squashfs-root/etc/passwd
cat ./squashfs-root/etc/shadow
Common Issues:
- Empty password hashes (passwordless login)
- Weak/default passwords (admin/admin)
- Hardcoded hashes (crackable)
Step 2: Search Configuration Files
grep -ri "password" ./squashfs-root/etc/ 2>/dev/null
grep -ri "passwd" ./squashfs-root/etc/ 2>/dev/null
grep -ri "pwd" ./squashfs-root/etc/ 2>/dev/null
grep -ri "secret" ./squashfs-root/etc/ 2>/dev/null
Step 3: Find API Keys and Tokens
grep -rE "[A-Za-z0-9]{32,}" ./squashfs-root/etc/config/
grep -ri "api_key\|token\|secret_key" ./squashfs-root/etc/
grep -ri "aws\|azure\|gcp\|s3" ./squashfs-root/etc/
Step 4: Extract SSL Certificates and Private Keys
find ./squashfs-root/ -name "*.pem" -o -name "*.key" -o -name "*.crt"
openssl rsa -in ./etc/ssl/private/server.key -text -noout
Credential Summary:
Hardcoded Credentials Found:
- Root password: "5up" (plaintext in /etc/shadow)
- Admin password: "admin" (default credentials)
- WiFi password: "default_wifi_password_12345" (weak)
- API key: "sk_live_abcdef..." (exposed in /etc/cloud-config.json)
- SSL private key: /etc/ssl/private/server.key (512-bit RSA, weak)
Phase 5: Vulnerability Scanning (1-3 hours)
Step 1: Identify Library Versions
ls ./squashfs-root/lib/
ls ./squashfs-root/usr/lib/
strings ./squashfs-root/lib/libc.so.0 | grep -i version
Step 2: CVE Scanning with MCP
/re:firmware router.bin --cve-scan true
Under the Hood:
const cveResults = await mcp__security-manager__scan_vulnerabilities({
filesystem_root: "./squashfs-root/",
library_scan: true,
cve_database: "nvd",
check_versions: true
})
Step 3: Manual Vulnerability Assessment
Check for Command Injection:
grep -E "(system|exec|popen|shell_exec)" ./squashfs-root/www/cgi-bin/*.cgi
Check for SQL Injection:
grep -rE "(SELECT|INSERT|UPDATE|DELETE)" ./squashfs-root/www/
Check for Path Traversal:
grep -rE "(fopen|readfile|include)" ./squashfs-root/www/
Step 4: Check for Backdoors
grep -rE "port.*[0-9]{4,5}" ./squashfs-root/etc/
grep -rE "(nc.*-e|bash.*>&|/dev/tcp)" ./squashfs-root/
find ./squashfs-root/ -name ".*" -type f
cat ./squashfs-root/etc/crontabs/*
Vulnerability Report:
CRITICAL Vulnerabilities:
1. CVE-2014-0160 (Heartbleed) - OpenSSL 1.0.1e
2. Command Injection - admin.cgi (unauthenticated)
3. Hardcoded credentials - root:5up
HIGH Vulnerabilities:
4. Path Traversal - download.cgi
5. Weak SSL certificate - 512-bit RSA key
6. Telnet enabled on 0.0.0.0:23 (no authentication)
MEDIUM Vulnerabilities:
7. Default credentials - admin:admin
8. UPnP enabled (SSRF potential)
9. SQL Injection - login.cgi
Phase 6: Binary Analysis (1-2 hours)
After extracting firmware, apply Levels 1-4 to interesting binaries.
Step 1: Identify Target Binaries
ls ./squashfs-root/usr/sbin/httpd
ls ./squashfs-root/usr/sbin/telnetd
find ./squashfs-root/usr/bin/ -type f -executable
Step 2: Apply Level 1 (String Analysis)
/re:strings ./squashfs-root/usr/sbin/httpd
Example Output:
Strings Found in httpd:
- "admin:5up" (hardcoded credential)
- "http://firmware-updates.vendor.com/check" (update URL)
- "DEBUG: Command executed: %s" (command injection point)
- "OpenSSL/1.0.1e" (vulnerable version)
Step 3: Apply Level 2 (Static Analysis)
/re:static ./squashfs-root/usr/sbin/httpd --tool ghidra
Decompiled Code Example (Ghidra output):
void handle_admin_cgi(char *query_string) {
char command[256];
char *cmd_param;
cmd_param = get_param(query_string, "cmd");
sprintf(command, "sh -c '%s'", cmd_param);
system(command);
}
Step 4: Apply Level 3 (Dynamic Analysis) - Optional
qemu-mipsel-static ./squashfs-root/usr/sbin/httpd
firmadyne.sh router-firmware.bin
gdb-multiarch ./squashfs-root/usr/sbin/httpd
(gdb) set architecture mips
(gdb) break handle_admin_cgi
(gdb) run
Step 5: Apply Level 4 (Symbolic Execution) - Advanced
/re:symbolic ./squashfs-root/usr/sbin/httpd \
--target-addr 0x401234 \
--input-symbolic cmd_param \
--find-exploits true
Comprehensive Workflow Examples
Workflow 1: Router Firmware Complete Analysis
Scenario: Analyze TP-Link router firmware for vulnerabilities
Step 1: Extraction (30 min)
wget http://vendor.com/TL-WR841N-v14-firmware.bin
binwalk -E TL-WR841N-v14-firmware.bin
binwalk -Me TL-WR841N-v14-firmware.bin
cd _TL-WR841N-v14-firmware.bin.extracted/squashfs-root/
Step 2: Service Discovery (1 hr)
cat etc/rc.d/S*
find www/ -name "*.cgi"
Step 3: Credential Hunting (15 min)
cat etc/shadow
grep -ri "password" etc/config/
Step 4: CVE Scanning (30 min)
strings lib/libc.so.0 | grep version
/re:firmware TL-WR841N-v14-firmware.bin --cve-scan true
Step 5: Binary Analysis (1 hr)
/re:strings www/cgi-bin/admin.cgi
/re:static www/cgi-bin/admin.cgi --tool ghidra
Final Report:
TP-Link TL-WR841N Firmware Analysis
====================================
CRITICAL Vulnerabilities:
1. Hardcoded credentials: admin:5up
2. Unauthenticated telnet on port 23
3. Command injection in admin.cgi
4. Heartbleed (CVE-2014-0160) in OpenSSL 1.0.1e
HIGH Vulnerabilities:
5. Weak default WiFi password
6. No CSRF protection on admin interface
Attack Scenario:
1. Telnet to router (no password required)
2. Or exploit command injection: http://router/cgi-bin/admin.cgi?cmd=reboot
3. Gain root shell access
Recommendation: Update to patched firmware version
Time: 3.25 hours total
Workflow 2: IoT Camera Firmware Security Audit
Scenario: Audit Wyze camera firmware for cloud API security
Step 1: Extraction (45 min)
binwalk --extract --matryoshka wyze-cam-v3-firmware.bin
jefferson ubifs.img --dest ./wyze-root/
Step 2: Service Discovery (1.5 hrs)
grep -ri "api\|cloud\|server" ./wyze-root/etc/
Step 3: Analyze Cloud Communication (1 hr)
cat ./wyze-root/etc/mqtt.conf
/re:strings ./wyze-root/usr/bin/cloud-agent
Step 4: CVE Scan (30 min)
ls ./wyze-root/lib/
Step 5: Binary Analysis of Cloud Agent (1 hr)
/re:static ./wyze-root/usr/bin/cloud-agent --tool ghidra
void cloud_authenticate() {
char *token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...";
char *api_key = "sk_live_abcdef1234567890";
http_request("POST", "https://api.wyze.com/v1/auth",
headers=["Authorization: Bearer " + token]);
}
Final Report:
Wyze Cam v3 Firmware Security Audit
====================================
CRITICAL Vulnerabilities:
1. Hardcoded API credentials shared across all devices
2. Hardcoded JWT token for cloud authentication
3. MQTT credentials in plaintext
4. CVE-2014-0160 (Heartbleed)
5. CVE-2020-8231 (libcurl RCE)
Attack Scenario:
1. Extract API key from firmware
2. Authenticate to Wyze cloud API
3. Access all cameras using same API key
4. Stream/download video from any camera
Impact: Complete compromise of all Wyze cameras using this firmware
Recommendation:
- Implement per-device API keys
- Remove hardcoded credentials
- Update vulnerable libraries
Time: 4.75 hours total
Workflow 3: Smart Thermostat Firmware - Finding Debug Interface
Scenario: Analyze Nest-like thermostat for hidden debug interfaces
Step 1: Extraction (1 hr)
binwalk --entropy thermostat-firmware.bin
find ./vendor-sdk/ -name "*.key" -o -name "*aes*"
openssl enc -d -aes-256-cbc -in thermostat-firmware.bin \
-out decrypted.bin -K $(cat encryption_key.bin)
binwalk --extract --matryoshka decrypted.bin
Step 2: Find Debug Interfaces (30 min)
grep -ri "uart\|serial\|console" ./squashfs-root/etc/
grep -ri "debug\|test\|diag" ./squashfs-root/usr/bin/
ls ./squashfs-root/usr/bin/debug-shell
Step 3: Analyze Debug Shell (1 hr)
/re:strings ./squashfs-root/usr/bin/debug-shell
/re:static ./squashfs-root/usr/bin/debug-shell --tool ghidra
bool check_debug_password(char *input) {
char *correct_password = "DebugMode2023"; // Hardcoded!
return strcmp(input, correct_password) == 0;
}
Step 4: Test Debug Interface (30 min)
qemu-arm-static ./squashfs-root/usr/bin/debug-shell
screen /dev/ttyUSB0 115200
Final Report:
Smart Thermostat Debug Interface Analysis
==========================================
CRITICAL Findings:
1. UART console enabled with debug shell access
2. Hardcoded debug password: "DebugMode2023"
3. Debug commands allow full device control
4. NVRAM dump reveals WiFi credentials
Attack Scenario:
1. Open device and connect to UART pins
2. Boot device and access serial console
3. Launch debug-shell
4. Enter password "DebugMode2023"
5. Execute dump_nvram to extract WiFi password
6. Execute enable_telnet for remote access
Impact: Physical access to device = full compromise
Recommendation:
- Disable debug interfaces in production firmware
- Use unique per-device debug passwords
- Implement secure boot to prevent firmware modifications
Time: 3 hours total
Advanced Options
Custom Extraction Targets
/re:firmware router.bin --extract-filesystem squashfs --skip-analysis
/re:firmware router.bin --analyze-binary /usr/sbin/httpd --level 2
/re:firmware router.bin --extract-jffs2-only
Multi-Firmware Analysis
/re:firmware router-v1.bin --output ./v1-analysis/
/re:firmware router-v2.bin --output ./v2-analysis/
diff -r ./v1-analysis/squashfs-root/ ./v2-analysis/squashfs-root/
diff <(ls ./v1-analysis/squashfs-root/usr/bin/) \
<(ls ./v2-analysis/squashfs-root/usr/bin/)
Automated Firmware Emulation
git clone https://github.com/firmadyne/firmadyne
cd firmadyne
./download.sh
./scripts/inferNetwork.sh router-firmware.bin
./scripts/makeImage.sh router-firmware.bin
http://192.168.1.1
telnet 192.168.1.1 23
Troubleshooting
Issue 1: Encrypted Firmware
Symptoms: High entropy (>0.9), binwalk finds no filesystems
Cause: Firmware is encrypted
Solution 1: Find decryption key
find ./vendor-sdk/ -name "*.key" -o -name "*aes*" -o -name "*decrypt*"
Solution 2: Check for known encryption schemes
tplink-safeloader -d firmware.bin -o decrypted.bin
openssl enc -d -aes-256-cbc -in firmware.bin -out decrypted.bin \
-K <known_key> -iv <known_iv>
Solution 3: Reverse engineer bootloader
dd if=firmware.bin bs=1 count=65536 of=bootloader.bin
/re:static bootloader.bin --tool ghidra
Issue 2: Unable to Extract Filesystem
Symptoms: binwalk extraction fails or produces corrupted files
Cause: Non-standard filesystem format or compression
Solution 1: Try manual extraction with different tools
unsquashfs -d ./output squashfs.img
unsquashfs-lzma -d ./output squashfs.img
jefferson ./output squashfs.img
jefferson jffs2.img -d ./output
ubireader_extract_images -o ./output firmware.bin
cramfsck -x ./output cramfs.img
Solution 2: Use firmware-mod-kit
git clone https://github.com/rampageX/firmware-mod-kit
cd firmware-mod-kit/src
./configure && make
./extract-firmware.sh ../firmware.bin
Solution 3: Manual carving
binwalk firmware.bin
dd if=firmware.bin bs=1 skip=1048576 of=filesystem.img
unsquashfs filesystem.img
Issue 3: Binaries Won't Execute (Architecture Mismatch)
Symptoms: "Exec format error" when running extracted binaries
Cause: Binary compiled for different architecture (MIPS, ARM, etc.)
Solution 1: Identify architecture and use correct QEMU
file ./squashfs-root/usr/sbin/httpd
qemu-mipsel-static ./squashfs-root/usr/sbin/httpd
sudo chroot ./squashfs-root qemu-mipsel-static /usr/sbin/httpd
Solution 2: Full system emulation with QEMU
qemu-img create -f qcow2 firmware.qcow2 1G
qemu-system-mips -M malta -kernel vmlinux -hda firmware.qcow2 \
-append "root=/dev/sda1 console=ttyS0" -nographic
firmadyne.sh firmware.bin
Solution 3: Use Docker with QEMU user emulation
docker run --rm -it --platform linux/arm/v7 \
-v $(pwd)/squashfs-root:/firmware \
arm32v7/ubuntu:20.04 bash
cd /firmware
./usr/sbin/httpd
Issue 4: CVE Scan Misses Vulnerabilities
Symptoms: Known vulnerabilities not detected by automated scan
Cause: Version string doesn't match CVE database format
Solution 1: Manual version checking
strings ./squashfs-root/lib/libssl.so.1.0.0 | grep -i version
Solution 2: Use multiple CVE scanners
cve-bin-tool ./squashfs-root/
grype dir:./squashfs-root/
trivy fs ./squashfs-root/
Solution 3: Custom signature matching
cat > custom-cve-rules.txt <<EOF
OpenSSL 1.0.1[a-f]: CVE-2014-0160 (Heartbleed)
BusyBox 1.2[0-4]: CVE-2021-28831 (Command injection)
Dropbear 201[0-6]: CVE-2016-7406 (Format string)
EOF
grep -f custom-cve-rules.txt <(find ./squashfs-root/ -exec strings {} \; 2>/dev/null)
Issue 5: Cannot Find Hardcoded Credentials
Symptoms: grep searches return no passwords despite expecting them
Cause: Credentials encoded/encrypted or stored in binary format
Solution 1: Search for encoded strings
find ./squashfs-root/ -type f -exec grep -l "YWRtaW46YWRtaW4=" {} \;
grep -rE "61646d696e" ./squashfs-root/etc/
grep -rE "%61%64%6d%69%6e" ./squashfs-root/
Solution 2: Search in binaries and databases
find ./squashfs-root/ -name "*.db" -o -name "*.sqlite"
sqlite3 ./etc/config.db "SELECT * FROM users;"
strings ./squashfs-root/etc/config.bin | grep -i "password\|admin"
Solution 3: Reverse engineer authentication binary
/re:static ./squashfs-root/usr/bin/login --tool ghidra
Performance Optimization
Speed Up Extraction
binwalk -e partition1.bin &
binwalk -e partition2.bin &
wait
unsquashfs -p 4 squashfs.img
Speed Up Service Discovery
grep -r "telnetd" ./squashfs-root/etc/ &
grep -r "httpd" ./squashfs-root/etc/ &
grep -r "sshd" ./squashfs-root/etc/ &
wait
Optimize CVE Scanning
mcp__security-manager__scan_vulnerabilities({
filesystem_root: "./squashfs-root/",
skip_binaries: ["busybox", "dropbear"],
only_critical: true
})
Memory-MCP Integration
Storing Firmware Analysis
mcp__memory-mcp__memory_store({
content: {
firmware_hash: "sha256:abc123...",
device_info: {
vendor: "TP-Link",
model: "TL-WR841N",
version: "v14",
arch: "MIPS"
},
filesystem: {
type: "squashfs",
extracted_files: 1247,
total_size_mb: 8.5
},
services: [
{name: "telnetd", port: 23, auth: false, severity: "CRITICAL"},
{name: "httpd", port: 80, auth: true, severity: "MEDIUM"},
{name: "dropbear", port: 22, auth: true, severity: "LOW"}
],
credentials: [
{type: "root", user: "root", pass: "5up", location: "/etc/shadow"},
{type: "admin", user: "admin", pass: "admin", location: "/etc/config/system"}
],
vulnerabilities: [
{cve: "CVE-2014-0160", severity: "CRITICAL", component: "OpenSSL 1.0.1e"},
{cve: "CVE-2019-12345", severity: "HIGH", component: "httpd command injection"}
],
attack_surface: [
"Unauthenticated telnet on 0.0.0.0:23",
"Command injection in /cgi-bin/admin.cgi",
"Path traversal in /cgi-bin/download.cgi"
],
binary_analysis: {
analyzed: ["/usr/sbin/httpd", "/www/cgi-bin/admin.cgi"],
findings: "Command injection confirmed in admin.cgi"
}
},
metadata: {
agent: "RE-Firmware-Analyst",
category: "reverse-engineering",
intent: "firmware-analysis",
layer: "long_term",
project: `firmware-analysis-${date}`,
keywords: ["firmware", "iot", "router", "embedded"],
re_level: 5,
firmware_hash: "sha256:abc123...",
timestamp: new Date().toISOString()
}
})
Agents & Commands
Agents Invoked
-
RE-Firmware-Analyst (Level 5)
- Specialist: Firmware extraction and IoT security analysis
- Tools: binwalk, unsquashfs, jefferson, firmadyne, QEMU
- Output: Extracted filesystem, service map, credential list, CVE report
-
RE-String-Analyst (Level 1, for extracted binaries)
- Applied to extracted binaries for IOC extraction
-
RE-Disassembly-Expert (Level 2, for extracted binaries)
- Applied to extracted binaries for vulnerability analysis
-
security-manager (automatic)
- Performs CVE scanning on extracted libraries
Slash Commands
/re:firmware <firmware> - Full Level 5 analysis (this skill's primary command)
/re:strings <binary> - Apply to extracted binaries
/re:static <binary> - Apply to extracted binaries
MCP Servers
- filesystem: Navigate extracted firmware directories
- security-manager: Automated CVE scanning
- connascence-analyzer: Code quality analysis on extracted code
- memory-mcp: Cross-session persistence of firmware analysis
- sequential-thinking: Decision gates for binary analysis escalation
Related Skills
Resources
External Tools
Learning Resources
Community
Created: 2025-11-01
RE Level: 5 (Firmware Analysis)
Timebox: 2-8 hours
Category: IoT Security, Embedded Systems, Firmware Reverse Engineering
Difficulty: Advanced
Core Principles
Reverse Engineering: Firmware Analysis operates on 3 fundamental principles:
Principle 1: Layered Extraction Strategy
Firmware contains multiple nested components (bootloader, kernel, filesystem, configuration) requiring progressive extraction.
In practice:
- Use binwalk entropy analysis to detect encryption before extraction attempts
- Extract filesystems recursively (matryoshka mode) to handle nested archives
- Identify component boundaries with signature scanning (SquashFS, JFFS2, UBIFS magic bytes)
- Manual carving with dd when automatic extraction fails
Principle 2: Attack Surface Mapping
IoT devices expose attack surfaces through network services, web interfaces, and hardcoded credentials.
In practice:
- Map all network listeners from init scripts (telnetd, httpd, UPnP daemons)
- Analyze CGI scripts for command injection and path traversal vulnerabilities
- Extract credentials from shadow files, configuration databases, and binary strings
- Document firmware update mechanisms for supply chain attack vectors
Principle 3: Cross-Component Correlation
Vulnerabilities often span multiple firmware components (web interface + binary daemon + kernel module).
In practice:
- Correlate CGI script vulnerabilities with backend binary analysis
- Link hardcoded credentials to service authentication mechanisms
- Validate CVEs across shared libraries (OpenSSL, BusyBox, Dropbear)
- Apply Levels 1-4 binary analysis to extracted executables
Common Anti-Patterns
| Anti-Pattern | Problem | Solution |
|---|
| Executing firmware binaries on host | Architecture mismatch (MIPS/ARM), potential backdoors, system compromise | Use QEMU user-mode emulation or full system emulation with firmadyne |
| Ignoring encrypted firmware | Incomplete analysis, missed vulnerabilities, false sense of security | Search vendor SDKs for decryption keys, reverse bootloader crypto routines, check known device decryption schemes |
| Skipping service discovery | Miss network-exposed attack surfaces (unauthenticated telnet, vulnerable CGI) | Analyze init scripts, grep for bind/listen calls, map network listeners to binaries |
| Not validating extraction | Corrupted filesystems, missing files, incomplete analysis | Verify critical directories exist (/bin, /etc, /lib, /www), check file counts match expectations |
| Sharing raw credentials publicly | Legal liability, compromise of related devices, customer privacy violation | Redact internal IPs, sanitize credentials before publishing IOCs, use secure disclosure channels |
Conclusion
Reverse Engineering: Firmware Analysis is the gateway to understanding the security posture of billions of IoT and embedded devices deployed worldwide. By systematically extracting filesystems, mapping network services, hunting for hardcoded credentials, and scanning for CVEs, this skill reveals the critical vulnerabilities that make IoT devices prime targets for botnet recruitment and supply chain attacks.
The skill's value extends beyond individual device analysis - findings apply to entire product lines sharing the same firmware base. A single extracted default password or command injection vulnerability can compromise thousands of devices. Combined with Level 1-4 binary analysis of extracted executables, this skill enables comprehensive security assessments from bootloader to application layer.
Use this skill when analyzing router firmware before deployment, auditing smart home devices for privacy concerns, or conducting vulnerability research on embedded systems. The 2-8 hour timebox makes it suitable for both targeted security audits and large-scale IoT security research programs. Integration with memory-mcp enables cross-firmware correlation to identify common vulnerabilities across vendors, accelerating IoT security research at scale.