How refirmlabs/binwalk works
Project type and purpose
• This is a command-line firmware analysis tool and Rust library (Binwalk v3).
• It reads binary firmware files, identifies embedded file/data signatures, optionally extracts them, and can perform entropy analysis.
• It also provides a core Rust API for integration and supports fuzzing and Docker-based builds.
File structure
• Top-level binaries and scripts:
• Cargo.toml, src/main.rs: primary CLI binary (“binwalk”)
• src/lib.rs: core library exposing scan and extract functions
• scripts/binwalk-ui: optional UI wrapper
• fuzzing/: separate fuzzing harness to test core library
• dependencies/: scripts and manifests to install prerequisites (Python, Ubuntu, pip)
• Dockerfile and build_docker.sh: containerized build/deploy
• Core code modules under src/:
• cliparser.rs: parse CLI args into configuration
• common.rs: shared utilities and types
• .rs, json.rs: output formatting (terminal vs JSON)
• entropy.rs: entropy-analysis routines
• magic.rs, signatures/: signature definitions and detection logic
• extractors/: logic to extract each file/data type
• structures/: parse file-specific internal structures
• binwalk.rs: orchestrator that ties parsing, scanning, extraction, output
• Tests under tests/: unit tests covering signatures and extractors against sample inputs.
README for additional insights
• Confirms primary focus (firmware analysis), key features (signature scanning, extraction, entropy graphs).
• Mentions library integration and Docker builds.
Detailed breakdown recommendation
• Layer 1 (top): User CLI and UI
• Layer 2 (core):
• Arg Parser → Controller
• Controller branches into Scanner, Parsers, Entropy, Extractors
• Output Formatter
• Side modules:
• Test Suite → calls core API
• Fuzzing Harness → calls core API
• Bottom: Build/Deploy
• Docker build → produces binwalk binary