Lesson 5 of 14 · 15m
Binwalk, SquashFS, and the Filesystem Inside
Entropy first, signatures second, then per-filesystem extraction with unsquashfs, sasquatch, jefferson, and ubireader.
A firmware image is a concatenation of regions — bootloader, kernel, root filesystems, config — each with its own format. Your job is to find the boundaries and open each region with the tool that understands it. binwalk is the boundary-finder.
Read the entropy first
Before carving, run binwalk -E fw.bin. The entropy plot answers the question that saves you hours: is this encrypted? A plot that's uniformly high with no dips, where the signature scan returns nothing, is ciphertext or compressed container all the way down. Carving it produces nothing. Encrypted images mean the key lives in the updater — go get UART access or the updater binary instead of fighting math.
Normal firmware has visible structure: low-entropy bootloader regions, a signature-dense kernel header, the filesystem blocks.
Signature scan and carve
binwalk fw.bin # list signatures and offsets
binwalk -e fw.bin # extract at each signature
binwalk -Me fw.bin # recursive extraction into nested containersThe output names formats and byte offsets: SquashFS filesystem, little-endian, version 4.0, compression:xz, U-Boot uImage headers, gzip streams, X.509 certificates, device tree blobs (the d00dfeed magic), CRC tables. Each one is a region boundary with a format attached.
Three more flags earn their keep: -A runs the architecture scan — opcode statistics that name MIPS, ARM, or x86 before you've carved anything; -B is the raw signature scan without extraction; -W hex-diffs a region or a whole image — the fast way to see what a silent vendor update actually changed.
Signature offsets can lie — false positives inside compressed data are routine — so verify each carve produced real files before trusting it. When binwalk finds an offset but the auto-extraction fails, dd if=fw.bin of=part.bin bs=1 skip=<offset> isolates the region manually, and --dd='.*' with a custom pattern does surgical carving when you know the magic. -Me (matryoshka mode) matters because vendors nest formats: tar inside gzip inside a signed wrapper.
The kernel regions deserve attention too: a legacy uImage wraps kernel + metadata in a U-Boot header with its own CRC; device tree blobs decode with dtc to the actual memory map and peripheral config the vendor compiled in.
Opening the filesystems
Each filesystem type has its own extractor:
- SquashFS — the default read-only rootfs on routers and cameras.
unsquashfshandles standard images;sasquatchhandles the vendor-mangled variants — vendors modified SquashFS magic for years (the DD-WRT era) and sasquatch knows the nonstandard signatures stockunsquashfsrejects. - JFFS2 — flash-friendly journaling FS on NOR.
jeffersonextracts it. - UBIFS — NAND flash FS. Needs the UBI volume layer:
ubireader_extract_imagespulls volumes from a dump,ubireader_extract_filespulls files from a volume. Feeding ubireader a raw linear dump with OOB data still interleaved is the classic failure — strip spare areas first. - Cramfs — compressed read-only FS on older routers, extracted with
cramfsck/fsck.cramfs; it shows up on firmware old enough to also carry JFFS2. - CPIO/gzip — kernel initramfs and older rootfs images.
Check cat /proc/mtd output from the live device against your carved layout — MTD names tell you which partition is which region.
What's inside
A successful extraction is a real root filesystem: /etc/passwd and /etc/shadow, init.d scripts, the web server's CGI tree, every binary, every config. file or readelf -h on a binary gives you the architecture — big-endian MIPS is the router classic, ARM dominates newer gear, and it decides which disassembler target you feed Ghidra later.
A firmware image can hold several filesystem partitions — check the MTD layout (cat /proc/mtd on the live device) against your carved offsets so partition names map to regions, and so a jffs2 config partition doesn't get mistaken for part of the rootfs.
The extraction step is mechanical; the findings live in what you extracted. That read is the next lesson.
Practice
The sequence is always: entropy → signatures → carve → per-filesystem extraction → inventory. When a step fails, it fails for a structural reason (encryption, OOB, vendor-mangled magic, false-positive offsets) — diagnose the structure, don't retry the command.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
Running a Minecraft Network: Four JVMs, One Box, and the Settings That Lie to You
Four servers on one host means four JVMs each sizing its thread pools for a machine it does not own. The measured cost of that, the systemd ordering that guarantees nothing, and the throttle that switches itself back on when your forwarding breaks.
A Minecraft Mod Is a Program. In 2026, Attackers Started Acting Like It.
A Minecraft mod is a Java program that runs with your account's full permissions, and nothing in the game checks what it does.
Immich Had Fourteen Advisories and One Bug It Fixed Three Times
Immich's 2026 security record runs to fourteen advisories, and they cluster hard: the sharing features, the OAuth plumbing, and one login redirect parameter that took three separate fixes across eighty-three days. Plus the 3.0 migration traps still waiting for anyone who hasn't jumped yet.
Building a Minecraft Network: Four Servers Pretending to Be One Place
A proxy, a lobby, an SMP and a PvP arena is four JVMs that know nothing about each other. What actually has to be shared, why your permissions don't follow players, and the two LuckPerms defaults that silently share nothing at all.