Skip to content

Installing Binwalk

Binwalk currently exists in two generations, and which one you get depends entirely on where you get it. Getting this straight first will save you a confused hour of following instructions written for the other one.

The Python generation (v2) is what the distributions ship. On the build machine:

$ sudo apt install binwalk
$ binwalk
Binwalk v2.3.3

The Ubuntu package is labelled 2.3.4, while the tool's own banner reports v2.3.3 — the packaging carries distribution patches under a bumped version, and the program inside reports the upstream number. Believe the banner when the documentation disagrees, and expect this small mismatch wherever a distro packages older software. This generation is a Python program; it is also what pip install binwalk delivers. Every hands-on command in this guide was run and verified against v2.3.3, and the chapters say so wherever a behaviour is generation-specific.

The Rust generation (v3) is the current upstream: a ground-up rewrite, first released in 2024, faster and stricter about the signatures it accepts. It is not what apt installs, and upstream ships no ready-made binary packages — the project's own README offers two routes, building its Docker image or compiling from source with Rust's cargo. Its command line is similar in spirit but not identical: flags have been renamed and reorganised between generations. If you build v3, treat this guide as the concepts and the workflow, and your own binwalk --help as the authority on spelling.

What the scan needs vs what extraction needs

The signature scan itself is self-contained: the program, its magic files, done. You can scan an image on a machine with nothing else installed, which is a fine way to work — scan anywhere, extract somewhere disposable.

Extraction is a federation. Binwalk carves with its own code but unpacks by calling the format's own tool, so a full working install is binwalk plus a shelf of helpers:

For unpacking Install
SquashFS (standard) squashfs-tools (unsquashfs, mksquashfs)
SquashFS (vendor-modified) sasquatch (separate project, usually built from source)
JFFS2 jefferson (Python package)
UBI / UBIFS ubi_reader (Python package)
Seven-zip formats and much else p7zip-full

On the build machine, installing the distro binwalk package pulled in a long train of dependencies on its own (the package's maintainers know about the federation), and squashfs-tools provided the one helper this guide's specimen exercises. Install the rest as images demand them — the filesystems chapter names which helper belongs to which format, and its standing symptom holds: a member that carves but won't unpack is a missing helper, not a broken image.

Platform notes

  • Linux is home ground: both generations are developed there, and every command in this guide ran on Ubuntu 24.04.
  • macOS can run the Python generation under Python 3, and the Rust generation by compiling it; expect the extraction helpers to be the friction, not binwalk itself. (Not verified on this build; stated from the project's documentation.)
  • Windows is not a native home for either generation. The practical route is the one firmware people actually use: a Linux virtual machine, or upstream's Docker image for v3. Analysis inside a VM is also the safer arrangement the extraction chapter recommends everywhere, so the detour costs nothing.

A first honesty check on your install

Before trusting any scan, ask your install what it is and what it knows:

$ binwalk --help          (the flags your generation actually has)
$ binwalk some-empty-file (a scan that must return an empty table)

And when you later run a matryoshka scan, the output header reports Signatures: 411 on this build — the size of the signature library your install is matching against. That number moves between versions, and noting yours is part of describing any result honestly: a scan is only ever "nothing found by these signatures."

Check: you can say which generation you have (the banner), which helpers your extraction can call (the table above), and how many signatures your scan is worth (the header count). Everything after this chapter assumes those three answers.