#Why this matters
Every embedded security assessment starts with a single question: how do you get the binary off the device? Unlike desktop applications distributed as installers, IoT firmware lives inside soldered flash chips, locked microcontrollers, or vendor update servers. Without a clean copy of the firmware image, you cannot audit filesystem permissions, inspect web handlers, or look for hardcoded keys.
In practice, firmware acquisition follows a ladder from least invasive to most invasive. Starting with vendor downloads and network captures avoids unnecessary soldering, while hardware flash dumps and bootloader consoles cover devices whose updates are encrypted or unpublished.
#Method 1: Vendor portals and OTA captures
Before opening a plastic enclosure, check whether the vendor publishes firmware archives on a public support portal. Many routers, cameras, and industrial gateways ship full unencrypted .bin or .img images for manual recovery. When no public file exists, an isolated lab network lets you observe how the device fetches over-the-air (OTA) updates.
In an authorised lab, place the device behind a dedicated test access point or Ethernet bridge running packet capture. Inspect DNS queries and HTTP or MQTT update checks to locate the manifest URL and payload endpoint.
Modern devices fetch updates over TLS and verify cryptographic signatures inside the bootloader. Even when TLS is enforced, the manifest or server headers occasionally reveal version strings, staging paths, or whether a rollback to an older unencrypted image is accepted.
$ sudo tcpdump -i br-iot -w /tmp/ota_capture.pcap host 192.0.2.10
tcpdump: listening on br-iot, link-type EN10MB (Ethernet), snapshot length 262144 bytes#Method 2: Dumping SPI flash with flashrom
When OTA images are encrypted end-to-end or unavailable, look on the PCB for an 8-pin SOIC or WSON SPI NOR flash chip. Using the SPI wiring concepts from earlier hardware lessons, an analyst attaches a test clip (or desolders the chip to a breakout socket) connected to a USB programmer supported by flashrom, such as an FT2232H or CH341A adapter.
In-circuit reading often fails if the main SoC wakes up and drives the SPI bus at the same time as your programmer. Two precautions prevent corrupted dumps:
- Hold the SoC in reset (for example, by pulling its
RESETpin to ground if confirmed on the schematic) or desolder the flash chip for clean out-of-circuit reads. - Always read the chip at least twice and compare SHA-256 digests before touching anything else.
$ flashrom -p ft2232_spi:type=2232H,port=A -r dump1.bin
flashrom v1.3.0 on Linux 6.6.0-amd64 (x86_64)
Found Winbond flash chip "W25Q128.V" (16384 kB, SPI) on ft2232_spi.
Reading flash... done.
$ flashrom -p ft2232_spi:type=2232H,port=A -r dump2.bin
Reading flash... done.
$ sha256sum dump1.bin dump2.bin
9f4c2a18e7b0c13d88412f9a0e7710a2c5b6d8e9f0123456789abcdef0123456 dump1.bin
9f4c2a18e7b0c13d88412f9a0e7710a2c5b6d8e9f0123456789abcdef0123456 dump2.binIf dump1.bin and dump2.bin differ by even a single byte, suspect loose clip contacts, bus contention from the SoC, or excessive wire length. Never trust a single read.
#Method 3: Debug ports and bootloaders
Microcontrollers often store firmware in internal flash rather than an external SPI package, while larger Linux SoCs expose UART or JTAG pads on the board. Both interfaces offer reliable extraction paths when debug protections are left open.
| Interface | Typical tool | Key limitation |
|---|---|---|
| JTAG / SWD | OpenOCD | Blocked if Read-Out Protection (RDP) or debug fuses are set |
| UART (U-Boot) | Serial terminal + TFTP / log parser | Requires interactive shell or non-zero boot delay |
| SPI NOR | flashrom + USB programmer | Vulnerable to bus contention during in-circuit reads |
#OpenOCD over SWD or JTAG
When SWD or JTAG is enabled, OpenOCD halts the core and copies internal flash directly over the debug adapter. After launching OpenOCD with the matching interface and target configuration files, connect to its management port (default TCP 4444) to issue memory commands.
$ openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f target/stm32f4x.cfg
Open On-Chip Debugger 0.12.0
Info : Listening on port 4444 for telnet connections
# In a second terminal:
$ nc 127.0.0.1 4444
> halt
> dump_image mcu_flash.bin 0x08000000 0x100000
dumped 1048576 bytes in 4.210845 sec (243.181 KiB/s)#Bootloader extraction via U-Boot
On embedded Linux boards, interrupting the U-Boot countdown over UART drops you into a privileged bootloader prompt. From there, inspect partition boundaries (printenv or mtdparts), load flash blocks into RAM (sf read for SPI flash or nand read), and either send them over Ethernet with tftpput or print hex bytes to the serial log using md.b for offline reconstruction.
=> printenv mtdparts
mtdparts=mtdparts=spi0.0:256k(u-boot),64k(env),2048k(kernel),14016k(rootfs)
=> sf probe 0
SF: Detected w25q128fw with page size 256 Bytes, erase size 4 KiB, total 16 MiB
=> sf read 0x82000000 0x240000 0x20000
device 0 offset 0x240000, size 0x20000
SF: 131072 bytes read: OK#Quick triage with binwalk
Once you hold a raw dump, confirm that it actually contains recognizable code rather than all 0xFF bytes (empty flash) or pure random noise (encrypted flash). Running binwalk -E plots Shannon entropy across offsets: plateaus near 1.0 indicate compressed or encrypted regions, whereas structured drops below 0.8 typically mark uncompressed bootloaders, strings, or padding.
#Hardening and common mistakes
Vendors frequently leave physical extraction paths wide open even when OTA updates are signed:
- Unfused debug interfaces: leaving JTAG/SWD active or setting RDP level 0 lets anyone dump internal flash in seconds. Production firmware should enable RDP/secure debug locks and disable UART interactive consoles (
bootdelay=0, password-protected or disabled CLI). - Unencrypted external flash: storing secrets in plaintext on external SPI NOR makes chip-off extraction trivial. Sensitive keys should stay inside an isolated secure element, TPM, or hardware-backed keystore.
- Analyst mistake - ignoring voltage levels: clamping a 3.3 V programmer directly onto a 1.8 V flash chip (common on newer SoCs) corrupts reads and destroys silicon. Always read the chip part number and datasheet first.
- Analyst mistake - single-pass dumping: analyzing a noisy first dump wastes hours chasing false "corrupted" filesystems. Always hash-compare at least two independent reads.
#Summary
Firmware acquisition moves from non-invasive vendor portals and isolated OTA traffic captures to physical SPI flash dumping and bootloader/debug interfaces. Use flashrom with dual-read SHA-256 verification to rule out bus contention, leverage OpenOCD or U-Boot when internal flash or locked buses block external reads, and check image entropy with binwalk before unpacking filesystems.