Skip to content

Entropy

Signatures find what they recognise. When an image holds a region that matches nothing — an encrypted blob, a compressed stream whose format binwalk doesn't know, a filesystem it has no signature for — the question changes from what is it to where does it start and stop. That is the question entropy analysis answers, approximately, and it is worth being precise about the approximation.

Entropy, here, is a number per block of the file, between 0 and 1, measuring how unpredictable the bytes in that block are. Blocks of zeros or repeating text score near 0. Blocks of compressed data score high — compression removes pattern, which is its job. Blocks of encrypted data or genuinely random bytes score highest of all, near 1. Binwalk splits the file into blocks, scores each one, and reports the edges: the offsets where the score crosses a high threshold (default 0.95, rising edge) or a low one (default 0.85, falling edge).

The specimen, run with the plot suppressed so the numbers stand alone:

$ binwalk --entropy --nplot specimen.bin

DECIMAL       HEXADECIMAL     ENTROPY
--------------------------------------------------------------------------------
0             0x0             Falling entropy edge (0.016505)
69632         0x11000         Rising entropy edge (0.961859)

Read against the manifest, that is honest but coarse:

  • The falling edge at 0 (score 0.017) is the 64 KB of zero padding after the header — as close to no information as bytes get.
  • The rising edge at 0x11000 is where the file becomes dominated by compressed data. Note where it lands: not at the SquashFS (0x10000), whose gzip-compressed bulk is preceded by its own lower-entropy metadata, but a member later, at the first standalone gzip. Edges are computed over blocks, and a block is an average — an edge marks the block where the balance tipped, not the byte where a member begins.
  • No falling edge is reported for the end of the random region, even though the image ends shortly after it: the trap and padding that follow total a few dozen bytes, far under a block. Small things vanish at block scale. The 143-byte gzip member never appears as a feature of its own either.

The plot is the more useful form for a real image. --entropy --save writes a PNG beside the target (for the specimen, specimen.bin.png, 579 × 453 pixels): offset along the bottom, entropy up the side, the thresholds drawn in. Plateaus are what you read: a long high shelf is a compressed or encrypted region worth investigating; a low plain is structured or empty data; the mountain range in between is usually ordinary code and text. -F trades detail for speed on big images; -H and -L move the two thresholds when the defaults draw edges in unhelpful places.

What entropy cannot tell you

  • Compressed or encrypted? It cannot say. Both are high-entropy by design, and no amount of staring at the plot separates a gzip stream from an AES blob. What separates them is a signature, a format header, or knowledge of the device — entropy only points.
  • Where exactly a member starts. Edges are block averages; treat them as "within this neighbourhood," then carve generously and let a signature scan of the carve find the true start.
  • Anything at all about small members. A config file, a key, a tiny archive — all invisible at block scale. The plot is a map of regions, not of files.

Used within those limits, entropy earns its place: it is how you find the one region of a two-megabyte image that no signature explains, and how you decide whether an unrecognised image is mostly empty scaffolding or solid compressed data before spending an hour on it.

Check: on the specimen, the two reported edges bracket exactly the story the manifest tells — emptiness first (falling edge, 0.017), then a compressed world (rising edge, 0.962) — and the chapter's caveats are visible in the same two lines: the edge is one member late and the tail of the file is missing entirely.