Forensics
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.
sudo apt update && sudo apt install binwalk -y
binwalk [options] <file>
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.
| Command | Purpose |
|---|---|
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 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.Scan firmware images to identify embedded filesystems, kernels, and configuration files for security auditing.
Extract firmware from IoT devices to find hardcoded credentials, vulnerable services, and backdoors.
Map the internal structure of compiled binaries to understand data organization and embedded components.
Identify encrypted or compressed sections within firmware to assess reverse engineering difficulty.
Extract embedded filesystems, bootloaders, and data partitions from monolithic firmware images.
Find files hidden inside images and binaries — a PNG with an appended ZIP is a classic CTF hiding spot.
Diff two firmware releases with -W to see what the vendor changed, added, or removed.
Pull embedded payloads, droppers, and second stages out of a suspicious binary for safe offline analysis.
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.
Hardware Hacking
Arduino IDE and tools for programming microcontrollers used in hardware hacking, BadUSB attacks, and IoT testing.
Forensics
ExifTool is a platform-independent tool for reading, writing, and editing metadata in a wide variety of files including images, audio, and video.
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.
Forensics
Foremost is a forensic data recovery program that recovers files based on their headers, footers, and internal data structures.
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.
Learn digital forensics fundamentals including evidence collection, forensic imaging, memory analysis, timeline analysis, and proper chain of custody procedures for investigations.
Security Operations · IntermediateLearn 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 · BeginnerLearn 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 · BeginnerLearn 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.
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.
This tool is designed for authorized security testing, educational purposes, and legitimate network administration only. Unauthorized access to computer systems is illegal.