GO KALI FREE

Binwalk

Forensics

Intermediatelow risk

Learn how to use Binwalk to scan a firmware image, read the signature table, extract embedded filesystems, and spot encrypted regions — a beginner tutorial for Kali Linux.

Installation

sudo apt update && sudo apt install binwalk -y

Basic Syntax

binwalk [options] <file>

Quick Facts

Full Name
Binwalk Firmware Analysis Tool
License
MIT License
Author
ReFirm Labs
Written In
Python
Platforms
Linux, macOS, Windows
Category
Firmware Analysis
First Release
2010
Key Feature
Signature Scanning & Extraction

Tool Overview

Binwalk is a command-line tool that scans a binary file for known file signatures and extracts the files, filesystems, and code hidden inside it. To use Binwalk, install it with sudo apt install binwalk, then run binwalk firmware.bin to list every embedded format and its byte offset, and binwalk -e firmware.bin to extract what it found.

The beginner loop is install, scan, read, extract, recurse, inspect: install Binwalk and its extraction helpers, run a plain signature scan first, read the offset table to understand the firmware layout, extract with -e, recurse into nested content with -Me, then inspect the extracted filesystem for credentials, configuration files, and vulnerable binaries.

A first scan of a router firmware image looks like this: binwalk router-fw.bin prints a table with three columns — DECIMAL, HEXADECIMAL, and DESCRIPTION. A typical result reads 0 0x0 uImage header, 64 0x40 LZMA compressed data, and 131136 0x20040 SquashFS filesystem, little endian, version 4.0. Read it top to bottom: the uImage header at offset 0 describes the boot image, the LZMA block at offset 64 is the compressed kernel, and the SquashFS filesystem at offset 131136 is the root filesystem — the part you will extract and inspect. The final line, Analyzed 1 file for ... signatures, confirms the scan finished.

Mind the version: Kali Linux ships Binwalk v2.4.3, the Python original from ReFirm Labs, and v2 reaches end of life on 12 December 2025. Binwalk v3 is a Rust rewrite with a different command set, and on Kali it installs as the separate binwalk3 package — type binwalk3 instead of binwalk for v3. This guide covers the v2 commands Kali installs by default; v2 has no --version flag, so check your install with binwalk -h, which prints the version at the top.

Install Binwalk on Kali with sudo apt update && sudo apt install binwalk -y; it is pre-installed on most Kali images. Extraction only works if the helper programs for each format are present, so also install sudo apt install squashfs-tools cramfsswap zlib1g-dev liblzma-dev libbz2-dev p7zip-full sasquatch -y — sasquatch is a patched unsquashfs that handles vendor-modified SquashFS images Binwalk cannot unpack on its own. On macOS use Homebrew, on Windows use WSL, and for the newest release build v3 from the Binwalk GitHub repository.

Entropy analysis is how you find what signatures cannot see. binwalk -E firmware.bin measures how random each block of the file is on a 0-to-1 scale in v2: flat stretches near 0 are padding or plain text, the middle of the scale is code, and a flat stretch near 1 is compressed or encrypted data. A rising edge marks where compressed or encrypted data begins, a falling edge where it ends — so if a whole file sits near 1 with no signatures at all, it is most likely encrypted, and no extraction flag will open it without the key.

Only analyze firmware you are authorized to inspect, and treat every firmware image and everything it extracts as untrusted input. Work on a copy in an isolated virtual machine or container without unnecessary network access, never execute extracted binaries on your host, and record the original file's hash with sha256sum firmware.bin before you start so you can prove the evidence is unchanged.

Binwalk is the first step, not the whole job: once the filesystem is out, disassemble the interesting binaries in Ghidra, carve deleted or hidden files with Foremost, and check images for concealed data with Steghide. The same scan also wins CTF points — a PNG with a ZIP appended to it shows PNG image at offset 0 and a ZIP archive where the image ends, and binwalk -e unpacks the hidden archive.

Quick Reference Commands

Verified quick-reference commands for Binwalk
CommandPurpose
binwalk <firmware-image>Scan a firmware image for known signatures.
binwalk --extract --directory=<output-directory> <firmware-image>Extract recognized contents to a controlled directory.
binwalk --extract --matryoshka <firmware-image>Recursively extract nested content.
binwalk --carve <firmware-image>Carve identified data, including content without extraction rules.
binwalk --entropy --png=<entropy-graph.png> <firmware-image>Calculate entropy and save a PNG graph.
binwalk --log=<results.json> <firmware-image>Write JSON analysis results.
Binwalk README

Common Commands

binwalk firmware.binScan a file and print a signature analysis of embedded file types and offsets.
binwalk -e firmware.binExtract known file types found in the image using matched extraction rules.
binwalk --dd='.*' firmware.binExtract every signature match to disk regardless of type.
binwalk -M -e firmware.binRecursively scan and extract (matryoshka) through nested archives and filesystems.
binwalk -A firmware.binScan for common executable opcode signatures (architecture fingerprinting).
binwalk -E firmware.binPerform an entropy analysis to locate compressed or encrypted regions.
binwalk -E -J firmware.binRun entropy analysis and save the entropy graph as a PNG (requires matplotlib).
binwalk -B firmware.binRun a raw signature (magic) scan — the default behavior, stated explicitly.
binwalk -R "\x50\x4b\x03\x04" firmware.binSearch the file for a specific raw byte sequence (here, a ZIP header).
binwalk -Y firmware.binIdentify the CPU architecture using the capstone disassembler.
binwalk --dd='png image:png' firmware.binExtract only PNG matches and give them a .png extension.
binwalk -D 'jpeg:jpg' firmware.binExtract JPEG signatures to files with a .jpg extension.
binwalk -C ./out -e firmware.binExtract into a chosen output directory instead of the default.
binwalk -f scan.log firmware.binWrite the scan log to a file.
binwalk --csv firmware.binEmit scan results in CSV format for parsing.
binwalk -y filesystem firmware.binOnly report signatures whose description matches the given keyword.
binwalk -x compressed firmware.binExclude signatures whose description matches the given keyword.
binwalk --offset=0x100 firmware.binBegin scanning at a specific byte offset into the file.
binwalk --length=0x2000 firmware.binScan only a fixed number of bytes from the start (or offset).
binwalk -t firmware.binFormat output to the terminal width without truncating descriptions.
binwalk --run-as=root -e firmware.binAllow extraction to run as root (needed for some extractors).
binwalk -Me -d 2 firmware.binLimit recursive extraction to 2 levels deep to stop runaway nesting.
binwalk -r -e firmware.binDelete carved files after extraction to save disk space.
binwalk -z firmware.binCarve data from the file without running extraction utilities.
binwalk -V -e firmware.binExtract matches into sub-directories named by their offset.
binwalk -W firmware.bin firmware_v2.binHexdump-diff two firmware images to spot what changed between releases.
binwalk -X firmware.binScan for raw deflate compression streams with no file header.
binwalk -Z firmware.binScan for raw LZMA compression streams with no file header.
binwalk -F -E firmware.binRun a faster, less detailed entropy analysis.
binwalk -m custom.magic firmware.binScan with a custom magic signature file for proprietary formats.
binwalk -q firmware.binSuppress output to stdout so results can be scripted.
binwalk -hShow the full list of options and usage help.

Step-by-Step Guide

  1. 1Confirm you are authorized to analyze this firmware, then work on a copy in an isolated virtual machine: copy the image into a lab folder and record the original hash with sha256sum firmware.bin.
  2. 2Check the installed version with binwalk -h — Kali output starts with Binwalk v2.4.3. If the command is not found, install it with sudo apt update && sudo apt install binwalk -y.
  3. 3Install the extraction helpers so formats actually unpack: sudo apt install squashfs-tools cramfsswap zlib1g-dev liblzma-dev libbz2-dev p7zip-full sasquatch -y.
  4. 4Run your first scan: binwalk router-fw.bin. Read the DECIMAL, HEXADECIMAL, and DESCRIPTION columns top to bottom to map the firmware layout before extracting anything.
  5. 5Run entropy analysis in a separate pass: binwalk -E router-fw.bin. Note any flat high-entropy stretches — those regions are compressed or encrypted and signatures alone will not open them.
  6. 6Extract what the scan found: binwalk -e router-fw.bin. Binwalk creates a _router-fw.bin.extracted/ folder next to the image; list it with ls _router-fw.bin.extracted/.
  7. 7Recurse into nested content: binwalk -Me router-fw.bin. The -M flag re-scans every extracted file, which is how you reach a SquashFS filesystem hiding inside an LZMA-compressed kernel. Cap runaway recursion with -d 2.
  8. 8Tune a noisy scan with filters: binwalk -y squashfs router-fw.bin shows only filesystem signatures, and binwalk -x compressed router-fw.bin hides the compression noise.
  9. 9Carve a region by hand when extraction fails: take the offset and size from the scan, then dd if=router-fw.bin of=part.xz bs=1 skip=2349 count=268 cuts that exact slice out for manual inspection.
  10. 10Inspect the extracted filesystem — grep -R password _router-fw.bin.extracted/squashfs-root/etc/ for hardcoded credentials — then hand the interesting binaries to Ghidra for disassembly and record every finding with the command that produced it.

Warnings

Use Cases

Firmware Analysis

Scan firmware images to identify embedded filesystems, kernels, and configuration files for security auditing.

IoT Security Research

Extract firmware from IoT devices to find hardcoded credentials, vulnerable services, and backdoors.

Binary Reverse Engineering

Map the internal structure of compiled binaries to understand data organization and embedded components.

Entropy Detection

Identify encrypted or compressed sections within firmware to assess reverse engineering difficulty.

Embedded File Recovery

Extract embedded filesystems, bootloaders, and data partitions from monolithic firmware images.

CTF File Carving

Find files hidden inside images and binaries — a PNG with an appended ZIP is a classic CTF hiding spot.

Firmware Version Comparison

Diff two firmware releases with -W to see what the vendor changed, added, or removed.

Malware Triage

Pull embedded payloads, droppers, and second stages out of a suspicious binary for safe offline analysis.

Key Features

Related Tools

flashrom

Hardware Hacking

flashrom is a utility for identifying, reading, writing, verifying and erasing flash chips, commonly used for BIOS/EFI/firmware extraction, backup, and flashing.

Arduino

Hardware Hacking

Arduino IDE and tools for programming microcontrollers used in hardware hacking, BadUSB attacks, and IoT testing.

ExifTool

Forensics

ExifTool is a platform-independent tool for reading, writing, and editing metadata in a wide variety of files including images, audio, and video.

Autopsy

Forensics

Learn how to use Autopsy, the free digital forensics software, in a hands-on practice case. Start with a verified disk image, run ingest modules, look for deleted files, and use keyword hits and timeline entries to build a report.

Foremost

Forensics

Foremost is a forensic data recovery program that recovers files based on their headers, footers, and internal data structures.

Ghidra

Reverse Engineering

This hands-on guide shows how to use Ghidra to inspect a program you compile yourself. You'll compare decompiled code with the underlying assembly, follow cross-references, and document what the binary does without executing it.

Related Cybersecurity Guides

Security Operations · Advanced

Digital Forensics Basics: Collecting and Analyzing Evidence

Learn digital forensics fundamentals including evidence collection, forensic imaging, memory analysis, timeline analysis, and proper chain of custody procedures for investigations.

Security Operations · Intermediate

How to Analyze Logs: A Beginner's Guide to Linux, Windows & Web Log Analysis

Learn how to analyze logs step by step: read Linux and Windows logs, search with grep and journalctl, and investigate a real brute-force attack in auth.log.

Tools · Beginner

How to Use Dirb: Beginner's Guide to Directory Brute-Forcing in Kali Linux

Learn how to use Dirb in Kali Linux: run your first directory scan, pick the right wordlist, and read the results — with a worked example and cheat sheet.

Tools · Beginner

How to Use Tcpdump: Beginner's Guide to Packet Capture in Kali Linux

Learn how to use tcpdump in Kali Linux — capture packets, filter with BPF, save pcap files and read output, with a worked example and cheat sheet.

Frequently Asked Questions

What is Binwalk used for?

Binwalk is a firmware analysis tool used to scan binary files for embedded file signatures, extract embedded content, and perform entropy analysis to detect encryption or compression in firmware images.

Can Binwalk extract encrypted firmware?

No, Binwalk cannot decrypt encrypted firmware payloads. It can identify encrypted sections through entropy analysis, but decryption requires the encryption key or external tools.

How does Binwalk extract files?

Binwalk uses signature matching to locate embedded files and filesystems within a binary, then carves them out into a _extracted directory. The -Me flag enables recursive extraction for nested content.

What is entropy analysis in Binwalk?

Entropy analysis (-E flag) measures the randomness of data sections. High entropy indicates encryption or compression, while low entropy suggests structured data or uncompressed content.

How do I use Binwalk in Kali Linux?

Install it with sudo apt update && sudo apt install binwalk -y (it is pre-installed on most Kali images), then run binwalk firmware.bin to scan, binwalk -e firmware.bin to extract, and binwalk -Me firmware.bin to extract recursively. Check the version with binwalk -h — Kali ships v2.4.3.

What is the purpose of Binwalk?

Binwalk finds and extracts the files, filesystems, and code hidden inside a binary file or firmware image. Its purpose is firmware analysis: it maps a firmware image's internal layout by signature, extracts the root filesystem for inspection, and uses entropy analysis to spot compressed or encrypted regions.

How do I install Binwalk?

On Kali Linux: sudo apt update && sudo apt install binwalk -y. Also install the extraction helpers with sudo apt install squashfs-tools cramfsswap zlib1g-dev liblzma-dev libbz2-dev p7zip-full sasquatch -y. On macOS use Homebrew; on Windows use WSL. Binwalk v3 installs separately as the binwalk3 package on Kali.

How do I extract all files with Binwalk?

Run binwalk -Me firmware.bin: -e extracts every recognized format and -M recurses into each extracted file, so nested archives and filesystems are unpacked too. Everything lands in _firmware.bin.extracted/. To carve even unrecognized regions, use binwalk --dd='.*' firmware.bin.

Where does Binwalk put the extracted files?

In a folder named _firmware.bin.extracted/ in the directory you ran Binwalk from, with one subfolder per extracted match named after its offset. Change the location with -C, for example binwalk -C ./out -e firmware.bin.

What is the difference between Binwalk v2 and v3?

Binwalk v2 is the Python original (v2.4.3 on Kali) and reaches end of life on 12 December 2025; Binwalk v3 is a Rust rewrite with different flags — for example v3 uses -c to carve and -l for JSON logs, while v2 uses -z, --dd, and -f. On Kali, v3 installs as the separate binwalk3 command. Check which you have with binwalk -h (v2) or binwalk3 --version (v3).

Can I use Binwalk on Windows?

Yes, in WSL — install Kali or Ubuntu in WSL and use the Linux commands in this guide. A native Windows build exists, but extraction needs Developer Mode or an administrator shell and many formats need helper programs that are not bundled, so WSL is the reliable route.

Why does Binwalk find no signatures?

Three usual causes: the file is encrypted or compressed as a whole, so no magic bytes are visible; the format is outside Binwalk's signature database; or the scan stopped early. Run binwalk -E firmware.bin and read the entropy curve — a flat line near 1 means encrypted — then try binwalk -X and binwalk -Z for raw deflate and LZMA streams, and verify the file with file firmware.bin first.

How do I use Binwalk to find hidden files in images?

Run a plain scan: binwalk image.png lists every signature and offset — a PNG with a ZIP appended to it shows PNG image at offset 0 and a ZIP archive where the image ends. Then binwalk -e image.png unpacks the hidden archive into _image.png.extracted/. The same trick finds files hidden in firmware, documents, and disk images, which is why Binwalk is a staple in CTF competitions.

How do I update Binwalk in Kali Linux?

Update the Kali package with sudo apt update && sudo apt install --only-upgrade binwalk -y, then check the version with binwalk -h. For the newest release, install Binwalk v3 from its GitHub repository — on Kali it installs as the separate binwalk3 command.

Tags

#forensics#firmware#analysis

Output Explanation

Binwalk prints a three-column table: DECIMAL is the byte offset where a signature starts, HEXADECIMAL is the same offset in hex, and DESCRIPTION names the format Binwalk recognized there. Read the table top to bottom as a map of the file: a uImage header at offset 0 describes the boot image and its size, an LZMA compressed data row marks the compressed kernel, and a SquashFS filesystem, little endian, version 4.0 row is the root filesystem you will extract. Offsets matter — they are the byte positions you feed to dd when you carve a region by hand, and the _firmware.bin.extracted/ folder names each extracted piece after its offset. A row that says gzip compressed data with a size tells you a compressed blob lives there; a missing row where you expected a filesystem usually means the image is encrypted, vendor-modified, or uses a format outside the signature database. The closing line, Analyzed 1 file for ... signatures, confirms the scan completed; if it never appears, the scan was interrupted. After extraction, the same table is your checklist: every row should map to a file in the extraction folder, and any row with no extracted file points at a missing helper program.

Ethical Usage Notice

This tool is designed for authorized security testing, educational purposes, and legitimate network administration only. Unauthorized access to computer systems is illegal.