SecurityRonin/blazehash
GitHub: SecurityRonin/blazehash
面向数字取证的现代化文件哈希工具,完全兼容 hashdeep,以 BLAKE3 为默认算法,提供多线程加速、审计模式和 DFXML/JSON 等多种导出格式。
Stars: 0 | Forks: 0
# blazehash
[](https://crates.io/crates/blazehash)
[](LICENSE)
[](https://github.com/SecurityRonin/blazehash/actions/workflows/ci.yml)
[](https://github.com/SecurityRonin/blazehash/releases)
[](https://github.com/sponsors/h4x0r)
现代时代的 hashdeep。默认使用 BLAKE3。多线程。内存映射。与每一个 hashdeep 标志完全兼容,并新增了更多功能。在相同算法上比 hashdeep [**快达 3.4 倍**](docs/benchmarks.md) —— 切换到 BLAKE3 时则 [**快约 5 倍**](docs/benchmarks.md#the-blake3-advantage)。
将其指向一个案例目录。几秒钟内即可获得加密验证的清单,而不是几小时。
```
blazehash -r /mnt/evidence -c blake3,sha-256 -o results.hash
```
```
blazehash v0.1.0 — BLAKE3 + SHA-256, 16 threads, mmap I/O
[*] Scanning /mnt/evidence recursively
[+] 847,293 files hashed (2.14 TiB) in 38.7s
[+] Throughput: 56.6 GiB/s (BLAKE3) · 4.2 GiB/s (SHA-256)
[+] Manifest written to results.hash
```
## 为什么开发这个工具
[hashdeep](https://github.com/jessek/hashdeep) 是数字取证中最重要的工具之一。由 [Jesse Kornblum](https://github.com/jessek) 和 [Simson Garfinkel](https://simson.net/) 编写,它为取证社区提供了一种可靠、可审计的方式来对文件进行哈希处理并验证证据的完整性。其审计模式、递归哈希和已知哈希匹配树立了每个取证实验室所依赖的标准。hashdeep 是美国政府的工作成果,自诞生以来一直免费向社区提供。
我们要感谢 Jesse。hashdeep 解决了一个真实的问题,并且解决得很好。
但是 hashdeep 是在机械硬盘、单核 CPU 和 MD5 作为默认算法的时代编写的。世界已经向前发展。证据量从 GB 级增长到了 TB 级。NVMe 驱动器可以达到 7 GB/s 的速度。CPU 配备了 16 个以上的核心。NIST 废弃了 SHA-1。而 BLAKE3 —— 从底层开始为并行性和硬件加速设计 —— 可以以内存带宽的速度进行哈希。
hashdeep 自 v4.4 以来就没有发布过新版本。它不支持 BLAKE3。它不使用多核。它不进行内存映射文件。它无法恢复中断的运行。它无法导出为 DFXML 或 JSON。
**blazehash** 旨在将 hashdeep 带入现代。每一个 hashdeep 标志都按您的预期工作。输出格式是兼容的。您现有的脚本、审计工作流程、经过法庭验证的程序 —— 它们都可以继续工作。我们只是让它们更快,添加社区需要的算法,并填补 hashdeep 从未实现的功能空白。
这不是一个替代品。这是一个延续。
## 性能
在 Apple M4 Pro(14 核,48 GB RAM)上进行了基准测试。两个工具均在热缓存下运行。完整的方法和结果:**[docs/benchmarks.md](docs/benchmarks.md)**。
| Workload | blazehash | hashdeep v4.4 | Speedup |
|----------|----------:|----------:|--------:|
| 256 MiB file, SHA-256 | 854 ms | 930 ms | **1.09x** |
| 256 MiB file, SHA-1 | 275 ms | 572 ms | **2.08x** |
| 256 MiB file, 5 algos combined | 3.1 s | 3.5 s | **1.14x** |
| 1000 small files, SHA-256 | 20 ms | 69 ms | **3.43x** |
| Recursive walk (500 files) | 27 ms | 45 ms | **1.68x** |
| Piecewise (64 MiB, 1M chunks) | 163 ms | 339 ms | **2.08x** |
| **256 MiB file, BLAKE3** | **187 ms** | *not supported* | **~5x vs hashdeep SHA-256** |
**BLAKE3 达到 1.37 GB/s** 是 blazehash 的默认设置 —— 在 hashdeep 中不可用。对于从 `hashdeep -c sha256` 切换过来的从业者:预计端到端速度提升近 **5 倍**(更快的算法 + 更快的实现)。
对于共享算法(MD5, SHA-1, SHA-256, Tiger, Whirlpool),所有哈希值与 hashdeep 逐位相同。[已通过自动化跨工具测试验证](docs/benchmarks.md#correctness)。
## 安装
### Debian / Ubuntu / Kali
从 [GitHub Releases](https://github.com/SecurityRonin/blazehash/releases) 下载适合您架构的 `.deb` 包:
```
sudo apt install ./blazehash_*_amd64.deb # x86_64
sudo apt install ./blazehash_*_arm64.deb # ARM64
```
### macOS (Homebrew)
```
brew tap SecurityRonin/tap
brew install blazehash
```
### Windows
从 [GitHub Releases](https://github.com/SecurityRonin/blazehash/releases) 下载 `.msi` 安装程序。安装程序会自动将 `blazehash` 添加到您的系统 PATH 中。
### Cargo (所有平台)
```
cargo install blazehash
```
### 作为库使用
blazehash 也可作为 Rust 库使用,用于将哈希功能嵌入到您自己的工具中:
```
[dependencies]
blazehash = "0.1"
```
有关 API 文档,请参阅 [crates.io](https://crates.io/crates/blazehash)。
## 使用方法
blazehash 是 hashdeep 的**超集**。所有 hashdeep 标志均可使用,并新增了更多功能。
### 对目录进行哈希(BLAKE3,默认)
```
blazehash -r /mnt/evidence
```
### 多种算法
```
blazehash -r /mnt/evidence -c blake3,sha256,md5
```
### 审计模式(根据已知哈希进行验证)
```
blazehash -r /mnt/evidence -a -k known_hashes.txt
blazehash -r /mnt/evidence -a -k hashdeep_manifest.txt # hashdeep format
blazehash -r /mnt/evidence -a -k hashes.csv # CSV
blazehash -r /mnt/evidence -a -k hashes.json # JSON / JSONL
blazehash -r /mnt/evidence -a -k hashes.b3 # b3sum format
blazehash -r /mnt/evidence -a -k hashes.sha256 # sha256sum format
```
接受 blazehash 可以导出的任何格式的已知哈希文件:hashdeep, CSV, JSON, JSONL, b3sum 和 sha256sum。审计报告与 hashdeep 输出完全匹配:匹配的文件、不匹配的文件、移动的文件、新增的文件。
### 导出格式
```
blazehash -r /mnt/evidence --format hashdeep # default, hashdeep-compatible
blazehash -r /mnt/evidence --format dfxml # Digital Forensics XML
blazehash -r /mnt/evidence --format csv # CSV with headers
blazehash -r /mnt/evidence --format json # JSON array
blazehash -r /mnt/evidence --format jsonl # one JSON object per line
```
### 导入 NSRL
```
blazehash -r /mnt/evidence --import-nsrl /path/to/NSRLFile.txt -a
```
在审计期间使用 NIST 的 [National Software Reference Library](https://www.nist.gov/itl/ssd/software-quality-group/national-software-reference-library-nsrl) 过滤已知良好的文件。
### 恢复中断的运行
```
blazehash -r /mnt/evidence -o manifest.hash --resume
```
从中断的地方继续。读取部分清单,跳过已哈希的文件,从下一个文件继续。
### 分段 / 块哈希
```
blazehash -r /mnt/evidence -p 1G # hash in 1 GiB chunks
```
分段哈希(hashdeep 的 `-p` 标志)。每个文件生成多个哈希条目,每个块一个。用于验证部分传输或检测大文件内的针对性修改。
### 仅大小模式(快速预扫描)
```
blazehash -r /mnt/evidence -s # list files with sizes, no hashing
```
## 算法
| Algorithm | Flag | Default | Apple Silicon (M4) | x86_64 | Quantum Resilient | Notes |
|-----------|------|---------|-------------------|--------|-------------------|-------|
| BLAKE3 | `blake3` | **Y** | NEON, internal tree parallelism | AVX-512, AVX2, SSE4.1 | Pre-quantum | 4x faster than SHA-256, designed for parallelism |
| SHA-256 | `sha256` | -- | ARM SHA2 extensions (`sha256h/h2/su0/su1`) | SHA-NI | Pre-quantum | NIST standard, court-accepted everywhere |
| SHA-3-256 | `sha3-256` | -- | NEON Keccak-f[1600] | AVX2 lane-parallel | Post-quantum candidate basis | Keccak sponge, different construction from SHA-2 |
| SHA-512 | `sha512` | -- | Native 64-bit, NEON 2x interleave | AVX2 | Pre-quantum | Faster than SHA-256 on 64-bit CPUs |
| SHA-1 | `sha1` | -- | ARM SHA1 extensions (`sha1c/p/m/h/su0/su1`) | SHA-NI | Broken | Legacy only, collision attacks published (SHAttered, 2017) |
| MD5 | `md5` | -- | NEON vectorized | SSE2/AVX2 multi-buffer | Broken | Legacy only, collision attacks trivial since 2004 |
| Tiger | `tiger` | -- | 64-bit optimized lookup tables | 64-bit optimized | Pre-quantum | hashdeep compatibility, 192-bit output |
| Whirlpool | `whirlpool` | -- | Table-based, 64-bit native | Table-based, 64-bit native | Pre-quantum | hashdeep compatibility, 512-bit output |
BLAKE3 是默认选择,因为它是现代硬件上最快的加密哈希,同时保持 256 位的安全级别。对于对方律师可能质疑算法选择的法庭提交,`sha256` 仍然是稳妥的选择。
## 为什么它很快
| Technique | What it does |
|-----------|-------------|
| BLAKE3 default | Hash function designed for parallelism — internally splits each file into 1 KiB chunks and hashes them across a Merkle tree |
| Memory-mapped I/O | Lets the OS page in file data directly, bypassing userspace read buffers. Eliminates a `memcpy` per read call |
| Multithreaded file walking | Directory traversal and hashing run on a thread pool (defaults to all cores). Large files are parallelized internally by BLAKE3; many small files are parallelized across threads |
| Streaming architecture | Files are hashed as they stream in. No file is ever fully loaded into memory, regardless of size |
| Hardware intrinsics | BLAKE3 uses AVX-512/AVX2/SSE4.1 on x86 and NEON on ARM. SHA-256 uses SHA-NI where available |
## 功能对比
blazehash 与 hashdeep, b3sum, sha256sum 以及其他取证哈希工具的对比。
### 算法
| Feature | blazehash | hashdeep | b3sum | sha256sum | md5deep |
|---------|:---------:|:--------:|:-----:|:---------:|:-------:|
| BLAKE3 | **Y** | -- | **Y** | -- | -- |
| SHA-256 | **Y** | **Y** | -- | **Y** | -- |
| SHA-3-256 | **Y** | -- | -- | -- | -- |
| SHA-512 | **Y** | **Y** | -- | -- | -- |
| SHA-1 | **Y** | **Y** | -- | -- | -- |
| MD5 | **Y** | **Y** | -- | -- | **Y** |
| Tiger | **Y** | **Y** | -- | -- | -- |
| Whirlpool | **Y** | **Y** | -- | -- | -- |
| Multiple simultaneous | **Y** | **Y** | -- | -- | -- |
### 性能
| Feature | blazehash | hashdeep | b3sum | sha256sum | md5deep |
|---------|:---------:|:--------:|:-----:|:---------:|:-------:|
| Multithreaded hashing | **Y** | -- | **Y** | -- | -- |
| Memory-mapped I/O | **Y** | -- | **Y** | -- | -- |
| SIMD / HW acceleration | **Y** | -- | **Y** | -- | -- |
| Parallel file walking | **Y** | -- | -- | -- | -- |
### 取证功能
| Feature | blazehash | hashdeep | b3sum | sha256sum | md5deep |
|---------|:---------:|:--------:|:-----:|:---------:|:-------:|
| Audit mode | **Y** | **Y** | -- | `-c` flag | -- |
| Piecewise hashing | **Y** | **Y** | -- | -- | -- |
| NSRL import | **Y** | -- | -- | -- | -- |
| Resume interrupted | **Y** | -- | -- | -- | -- |
| Known-hash matching | **Y** | **Y** | -- | -- | **Y** |
| Recursive hashing | **Y** | **Y** | -- | -- | **Y** |
### 输出格式
| Feature | blazehash | hashdeep | b3sum | sha256sum | md5deep |
|---------|:---------:|:--------:|:-----:|:---------:|:-------:|
| hashdeep format | **Y** | **Y** | -- | -- | -- |
| DFXML | **Y** | -- | -- | -- | -- |
| CSV | **Y** | -- | -- | -- | -- |
| JSON / JSONL | **Y** | -- | -- | -- | -- |
| b3sum format | **Y** | -- | **Y** | -- | -- |
| sha256sum format | **Y** | -- | -- | **Y** | -- |
### 平台与实现
| | blazehash | hashdeep | b3sum | sha256sum | md5deep |
|---------|:---------:|:--------:|:-----:|:---------:|:-------:|
| Cross-platform | **Y** | **Y** | **Y** | **Y** | **Y** |
| Language | Rust | C++ | Rust | C (coreutils) | C++ |
| Maintained (2025+) | **Y** | -- (v4.4, 2014) | **** | **Y** | -- |
| Static Linux binary | **Y** | -- | **Y** | -- | -- |
## 参考
- [hashdeep](https://github.com/jessek/hashdeep) (Jesse Kornblum & Simson Garfinkel, forensic hashing and audit)
- [BLAKE3](https://github.com/BLAKE3-team/BLAKE3) (Jack O'Connor, Samuel Neves, Jean-Philippe Aumasson, Zooko Wilcox-O'Hearn)
- [NIST NSRL](https://www.nist.gov/itl/ssd/software-quality-group/national-software-reference-library-nsrl) (National Software Reference Library)
- [DFXML](https://github.com/simsong/dfxml) (Simson Garfinkel, Digital Forensics XML)
- [SHAttered](https://shattered.io/) (SHA-1 collision, Stevens et al., 2017)
## 致谢
这个项目的存在归功于 [Jesse Kornblum](https://github.com/jessek)。
Jesse 在为美国政府工作期间创建了 [hashdeep](https://github.com/jessek/hashdeep)(及其前身 md5deep),并将其作为公共领域工具赠予取证社区。十多年来,hashdeep 一直是全球取证实验室、执法机构和法庭进行证据哈希和完整性验证的首选工具。其审计模式 —— 验证一组文件与已知良好清单的能力,并报告匹配、移动、更改和新增的内容 —— 仍然是取证工具中最优雅的设计之一。
[Simson Garfinkel](https://simson.net/) 是 hashdeep 的合著者,并创建了 [DFXML](https://github.com/simsong/dfxml),即 blazehash 作为导出选项支持的数字取证 XML 格式。
[BLAKE3 团队](https://github.com/BLAKE3-team/BLAKE3) —— Jack O'Connor, Samuel Neves, Jean-Philippe Aumasson, 和 Zooko Wilcox-O'Hearn —— 设计了一种既快又正确的哈希函数。BLAKE3 的内部并行性和树哈希结构是 blazehash 能够在单个文件上饱和 NVMe 带宽的原因。
blazehash 并不声称要取代 hashdeep。它是在延续其火炬。
## 作者
**Albert Hui** ([@h4x0r](https://github.com/h4x0r)) 来自 [@SecurityRonin](https://github.com/SecurityRonin)
数字取证从业者和工具开发者。构建开源 DFIR 工具以填补商业软件留下的空白。
## 许可证
根据 [MIT License](LICENSE) 授权。
标签:BLAKE3, Hashdeep, Rust, SHA-256, 内存映射, 取证工具, 可视化界面, 哈希比对, 哈希计算, 数字取证, 数据完整性验证, 数据校验, 文件完整性, 网络流量审计, 自动化脚本, 证据固定, 通知系统, 高性能计算