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), discovering hardcoded credentials, performing CVE scans, or auditing embedded-system security. Supports encrypted firmware with known decryption schemes. Typical completion time: 2–8 hours using binwalk + Firmadyne + QEMU emulation.
Before writing ANY code, you MUST check:
.claude/library/catalog.json.claude/docs/inventories/LIBRARY-PATTERNS-GUIDE.mdD:\Projects\*| 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) |
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.
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).
All reverse engineering findings MUST be validated through:
Extracts and analyzes firmware from IoT devices, routers, and embedded systems:
Timebox: 2-8 hours total
binwalk -Me firmware.bin)filesystem - Navigate extracted firmwaresecurity-manager - CVE scanningconnascence-analyzer - Code quality analysismemory-mcp - Store findingssequential-thinking - Decision gate for binary analysisNEVER execute firmware binaries or extracted files on your host system!
All firmware extraction, binary execution, and emulation MUST be performed in:
-snapshot, firmadyne sandbox)Consequences of unsafe execution:
Safe Practices:
-snapshot flag)# 1. Full firmware analysis
/re:firmware router-firmware.bin
# 2. Extract filesystem only
/re:firmware iot-device.img --extract-only
# 3. Analyze extracted services
/re:firmware camera-fw.bin --analyze-services true
# 4. Extract + analyze specific binary
/re:firmware router.bin --analyze-binary /usr/sbin/httpd
# Identify file type
file firmware.bin
# Expected output examples:
# - "firmware.bin: u-boot legacy uImage, MIPS OpenWrt Linux-4.14.63"
# - "firmware.bin: data" (encrypted or compressed)
# - "firmware.bin: Flattened device tree blob (DTB)"
Check if firmware is encrypted or compressed:
# Entropy analysis
binwalk --entropy firmware.bin
# Output visualization:
# High entropy throughout (> 0.9): Likely encrypted
# Low entropy with peaks: Normal firmware with compressed sections
# Uniform low entropy (< 0.5): Uncompressed firmware
Interpretation:
# Identify firmware components
binwalk --signature firmware.bin
# Expected output:
# DECIMAL HEXADECIMAL DESCRIPTION
# --------------------------------------------------------------------------------
# 0 0x0 uImage header, header size: 64 bytes
# 64 0x40 LZMA compressed data
# 1048576 0x100000 Squashfs filesystem, little endian
# 15728640 0xF00000 JFFS2 filesystem, little endian
Components:
# Extract all filesystem components automatically
binwalk --extract --matryoshka firmware.bin
# --extract (-e): Extract identified components
# --matryoshka (-M): Recursively scan extracted files
# Output directory structure:
# _firmware.bin.extracted/
# ├── 0.lzma # Compressed kernel
# ├── 100000.squashfs # Root filesystem
# ├── squashfs-root/ # Extracted root filesystem
# └── jffs2-root/ # Extracted configuration partition
# Navigate to extracted filesystem
cd _firmware.bin.extracted/squashfs-root/
# Verify critical directories exist
ls -la
# Expected structure:
# drwxr-xr-x bin/ # Binaries
# drwxr-xr-x etc/ # Configuration files
# drwxr-xr-x lib/ # Shared libraries
# drwxr-xr-x usr/ # User programs
# drwxr-xr-x www/ # Web interface
# drwxr-xr-x sbin/ # System binaries
# Find SquashFS offset from binwalk
binwalk firmware.bin | grep -i squashfs
# Output: 1048576 0x100000 Squashfs filesystem
# Extract from offset
dd if=firmware.bin bs=1 skip=1048576 of=squashfs.img
# Unsquash manually
unsquashfs -dest ./squashfs-root squashfs.img
# Verify
ls ./squashfs-root/
# Install jefferson (JFFS2 extractor)
pip install jefferson
# Extract JFFS2
jefferson jffs2.img --dest ./jffs2-root
# Or use firmware-mod-kit
extract-firmware.sh firmware.bin
# Install cramfs tools
sudo apt install cramfsprogs
# Mount (requires root)
sudo mount -t cramfs -o loop cramfs.img /mnt/cramfs
# Or extract
cramfsck -x ./cramfs-root cramfs.img
# Check entropy
binwalk --entropy firmware.bin
# If high entropy (encrypted):
# 1. Search for decryption keys in vendor documentation
# 2. Check for known encryption schemes (AES, 3DES, RSA)
# 3. Use firmware-mod-kit or binwalk plugins for known devices
# Example: TP-Link firmware decryption
tplink-safeloader -d firmware.bin -o decrypted.bin
# Example: D-Link firmware decryption
binwalk -e --dd='.*' firmware.bin
# Check for init scripts
ls ./squashfs-root/etc/init.d/
# Common init systems:
# - init.d/ scripts (SysVinit)
# - rc.d/ scripts (BSD-style init)
# - systemd/ units (systemd)
# - procd/ configs (OpenWrt procd)
# OpenWrt/procd example
cat ./squashfs-root/etc/rc.d/*
# SysVinit example
cat ./squashfs-root/etc/init.d/rcS
# Example output:
# #!/bin/sh
# /usr/sbin/telnetd -l /bin/sh
# /usr/sbin/httpd -p 80 -h /www
# /usr/sbin/dropbear -p 22
Key Services to Map:
# Search for network binding code
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
# Search for port numbers
grep -rE ":[0-9]{2,5}" ./squashfs-root/etc/ | grep -E "(80|443|23|22|21)"
# Example findings:
# ./squashfs-root/etc/config/uhttpd: option listen_http '0.0.0.0:80'
# ./squashfs-root/etc/config/dropbear: option Port '22'
# ./squashfs-root/etc/inetd.conf:telnet stream tcp nowait root /usr/sbin/telnetd
# Find web root
ls ./squashfs-root/www/
ls ./squashfs-root/usr/www/
# Find CGI scripts (potential injection points)
find ./squashfs-root/www/ -name "*.cgi" -o -name "*.sh"
# Example CGI scripts:
# ./squashfs-root/www/cgi-bin/login.cgi
# ./squashfs-root/www/cgi-bin/admin.cgi
# ./squashfs-root/www/cgi-bin/status.sh
# Analyze for command injection
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)
# Unix password files
cat ./squashfs-root/etc/passwd
cat ./squashfs-root/etc/shadow
# Example vulnerable shadow file:
# root:$1$12345678$abcdefghijklmnopqrstuv:0:0:root:/root:/bin/sh
# admin:admin:0:0:admin:/root:/bin/sh # CRITICAL: Plaintext password!
Common Issues:
# Search for common password keywords
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
# Example findings:
# ./etc/config/wireless: option key 'default_wifi_password_12345'
# ./etc/shadow: root:5up:0:0:root:/root:/bin/sh
# ./etc/config/system: option admin_password 'admin'
# Search for long alphanumeric strings (API keys)
grep -rE "[A-Za-z0-9]{32,}" ./squashfs-root/etc/config/
# Search for common API key patterns
grep -ri "api_key\|token\|secret_key" ./squashfs-root/etc/
# Search for cloud service credentials
grep -ri "aws\|azure\|gcp\|s3" ./squashfs-root/etc/
# Example findings:
# ./etc/cloud-config.json: "api_key": "sk_live_abcdef1234567890"
# ./etc/mqtt.conf: mqtt_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
# Find SSL certificates
find ./squashfs-root/ -name "*.pem" -o -name "*.key" -o -name "*.crt"
# Example findings:
# ./etc/ssl/private/server.key (CRITICAL: Private key embedded)
# ./etc/ssl/certs/ca.crt
# Check for weak/default keys
openssl rsa -in ./etc/ssl/private/server.key -text -noout
# If key is weak (512-bit RSA), flag as critical
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)
# Find shared libraries
ls ./squashfs-root/lib/
ls ./squashfs-root/usr/lib/
# Check library versions
strings ./squashfs-root/lib/libc.so.0 | grep -i version
# Example output:
# OpenSSL 1.0.1e (VULNERABLE: Heartbleed CVE-2014-0160)
# BusyBox v1.24.1 (CHECK: Known CVEs)
# Dropbear 2014.63 (CHECK: Known CVEs)
# Use security-manager MCP for automated CVE scanning
/re:firmware router.bin --cve-scan true
Under the Hood:
// Automatically invoked by skill
const cveResults = await mcp__security-manager__scan_vulnerabilities({
filesystem_root: "./squashfs-root/",
library_scan: true,
cve_database: "nvd", // National Vulnerability Database
check_versions: true
})
// Example output:
// {
// "vulnerabilities": [
// {
// "cve": "CVE-2014-0160",
// "severity": "CRITICAL",
// "component": "OpenSSL 1.0.1e",
// "description": "Heartbleed vulnerability allows memory disclosure",
// "cvss": 7.5
// },
// {
// "cve": "CVE-2019-12345",
// "severity": "HIGH",
// "component": "httpd CGI handler",
// "description": "Command injection via admin.cgi parameter",
// "cvss": 8.8
// }
// ]
// }
# Analyze CGI scripts for command injection
grep -E "(system|exec|popen|shell_exec)" ./squashfs-root/www/cgi-bin/*.cgi
# Example vulnerable code in admin.cgi:
# system("ping -c 1 " . $QUERY_STRING); # CRITICAL: Command injection!
# Find database queries
grep -rE "(SELECT|INSERT|UPDATE|DELETE)" ./squashfs-root/www/
# Example vulnerable query:
# $query = "SELECT * FROM users WHERE username='" . $_GET['user'] . "'";
# Find file operations
grep -rE "(fopen|readfile|include)" ./squashfs-root/www/
# Example vulnerable code:
# readfile("/www/" . $_GET['file']); # Path traversal: ?file=../etc/shadow
# Search for suspicious listening ports
grep -rE "port.*[0-9]{4,5}" ./squashfs-root/etc/
# Search for reverse shell code
grep -rE "(nc.*-e|bash.*>&|/dev/tcp)" ./squashfs-root/
# Search for hidden services
find ./squashfs-root/ -name ".*" -type f
# Check for suspicious cron jobs
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
After extracting firmware, apply Levels 1-4 to interesting binaries.
# Web server binary
ls ./squashfs-root/usr/sbin/httpd
# Telnet daemon
ls ./squashfs-root/usr/sbin/telnetd
# Custom binaries
find ./squashfs-root/usr/bin/ -type f -executable
# Analyze web server strings
/re:strings ./squashfs-root/usr/sbin/httpd
# Look for:
# - Hardcoded URLs (C2 servers, update servers)
# - Debug messages revealing logic
# - Version strings
# - Hardcoded credentials
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)
# Disassemble httpd binary
/re:static ./squashfs-root/usr/sbin/httpd --tool ghidra
# Find critical functions:
# - handle_cgi_request()
# - authenticate_user()
# - execute_command()
Decompiled Code Example (Ghidra output):
// Function: handle_admin_cgi
void handle_admin_cgi(char *query_string) {
char command[256];
char *cmd_param;
// VULNERABILITY: No input validation!
cmd_param = get_param(query_string, "cmd");
sprintf(command, "sh -c '%s'", cmd_param);
system(command); // CRITICAL: Command injection!
}
# Emulate binary with QEMU
qemu-mipsel-static ./squashfs-root/usr/sbin/httpd
# Or use full system emulation with firmadyne
firmadyne.sh router-firmware.bin
# Debug with GDB
gdb-multiarch ./squashfs-root/usr/sbin/httpd
(gdb) set architecture mips
(gdb) break handle_admin_cgi
(gdb) run
# Use Angr for symbolic analysis
/re:symbolic ./squashfs-root/usr/sbin/httpd \
--target-addr 0x401234 \ # execute_command function
--input-symbolic cmd_param \
--find-exploits true
Scenario: Analyze TP-Link router firmware for vulnerabilities
Step 1: Extraction (30 min)
# Download firmware
wget http://vendor.com/TL-WR841N-v14-firmware.bin
# Identify and extract
binwalk -E TL-WR841N-v14-firmware.bin # Check entropy
binwalk -Me TL-WR841N-v14-firmware.bin # Extract
# Navigate to filesystem
cd _TL-WR841N-v14-firmware.bin.extracted/squashfs-root/
Step 2: Service Discovery (1 hr)
# Find init scripts
cat etc/rc.d/S*
# Services found:
# - telnetd on 0.0.0.0:23 (CRITICAL)
# - httpd on 0.0.0.0:80
# - dnsmasq on 0.0.0.0:53
# Map CGI scripts
find www/ -name "*.cgi"
# CGI scripts found:
# - www/cgi-bin/admin.cgi (admin interface)
# - www/cgi-bin/upgrade.cgi (firmware upload)
Step 3: Credential Hunting (15 min)
# Check shadow file
cat etc/shadow
# Output: admin:5up:0:0:admin:/root:/bin/sh
# Check config files
grep -ri "password" etc/config/
# Output: option admin_password 'admin'
# CRITICAL: Default credentials admin:5up
Step 4: CVE Scanning (30 min)
# Check library versions
strings lib/libc.so.0 | grep version
# OpenSSL 1.0.1e (CVE-2014-0160 Heartbleed)
# Automated CVE scan
/re:firmware TL-WR841N-v14-firmware.bin --cve-scan true
# Results:
# - CVE-2014-0160 (CRITICAL): Heartbleed
# - CVE-2019-12345 (HIGH): Command injection in admin.cgi
Step 5: Binary Analysis (1 hr)
# Analyze admin CGI
/re:strings www/cgi-bin/admin.cgi
# Found: "system(sh -c %s)" - command injection
# Static analysis
/re:static www/cgi-bin/admin.cgi --tool ghidra
# Decompiled code shows:
# char *cmd = getenv("QUERY_STRING");
# system(cmd); # CRITICAL: No sanitization!
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
Scenario: Audit Wyze camera firmware for cloud API security
Step 1: Extraction (45 min)
# Extract firmware
binwalk --extract --matryoshka wyze-cam-v3-firmware.bin
# Filesystem type: UBIFS (NAND flash filesystem)
# Manual extraction required
jefferson ubifs.img --dest ./wyze-root/
Step 2: Service Discovery (1.5 hrs)
# Find cloud service configuration
grep -ri "api\|cloud\|server" ./wyze-root/etc/
# Found:
# ./etc/cloud-config.json:
# {
# "api_endpoint": "https://api.wyze.com/v1",
# "device_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
# "api_key": "sk_live_abcdef1234567890"
# }
# CRITICAL: Hardcoded API credentials!
Step 3: Analyze Cloud Communication (1 hr)
# Find MQTT broker configuration
cat ./wyze-root/etc/mqtt.conf
# Broker: mqtt.wyze.com:8883
# Username: camera-12345
# Password: hardcoded_mqtt_pass
# Analyze cloud binary
/re:strings ./wyze-root/usr/bin/cloud-agent
# Found:
# - "Bearer eyJhbGci..." (hardcoded auth token)
# - "https://firmware-updates.wyze.com/" (update URL)
**Step 4: CVE Scan (30 min
<!-- Content truncated for initial SEO render. Open the source file tab for the full file. -->Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer