A fast, modern command-line tool for viewing file contents in hexadecimal and identifying file types using magic number signatures.
hex-dump is a C++ application for developers, reverse engineers, and digital forensics analysts who need a quick way to inspect file internals and determine a file's true type, regardless of its extension.
This tool serves two primary purposes: a hex viewer and a file type finder.
As a hex viewer, it provides a clean, formatted hexadecimal and ASCII representation of a file's contents.
As a file type finder, it reads a file's raw byte content and searches for known "magic number" signatures that identify its true type. For example, it can identify a PNG image even if it's been renamed with a .txt extension.
Efficiency is a core design goal. hex-dump uses memory-mapped I/O (mmap) to handle large files with minimal overhead and the Aho-Corasick algorithm to search for all known file signatures in a single, efficient pass.
- Dual Functionality: Acts as both a hex viewer and a file type finder.
- High-speed Scanning: Utilizes memory-mapped files to minimize I/O overhead.
- Efficient Multi-pattern Search: Employs the Aho-Corasick algorithm to find all known signatures in one pass.
- Cross-Platform: Built with standard C++ and CMake, targeting POSIX-compliant systems (Linux, macOS).
Follow these instructions to get a copy of the project up and running on your local machine.
- C++20 Compliant Compiler:
- GCC 10 or newer
- Clang 12 or newer
- CMake:
- Version 3.10 or newer
- Git
- Clone the repository
git clone https://github.com/your_username/hex-dump.git cd hex-dump - Create a build directory and configure
mkdir build && cd build cmake ..
- Compile the project
make
The compiled binary, hex-dump, will be located in the build directory.
Run the tool from the command line, passing the path of the file you wish to inspect as an argument.
./build/hex-dump /path/to/your/file.ext[+] Hexdump of the first 100 bytes:
00000000: 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 |.PNG........IHDR|
00000010: 00 00 01 f4 00 00 01 f4 08 06 00 00 00 1f 15 c4 |................|
...
[+] Matches found: 1
Offset: 0x0 | Pattern: 89 50 4e 47 0d 0a 1a 0a | File type: png