The Worked Specimen
One image, every technique, start to finish. This chapter is the whole guide compressed into a single sitting: if you run nothing else, run this. You will build the specimen, scan it, extract it, recurse into it, and prove two planted files recovered — checking each stage against knowledge you hold independently, never against binwalk's own confidence.
You need: binwalk installed (chapter 2),
mksquashfs (the squashfs-tools package),
Python 3, and the files from this guide's
examples/ folder.
1. Build, and keep the manifest
$ python3 make_specimen.py
wrote .../specimen.bin (78202 bytes)
offset hex size member
0 0 16 invented header (no Binwalk signature)
65536 10000 4096 SquashFS root filesystem
69632 11000 143 gzip member (release notes)
69776 11090 171 gzip member (tar with marker)
69952 11140 8192 random data (entropy stand-in)
78144 13140 58 TRAP: bare gzip magic, no stream
Before scanning, hash the planted file in its source form. This number is your ground truth:
$ sha256sum specimen-build/rootfs/notes/field-notes.txt
7ccaa2b81c3f9aa9d677756ff16be21f13ada62afcc82fe19abdfbe6bc944a1e
2. Scan, then reconcile
$ binwalk specimen.bin
65536 0x10000 Squashfs filesystem, little endian, version 4.0, ...
69632 0x11000 gzip compressed data, ...
69776 0x11090 gzip compressed data, ...
All three real members at the manifest's offsets, to the byte. The header, the random region, and the trap are absent — each for a reason you can name (no signature; no pattern; validated away). If any row had disagreed with the manifest, the manifest wins: it was written by the builder, not inferred.
3. Peek at the edges
$ binwalk --entropy --nplot specimen.bin
0 0x0 Falling entropy edge (0.016505)
69632 0x11000 Rising entropy edge (0.961859)
Zeros first, then the compressed world. The rising edge sits one member later than the compressed region's true start — block averages, not boundaries — which is the expected accuracy of the instrument.
4. Extract, then prove a file
$ binwalk -e specimen.bin (add --run-as=root if you are root)
Walk to the recovered notes file and hash it:
$ sha256sum _specimen.bin.extracted/squashfs-root/notes/field-notes.txt
7ccaa2b81c3f9aa9d677756ff16be21f13ada62afcc82fe19abdfbe6bc944a1e
Digit for digit, the same as step 1. That equality — not the extraction log, not the scan table — is the proof that the pipeline image → scan → carve → unpack returned the planted file intact.
5. Recurse to the bottom of the nest
$ binwalk -Me specimen.bin (add --run-as=root if you are root)
$ cat _specimen.bin.extracted/_11090.extracted/deep/marker.txt
Nested marker, carried inside a tar inside a gzip.
Nested marker: WOMBAT-2210-CANDLE.
The marker was inside a tar, inside a gzip,
inside the image. Plain -e left it entombed
in the carved 11090 file (a tar, unopened);
-M opened each generation in turn and
scanned even the final text file, finding
nothing — the empty table that certifies the
bottom.
6. Interrogate the scan itself
$ binwalk -I specimen.bin
... the three real members, plus:
76003 0x128E3 Microsoft executable,
78144 0x13140 gzip compressed data, invalid extra flags, ...
The phantom executable inside random noise,
and the trap with its garbage filename and
its 2031 date, both present once the
invalid-filter is lifted. Finish by trying to
make the trap confess the other way — a raw
search finds its magic happily
(binwalk -R '\x1f\x8b\x08' reports all three
gzip offsets), while extraction produces
nothing from it: three tools, three different
opinions of the same bytes, and only the
extraction attempt actually tests the claim.
Check: you have built an image whose contents you know, watched a scan reproduce that knowledge exactly, recovered a file and proven it byte-identical by checksum, recovered a second file from three layers down, and caught the scanner both hiding and hallucinating results — with the reasons for each behaviour named. That is the complete binwalk workflow, and every later chapter of real-world images is these six steps with higher stakes.