# Hashcat

**Hashcat** 是一款开源密码恢复工具，以 MIT 许可证发布，利用现代显卡或其他计算设备的处理器，将候选密码与密码哈希进行比对测试。其官方文档自称“世界上最快、最先进的密码恢复工具”，通过单个命令行程序支持数百种哈希格式。<sup>[1](https://hashcat.net/wiki/?id=hashcat)</sup> 在安全审计和数字取证领域，它是 GPU 加速离线哈希测试的标准工具；而其长期以来的同类工具 [John the Ripper](https://www.edgepedia.org/zh/john-the-ripper) 则在哈希提取和灵活的单词变形规则方面更受青睐。<sup>[2](https://cybersnowden.com/john-the-ripper-vs-hashcat/)</sup>

| 关键事实 | 详情 |
|---|---|
| 许可证与当前版本 | 以 MIT 许可证开源；当前版本 7.1.2<sup>[1](https://hashcat.net/wiki/?id=hashcat)</sup> |
| 计算后端 | NVIDIA 上使用 CUDA，AMD 上使用 HIP，Apple 上使用 Metal，OpenCL 作为通用回退（包括在 CPU 上）<sup>[3](https://hashcat.net/wiki/doku.php?id=frequently_asked_questions)</sup> |
| 哈希模式 | 7.1.2 版共有 582 种哈希模式<sup>[3](https://hashcat.net/wiki/doku.php?id=frequently_asked_questions)</sup> |
| 密码长度限制 | 默认纯内核为 256 字节；使用 `-O` 启用的优化内核为 55 字节<sup>[3](https://hashcat.net/wiki/doku.php?id=frequently_asked_questions)</sup> |
| 首次发布 | v0.30，2009 年 12 月 24 日，由延斯·"atom"·施托伊贝（Jens "atom" Steube）和加布里埃莱·"matrix"·格里斯蒂纳（Gabriele "matrix" Gristina）发布<sup>[4](https://keerthana200219.wixstudio.com/passwordcrackers/research-and-technology)</sup> |
| 适用范围 | 仅适用于离线存储的密码哈希；无法恢复 Google 或 Facebook 等在线账户<sup>[3](https://hashcat.net/wiki/doku.php?id=frequently_asked_questions)</sup> |
| 实测速度（RTX 5090） | MD5 上 219.5 GH/s，NTLM 上 340.1 GH/s，bcrypt 上 304.8 kH/s，SHA-256 上 27681.6 MH/s<sup>[5](https://www.tomshardware.com/pc-components/gpus/tests-show-usd30-000-ai-gpus-are-terrible-password-crackers-h200-and-mi300x-outperformed-by-rtx-5090)</sup> |

## 功能

Hashcat 从哈希中恢复密码。密码哈希是密码哈希方案经加盐和成本因子处理后的输出，NIST 的数字身份指南要求验证方以这种确切形式存储密码，盐至少 32 位，且成本因子随时间提高，从而使攻击者在获取哈希文件后所做的每一次猜测都代价高昂。<sup>[6](https://pages.nist.gov/800-63-4/sp800-63b/authenticators/)</sup> Hashcat 就是大规模执行这些猜测的工具：它接收一个哈希或哈希文件，外加字典、掩码或候选目录，并针对选定的哈希类型进行测试。<sup>[1](https://hashcat.net/wiki/?id=hashcat)</sup>

该工具的常见问题解答对适用范围有明确说明：hashcat 不能用于恢复在线账户，即使获得账户所有者许可也不行，因为它只对离线存储的密码哈希进行操作。<sup>[3](https://hashcat.net/wiki/doku.php?id=frequently_asked_questions)</sup> 合法用途包括密码审计——在攻击者之前发现弱密码选择——以及调查过程中对受保护内容的取证恢复。<sup>[2](https://cybersnowden.com/john-the-ripper-vs-hashcat/)</sup>

## 攻击模式与用法

Hashcat 的命令行用 `-m` 选择哈希类型，用 `-a` 选择攻击模式。文档记载的模式包括直接字典攻击（`-a 0`）、组合攻击（`-a 1`）、掩码暴力破解（`-a 3`）和关联攻击（`-a 9`）；例如，对六字符掩码进行 MD5 暴力破解的命令是 `hashcat -a 3 -m 0 example0.hash ?a?a?a?a?a?a`。<sup>[1](https://hashcat.net/wiki/?id=hashcat)</sup> `best64.rule` 等规则文件会对字典单词进行变形，位置参数有固定顺序：先是哈希或哈希文件，然后是词表或掩码。<sup>[3](https://hashcat.net/wiki/doku.php?id=frequently_asked_questions)</sup>

当候选密码通过管道传入 hashcat 时，它运行字典攻击，并可在候选到达设备之前由主机 CPU 将其拒绝，提前过滤掉违反长度限制的候选。<sup>[3](https://hashcat.net/wiki/doku.php?id=frequently_asked_questions)</sup>

## 硬件后端

单个 hashcat 程序通过四种计算后端覆盖 CPU 和 GPU：在支持的 NVIDIA 设备上使用 CUDA，在支持的 AMD 设备上使用 HIP，在 Apple 设备上使用 [Metal](https://www.edgepedia.org/zh/metal-api)，在一切具有兼容运行时的设备上使用 OpenCL，包括作为回退的 CPU。<sup>[3](https://hashcat.net/wiki/doku.php?id=frequently_asked_questions)</sup> 每种后端都有安装要求：NVIDIA 驱动加 CUDA Toolkit；AMD Linux 上用 ROCm，Windows 上用 AMD HIP SDK；Intel GPU 用 Intel Graphics Compute Runtime（NEO）；macOS 上无需额外安装。<sup>[3](https://hashcat.net/wiki/doku.php?id=frequently_asked_questions)</sup>

CPU 设备默认被禁用，因为繁忙的 CPU 会拖慢 GPU 同步；可用 `-D 1` 启用，或用 `-D 1,2` 同时启用两种设备类型。例外是完全没有任何 OpenCL GPU 的机器，此时 hashcat 会自动启用 CPU。<sup>[3](https://hashcat.net/wiki/doku.php?id=frequently_asked_questions)</sup> 7.1.2 版在旧运行时上对不同厂商区别对待：NVIDIA CUDA 驱动低于 9.0 会直接终止，而 Linux 上 AMD HIP 运行时低于 6.2.0 只会触发回退到 OpenCL。<sup>[3](https://hashcat.net/wiki/doku.php?id=frequently_asked_questions)</sup>

## 历史

Hashcat 由延斯·"atom"·施托伊贝和加布里埃莱·"matrix"·格里斯蒂纳开发，首个正式版本 v0.30 于 2009 年 12 月 24 日发布。<sup>[4](https://keerthana200219.wixstudio.com/passwordcrackers/research-and-technology)</sup> 多年来它以多个独立程序的形式存在：基于 CPU 的 hashcat，以及 GPU 加速的 oclHashcat、oclHashcat-plus 和 oclHashcat-lite。3.00 版将它们合并，变更日志开头写道：“本次发布标志着 hashcat 与 oclHashcat 融合为 hashcat”；旧的纯 CPU 程序以 hashcat-legacy 之名存续，但已退役。<sup>[3](https://hashcat.net/wiki/doku.php?id=frequently_asked_questions)</sup> 凡提及 oclHashcat 或其同系列程序的指南，都早于 3.00 版。<sup>[3](https://hashcat.net/wiki/doku.php?id=frequently_asked_questions)</sup>

开发仍在活跃进行。6.2.3 版为 AMD 设备增加了 HIP 后端，6.0.0 版引入了重构的后端架构，实现了原生 CUDA 支持，2025 年的 v7.0.0 版本历经两年多的开发，对若干关键组件进行了彻底重构。<sup>[7](https://hashcat.net/forum/showthread.php?mode=threaded&pid=49174&tid=9303)</sup><sup> • </sup><sup>[8](https://github.com/hashcat/hashcat/releases)</sup> 7.1.0 版增加了针对使用 Argon2i 密钥派生函数的 LUKS2、KeePass KDBX v4、BLAKE2b-256 变体和 MD6 等的哈希模式。<sup>[8](https://github.com/hashcat/hashcat/releases)</sup>

## 性能与硬件选择

[密码破解](https://www.edgepedia.org/zh/password-cracking)以 32 位整数运算为主，这决定了哪种硬件胜出。Specops 的一个研究团队使用 hashcat 在 Nvidia 的 H200、AMD 的 MI300X 和 Nvidia 的 RTX 5090 上对五种算法——MD5、NTLM、bcrypt、SHA-256 和 SHA-512——进行了基准测试。消费级的 RTX 5090 在每种算法上都击败了两款数据中心 AI GPU：平均而言，它比 MI300X 快 20%，比 H200 快 63.7%，在 SHA-512 上比 H200 最多快 93.5%。<sup>[5](https://www.tomshardware.com/pc-components/gpus/tests-show-usd30-000-ai-gpus-are-terrible-password-crackers-h200-and-mi300x-outperformed-by-rtx-5090)</sup>

原因在于架构。AI 加速器优先考虑机器学习所用的低精度指令，如 FP4、BF16、FP8 和 INT8；H200 的 INT32 核心数量只有 FP32 核心的一半，因为它的大部分工作由 Tensor 核心处理。MI300X 的 INT32 性能实际上高于 RTX 5090，但仍因 hashcat 代码中针对 Nvidia 的专门优化而落败。<sup>[5](https://www.tomshardware.com/pc-components/gpus/tests-show-usd30-000-ai-gpus-are-terrible-password-crackers-h200-and-mi300x-outperformed-by-rtx-5090)</sup>

算法选择与硬件同样重要。同一块 RTX 5090 在 MD5 和 NTLM 等快速无盐哈希上可达每秒数百千兆哈希，但在 bcrypt 上只有 304.8 kH/s，其刻意的成本因子将吞吐量降低了约六个数量级。<sup>[5](https://www.tomshardware.com/pc-components/gpus/tests-show-usd30-000-ai-gpus-are-terrible-password-crackers-h200-and-mi300x-outperformed-by-rtx-5090)</sup> 这正是 NIST 指南所依赖的机制：高成本因子使每次猜测都足够昂贵，从而使猜测攻击的成本变得高昂甚至难以承受。<sup>[6](https://pages.nist.gov/800-63-4/sp800-63b/authenticators/)</sup>

## Hashcat 与 John the Ripper

这两个工具是互补的，而非可互换的。各种比较一致认为，hashcat 是 GPU 加速恢复和大规模哈希测试的更好选择，而 John the Ripper 在识别哈希类型、处理复杂密码格式和应用复杂单词变形规则方面更为灵活。<sup>[2](https://cybersnowden.com/john-the-ripper-vs-hashcat/)</sup> 在实践中，通常正是 John 的 *2john 提取脚本让证据文件得以变成一行哈希，而实际的破解工作则因 GPU 吞吐量而在 hashcat 中进行。<sup>[9](https://www.legalcyberacademy.com/library/hashcat-and-john-the-ripper)</sup> 一位从业者描述的工作流程是：用 John 提取并破解文件格式哈希、攻击带用户名的转储，然后用 hashcat 将 GPU 算力用于原始哈希和 Wi-Fi 抓包。<sup>[10](https://techearl.com/hashcat-vs-john-the-ripper)</sup>

“hashcat 是 GPU 那个，John 是 CPU 那个”这种简单说法只是初步近似；hashcat 可以通过 OpenCL 在 CPU 上运行，John 也有 GPU 代码，不过 hashcat 在 GPU 上通常更快。<sup>[3](https://hashcat.net/wiki/doku.php?id=frequently_asked_questions)</sup><sup> • </sup><sup>[11](https://www.openwall.com/lists/john-users/2020/05/26/1)</sup>

## 适用范围与局限

少数模式受限于算法本身而非 hashcat：LM 哈希不能超过 7 个字符，descrypt 不能超过 8 个，这是哈希本身的属性而非工具的属性。<sup>[3](https://hashcat.net/wiki/doku.php?id=frequently_asked_questions)</sup>

该工具的速度上限由硬件决定，而下限低到足以成为奇谈。一位安全工程师将 hashcat 移植到 [Game Boy Advance](https://www.edgepedia.org/zh/game-boy-advance) 上，其 16.8 MHz 芯片每秒约能处理 727 个哈希，比现代 GPU 加速破解设备慢约三千万倍；据作者估计，在这台掌机上连续破解一年，约等于现代设备上的一秒钟。<sup>[12](https://www.tomshardware.com/video-games/nintendo/security-engineer-ports-password-cracker-hashcat-to-gameboy-advance-16-8-mhz-chip-can-perform-a-meager-727-hashes-a-second-30-million-times-slower-than-a-modern-rig)</sup>

## References

1. [hashcat, hashcat wiki](https://hashcat.net/wiki/?id=hashcat)
2. [John the Ripper vs Hashcat: Which Password Cracking Tool Is Better?, Cyber Snowden](https://cybersnowden.com/john-the-ripper-vs-hashcat/)
3. [Frequently Asked Questions, hashcat wiki](https://hashcat.net/wiki/doku.php?id=frequently_asked_questions)
4. [History of Hashcat, Password Crackers research site](https://keerthana200219.wixstudio.com/passwordcrackers/research-and-technology)
5. [Tests show $30,000 AI GPUs are terrible password crackers, Tom's Hardware (11 April 2026)](https://www.tomshardware.com/pc-components/gpus/tests-show-usd30-000-ai-gpus-are-terrible-password-crackers-h200-and-mi300x-outperformed-by-rtx-5090)
6. [Authenticators, NIST SP 800-63B-4](https://pages.nist.gov/800-63-4/sp800-63b/authenticators/)
7. [hashcat 6.0.0 release announcement, hashcat forum](https://hashcat.net/forum/showthread.php?mode=threaded&pid=49174&tid=9303)
8. [Releases, hashcat/hashcat, GitHub](https://github.com/hashcat/hashcat/releases)
9. [Hashcat and John the Ripper, Legal Cyber Academy](https://www.legalcyberacademy.com/library/hashcat-and-john-the-ripper)
10. [Hashcat vs John the Ripper: Which Should You Use?, TechEarl](https://techearl.com/hashcat-vs-john-the-ripper)
11. [hashcat vs. JtR, openwall john-users mailing list (2020)](https://www.openwall.com/lists/john-users/2020/05/26/1)
12. [Security engineer ports password cracker hashcat to Game Boy Advance, Tom's Hardware](https://www.tomshardware.com/video-games/nintendo/security-engineer-ports-password-cracker-hashcat-to-gameboy-advance-16-8-mhz-chip-can-perform-a-meager-727-hashes-a-second-30-million-times-slower-than-a-modern-rig)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Named software products and platforms › Security and penetration-testing tools

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/hashcat

English original: https://www.edgepedia.org/hashcat
