Skip to content

Lesson 6 of 14 · 20m

Reading the Image Like an Auditor

A systematic pass over an extracted rootfs: secrets, accounts, listeners, web handlers, and emulation with FirmAE.

Once the rootfs is extracted you're holding the complete operating system the vendor ships — accounts, listeners, web handlers, keys. Auditing it is a systematic pass, not a vibes read. Here's the order that finds things.

Secrets first

grep -r "PRIVATE KEY" .
grep -rEi "password|passwd|apikey|api_key|secret" .
strings -n 8 binary | less

Private keys and certs ship in firmware constantly — PEM blocks, keystore files, .htpasswd, config XML. Every private key found is public by definition once the image is downloadable or the chip is readable. Note each one and which component uses it; the same PEM across three SKUs is a finding by itself.

URLs and hostnames are next — grep -rEo 'https?://[^"'\'' ]+' over the tree: update endpoints, NTP servers, cloud backends, hardcoded API hosts. They tell you where the device phones home and which domains are load-bearing. An update endpoint on a domain that lapses is a future hijack — that lesson comes later, but the inventory happens here.

Accounts and listeners

/etc/passwd and /etc/shadow are the crown file — the account list and the hashes that gate them. A single root hash — typically $1$ md5crypt — that ships in every unit means one cracking run yields root on the whole fleet. john or hashcat against md5crypt is minutes of work, not days.

Then enumerate what listens: telnetd, dropbear, sshd, lighttpd, mini_httpd, miniupnpd, TR-069 CWMP clients (easycwmp). Read /etc/init.d/ and inittab — what's started at boot is the attack surface, regardless of what the marketing page describes. Check crontab and rc.local too — persistence points the vendor shipped and an attacker inherits — and find . -perm -4000 for setuid binaries: each one is a privilege boundary crossing worth opening. A telnetd launched from init with a compiled-in account is the Mirai pattern sitting in front of you.

The web tree is where the bugs live

Router and camera web UIs are CGI-era code: shell handlers that build command strings. The classic bug class is command injection in diagnostic endpoints — ping, traceroute, ntp pages that take user input into system(). Equally classic is auth bypass through request metadata: devttys0 found in 2013 that sending User-Agent xmlset_roodkcableoj28840ybtide — "editby04882joelbackdoor" spelled backwards — bypassed authentication entirely on D-Link DIR-100-class firmware. That wasn't a weird one-off; hidden checks keyed on magic strings are a genre.

Grep the CGI tree for system(, popen(, exec, and sprintf into command buffers. Then open the interesting binaries — httpd, the updater, the telnet handler — in Ghidra. The productive workflow: load the binary, run the string search, follow cross-references from interesting strings ("password", "telnet", odd UA fragments) back to the functions that compare them, and read the auth check as code — where the comparison happens, what it short-circuits, which requests skip it. Backdoors and auth bypasses live exactly there, and they read fast because the check is usually five instructions and a strcmp.

Emulation: run it instead of only reading it

Static reading misses what the system does assembled. Two projects run real firmware in QEMU without hardware: FAT — the Firmware Analysis Toolkit — packages Firmadyne, the original extract-and-boot pipeline, into a one-command runner. FirmAE is the maintained successor emulator: same loop, plus an arbitration pass that fakes the hardware details firmware expects — emulated NVRAM, stubbed peripherals — so most images boot where Firmadyne managed a fraction. When emulation works you get the actual web UI in a VM — fuzzable, pokeable, no hardware required. When it fails, it fails because the firmware expects hardware emulation can't fake — which is itself information.

Deliverable

The output of this pass is a concrete list: accounts and their hash types, services and their listeners, secrets and where they're reused, injectable endpoints, emulation status. Not "the firmware looks old." A junior writes vibes; a senior writes the list an exploit gets built from. And every item on the list should carry its file path and offset — "telnetd launched by /etc/init.d/S50" is actionable, "there's telnet" is not.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.