Every embedded security researcher hits the same rite of passage: you download an official "2026 Security Maintenance" firmware archive for a dual-core ARMv7 gigabit Wi-Fi router, inspect the unpacked root filesystem, and discover Linux version 2.6.36.4brcmarm โ a kernel tree frozen in October 2010. Before you can audit userland daemons, inspect proprietary Wi-Fi drivers, or build a clean-room mainline OpenWrt replacement, you need to understand how router firmware containers are structured at the byte level rather than treating extraction tools as magic black boxes.
5-Part IoT Router Firmware & Linux Wi-Fi Driver Reverse Engineering Curriculum
This hands-on curriculum teaches defensive hardware/firmware reverse engineering and clean-room Linux mac80211 driver architecture on dual-core Broadcom BCM4709A0 + dual BCM4360 (14e4:43a0) 802.11ac routers without spoiling your lab exercises:
- Part 1 (You Are Here): Dissecting NETGEAR
.chk, BroadcomTRX&SquashFSContainers by Hand - Part 2: ARM
ET_RELKernel Modules,.rel.rodataTables & D11 Microcode - Part 3: Black-Box
BAR0Page-Fault MMIO Traps & Differential NVRAM Fuzzing - Part 4: Clean-Room Linux 6.12
mac80211, BCMA Windowing &B43DFirmware Loaders - Part 5: 2.6.36-to-6.12
sk_buffABI Interposition vs. Native OpenWrt 25.12 Packaging
Need commercial white-hat firmware auditing or custom BSP bring-up for your OEM hardware line? Explore our IoT Router Reverse Engineering Consultancy.
1. The "Frozen Kernel" Paradox in Consumer & SMB Gateways
Why would an OEM release notes page dated 2026 ship a kernel older than systemd, modern eBPF, WireGuard, and fifteen years of upstream memory-corruption mitigations (such as ARMv7 CONFIG_STRICT_KERNEL_RWX, stack protector canaries, and hardened usercopy)? The answer is binary Board Support Package (BSP) lock-in.
When a silicon vendor delivers a reference SDK for an embedded System-on-Chip (such as the dual-core Cortex-A9 Broadcom BCM4709A0 Northstar platform), the SDK couples three components tightly to one specific Linux kernel version:
- Proprietary Wireless Kernel Module (
wl.ko/wl_apsta.o): A 6โ8 MB precompiled ARM object implementing 802.11ac wave-1 beamforming, 3x3:3 AC-PHY calibration, and Radio 2069 register programming for the dual PCIeBCM4360chips. - Proprietary Packet Accelerators (
ctf.ko/et.ko): Cut-Through Forwarding hooks injected directly intostruct sk_buffand the Ethernet DMA ring to bypass Linux Netfilter on established NAT flows. - NVRAM & SROM Board Glue: Non-standard kernel exports reading per-unit RF calibration keys (
pci/1/1/...andpci/2/1/...) directly out of raw MTD flash partitions.
Because mainline Linux deliberately refuses to maintain a stable internal C ABI for out-of-tree modules, an OEM without full silicon register documentation cannot recompile wl_apsta.o against Linux 6.12. Instead, OEM security teams spend years cherry-picking userland patches onto a 2010 kernel โ leaving legacy ioctl handlers, unhardened kernel heaps, and obsolete wireless stacks exposed while simultaneously blocking mainline OpenWrt users from enabling 5 GHz 802.11ac Wi-Fi.
2. Why Security Researchers Parse Headers Before Running Binwalk
Automated signature scanners such as binwalk scan files byte-by-byte for magic constants (HDR0, hsqs, 1f 8b, 5d 00 00). Signature scanning works well on standard images, yet fails or misleads researchers in three routine real-world cases:
- False-Positive Signatures Inside Compressed Streams: A 4-byte ASCII sequence like
hsqsor an LZMA dictionary header frequently occurs inside random high-entropy compressed data or inside a bootloader's string table, causing naive carvers to extract truncated garbage. - Vendor Header Obfuscation & Custom Checksums: If you later repack or flash a test image during authorized hardware research, Broadcom's CFE bootloader and the OEM web upgrader verify exact header lengths, board-ID strings, and inverted IEEE CRC-32 fields before touching NAND/NOR flash.
- Endianness Transitions: Many router images mix big-endian outer headers with little-endian inner partition tables. Understanding where and why the byte order flips builds the mental precision required for binary exploit analysis and kernel driver work.
3. Layer 1: The Big-Endian NETGEAR .chk Envelope (Offset 0x00)
Open any stock R7000 factory image (R7000-V1.0.12.216_10.2.122.chk, 30,666,810 bytes) โ or even an OpenWrt factory transition image (openwrt-25.12.6-bcm53xx-generic-netgear_r7000-squashfs.chk) โ with xxd -g 1 -l 96:
00000000: 2a 23 24 5e 00 00 00 3a 01 01 0c d8 36 02 79 97 *#$^...:....6.y.
00000010: 00 00 00 00 36 02 79 97 00 21 e5 c8 01 b2 0a 38 ....6.y..!.....8
00000020: 29 5b e1 5d 13 a4 64 11 55 31 32 48 32 37 30 54 )[.]..d.U12H270T
00000030: 30 30 5f 4e 45 54 47 45 41 52 48 44 52 30 00 f0 00_NETGEARHDR0..
00000040: d3 01 38 69 78 52 00 00 01 00 1c 00 00 00 ac e5 ..8ixR..........
00000050: 21 00 00 00 00 00 5d 00 00 00 01 ac 7c 42 00 00 !.....].....|B..
Look closely at bytes 0x04..0x07: 00 00 00 3a. Because the most-significant zero bytes come first, this outer header is encoded in big-endian (network) byte order, even though the BCM4709A0 Cortex-A9 CPU runs in little-endian mode! That 0x0000003a value equals decimal 58, telling us the outer .chk header ends at byte 0x39 and the inner payload begins at 0x3a.
| Byte Offset | Width & Endianness | Field Name | Observed R7000 Value | Bootloader / Upgrader Purpose |
|---|---|---|---|---|
0x00..0x03 |
uint32 BE (>I) |
magic |
0x2A23245E (*#$^) |
Identifies an official NETGEAR packet / .chk firmware image |
0x04..0x07 |
uint32 BE (>I) |
header_len |
58 (0x3A) |
Exact byte offset where the inner Broadcom TRX header begins |
0x08..0x0F |
8 bytes |
reserved / fw_ver |
01 01 0c d8 ... |
Encoded version tuple (1.0.12.216 -> 0x0c = 12, 0xd8 = 216) |
0x10..0x27 |
6 x uint32 BE |
crc & lengths |
Kernel/RootFS sizes & CRCs | Checked by userland HTTP upgrade CGI before erasing MTD flash |
0x28..0x39 |
18 bytes ASCII |
board_id |
U12H270T00_NETGEAR |
Hardware SKU lock preventing cross-flashing incompatible PCB layouts |
Notice a classic hex-dump optical illusion at offset 0x28..0x3d: in the ASCII column on the right, U12H270T00_NETGEAR runs directly into HDR0 with no NUL terminator in between (U12H270T00_NETGEARHDR0)! If a sloppy parser calls read_cstring() at offset 0x28 instead of bounding its slice strictly to buf[40:header_len], it misidentifies the board ID. Always bound variable-length header strings by explicit length fields.
4. Layer 2: The Little-Endian Broadcom TRX v1 Header (Offset 0x3A)
Once the stock web GUI verifies and strips the 58-byte .chk wrapper, it writes the remaining 30,666,752 bytes straight to the linux MTD partition in NAND/SPI flash. At boot, Broadcom's Common Firmware Environment (CFE) reads offset 0x00 of that flash partition โ which corresponds to offset 0x3A in our .chk file โ and parses a 28-byte little-endian trx_header structure (struct.unpack_from('<4sIIIIII', buf, 0x3A)):
| File Offset | TRX Offset | C Type (LE) | Field | Decoded Value & Meaning |
|---|---|---|---|---|
0x3A..0x3D |
+0x00 |
char[4] |
magic |
"HDR0" (0x30524448 little-endian) |
0x3E..0x41 |
+0x04 |
uint32 |
len |
0x01D3F000 (30,666,752 bytes = exact file size minus 58!) |
0x42..0x45 |
+0x08 |
uint32 |
crc32 |
0x52786938 โ inverted CRC-32 over trx[12 : len] |
0x46..0x49 |
+0x0C |
uint32 |
flag_version |
0x00010000 โ upper 16 bits = TRX version 1 |
0x4A..0x4D |
+0x10 |
uint32 |
offsets[0] |
0x0000001C -> LZMA kernel at 0x3A + 0x1C = 0x56 |
0x4E..0x51 |
+0x14 |
uint32 |
offsets[1] |
0x0021E5AC -> SquashFS rootfs at 0x3A + 0x21E5AC = 0x21E5E6 |
0x52..0x55 |
+0x18 |
uint32 |
offsets[2] |
0x00000000 (unused third partition slot) |
Verifying the Kernel Stream at 0x56
Check bytes 0x56..0x5A in our hex dump above: 5d 00 00 01 00. Every seasoned firmware analyst recognizes 5d 00 00 on sight: it is a classic raw LZMA1 properties header (lc=3, lp=0, pb=2 -> (2 * 5 + 0) * 9 + 3 = 93 = 0x5D) with a dictionary size of 0x00010000 (64 KiB) or 0x01000000 (16 MiB). CFE decompresses this stream into DRAM at 0x00008000 and jumps directly into the ARMv7 kernel entry point.
Once you slice blob[0x56 : 0x21E5E6] and decompress it with Python's standard lzma module (handling trailing padding gracefully via lzma.LZMADecompressor(lzma.FORMAT_ALONE)), running strings against the resulting raw vmlinux image immediately confirms the exact compiler, build timestamp, and kernel tree:
$ python3 -c '
import lzma, pathlib
raw = pathlib.Path("firmware/R7000-V1.0.12.216_10.2.122.chk").read_bytes()[0x56:0x21e5e6]
dec = lzma.LZMADecompressor(lzma.FORMAT_ALONE)
vmlinux = dec.decompress(raw)
for line in vmlinux.split(b"\x00"):
if line.startswith(b"Linux version "):
print(line.decode("ascii", "replace"))
'
Linux version 2.6.36.4brcmarm (jenkins@build-host) (gcc version 4.5.3 (Buildroot 2012.02) ) SMP PREEMPT
5. Layer 3: Auditing the SquashFS 4.0 Superblock (Offset 0x21E5E6)
Historically, Broadcom SDKs shipped non-standard SquashFS 3.x variants with swapped magic bytes (shsq, qshs, or sqlz) that crashed mainline unsquashfs. Inspecting the first 32 bytes at 0x21E5E6 with <4sIIIIHHHHHH tells you in milliseconds whether standard Linux SquashFS 4.0 tooling works out of the box:
s_magic = b"hsqs"(0x73717368): Standard little-endian SquashFS magic.s_major = 4, s_minor = 0: Mainline SquashFS v4.0 format introduced in Linux 2.6.29.compression_id = 4: Standard XZ (LZMA2) compression (IDs:1=gzip,2=lzma,3=lzo,4=xz,5=lz4,6=zstd).inodes = 1868,block_size = 131072(128 KiB blocks,block_log = 17).
Comparing all three staged images side by side reveals how stock OEM firmware, DD-WRT, and mainline OpenWrt 25.12 package the exact same U12H270T00_NETGEAR flash envelope differently:
| Staged Firmware Image | Total Bytes | .chk Len |
Kernel Offset | SquashFS Offset | Linux Kernel & Wi-Fi Stack |
|---|---|---|---|---|---|
R7000-V1.0.12.216_10.2.122.chk |
30,666,810 |
58 (0x3A) |
0x000056 |
0x21E5E6 |
Linux 2.6.36.4 + proprietary wl.ko |
factory-to-dd-wrt.chk |
29,630,522 |
58 (0x3A) |
0x000056 |
0x1E003A |
Linux 4.4.302 + ported Broadcom wl 7.14 |
openwrt-25.12.6-...-r7000-squashfs.chk |
7,733,306 |
58 (0x3A) |
0x000056 |
0x44103A |
Mainline Linux 6.12 LTS + open mac80211 |
6. Your Turn โ Hands-On Lab 01 Checkpoints (Zero Spoilers)
In the companion workbench (labs/01-firmware-containers.md and labs/starter/lab01_chk_trx_skeleton.py), implement the three parser functions yourself without calling external shell extractors:
- Implement
parse_chk_header(buf): Unpack big-endianmagicandheader_lenat offset0, reject truncated buffers or bad magic withValueError, and slicebuf[40:header_len]cleanly to recoverU12H270T00_NETGEAR. - Implement
parse_trx_header(buf, trx_offset): Unpack the 28-byte little-endian TRX v1 header attrx_offset, extractversion = (flags_ver >> 16) & 0xFFFF, and compute absolute file offsets for both the LZMA kernel and SquashFS rootfs. - Implement
parse_squashfs_superblock(buf, sqsh_offset): Decode the 32-byte SquashFS 4.0 superblock, mapcomp_idto its human-readable codec name, and runpython3 labs/verify_labs.py --lab 1until the hint-only grader reports[PASS]. - Bonus Triage Exercise: Carve the SquashFS slice to
/tmp/r7000_rootfs.sqsh, list its contents withunsquashfs -ll(never asroot, so device nodes cannot be created on your host), and locatelib/modules/2.6.36.4brcmarm/extra/wl.koin preparation for Part 2.
Continue to Part 2 of the Series
Once you have carved the root filesystem and located wl.ko, head to Part 2: Triage of ARM ET_REL Kernel Modules, .rel.rodata Tables & D11 Microcode to learn why Linux kernel modules cannot strip their relocation records โ and how those relocations hand you exact PHY calibration arrays on a silver platter.
