Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Technique:Unpacking firmware update containers

From ReverseEngineering.wiki
Technique
On this wiki Facts · Code · Notes · Topics

Order of work for Android, U-Boot and Rockchip firmware packages: identify the outer container by magic, peel it down to partition images, then identify the filesystem or boot image inside.

Outer containers and their first bytes

Magic at offset 0 Container Page
43 72 41 55 ("CrAU") Android A/B OTA payload.bin Format:Android OTA payload (payload.bin)
3A FF 26 ED Android sparse image Format:Android sparse image
67 44 6C 61 at 4096 super partition geometry ("gDla") Format:Android LP metadata (super.img)
ANDROID! / VNDRBOOT boot, recovery, vendor_boot Format:Android boot image
27 05 19 56 U-Boot legacy uImage Format:U-Boot legacy uImage
D0 0D FE ED FIT image or device tree Format:FIT image, Format:Flattened device tree
52 4B 46 57 ("RKFW") Rockchip update.img Format:Rockchip RKFW update image
: lines / S0..S9 lines Intel HEX / Motorola S-record text Format:Intel HEX, Format:Motorola S-record

Typical Android chain

  1. OTA zip: take payload.bin (check CrAU), decode its manifest, apply REPLACE* operations per partition (full OTA) to get raw partition images.
  2. Images may be sparse (fastboot factory images): expand them to raw.
  3. super image: read the LP metadata and cut out system, vendor, product...
  4. boot and vendor_boot: split kernel, ramdisk and dtb by header version; the ramdisk is Format:Cpio newc (initramfs).
  5. The filesystems (ext4, erofs, f2fs) are mounted or extracted with the usual tools.

Allwinner IMAGEWTY (recognition only)

Unverified: Allwinner PhoenixSuit/LiveSuit images (.img) start with the 8 ASCII bytes IMAGEWTY and carry a header with a version and a table of named sub-files (boot0, boot1, u-boot, kernel, rootfs parts), each with a main type and sub type string; no field layout was read for this page. Check the linux-sunxi wiki and the open source unpackers before relying on it.

Router vendor headers before the kernel

Consumer router images usually wrap the kernel and root filesystem in a vendor header that binwalk-style scanning has to skip. Check the first bytes and the last 16 bytes:

Where Bytes Container Page
offset 0 48 44 52 30 ("HDR0") Broadcom TRX, little-endian, 28/32-byte header, partition offsets Format:Broadcom TRX
offset 0 2A 23 24 5E ("*#$^") Netgear CHK, big-endian, board id string, usually around a TRX Format:Netgear CHK
offset 0 00 00 00 01 or 02 + "TP-LINK Technologies" TP-Link 512-byte header; salted MD5 Format:TP-Link firmware header
offset 0x14 fw-type:Cloud, ?NEW, or fwup-ptn table at 0x1014 TP-Link safeloader image Format:TP-Link firmware header
offset 0 5E A3 A4 17 SEAMA (D-Link and others), big-endian Format:SEAMA
tar member sysupgrade-<board>/CONTROL OpenWrt sysupgrade tar Format:OpenWrt sysupgrade tar
last 16 bytes 46 57 78 30 ("FWx0") 16 bytes from the end OpenWrt metadata/signature trailer Format:OpenWrt fwtool trailer

Order of work: strip trailing fwtool trailers (check their CRC), skip the outer vendor header (read the length fields rather than guessing), then identify the payload again (TRX, Format:U-Boot legacy uImage, Format:FIT image, Format:SquashFS, Format:LZMA). Each of these checksums is only an integrity check of the header and payload, so edited images are detectable by recomputing them; do not treat them as an authentication barrier on their own.

Zyxel, Linksys and other vendors have their own headers (firmware-utils has tools such as mkzynfw, zyimage and linksys-addfwhdr). Unverified: no field layout was read for those for this page.

Pitfalls

  • Vendors wrap or sign these formats (AVB footers, vendor headers, encrypted payloads); a wrong magic at offset 0 may only mean a prefix. Scan the first few KiB.
  • Do not run signature-bypass advice from forums; recognizing the signature block is enough for analysis.
  • Check the signature-like trailers (MD5 after RKFW firmware, AVB footer at the end of a partition) before concluding a file is truncated.