pablo7843/CRACK
GitHub: pablo7843/CRACK
面向教育场景的密码哈希破解工具,通过字典攻击、暴力破解和撞库演示帮助用户理解哈希算法安全性与密码防御策略。
Stars: 0 | Forks: 0
# CRACK — 密码哈希破解器
```
+--------------------------------------------------+
| ____ ____ _ ____ _ __ |
| / ___|| _ \ / \ / ___|| |/ / |
| | | | |_) | / _ \ | | | ' / |
| | |___ | _ < / ___ \ | |___ | . \ |
| \____||_| \_\/_/ \_\ \____||_|\_\ |
| |
| >> Password Hash Cracker v1.0 << |
| >> Dictionary | BruteForce | Stuffing << |
+--------------------------------------------------+
```
## 功能
| 功能 | 描述 |
|---------|-------------|
| **字典攻击** | 使用字典条目对哈希进行测试,支持可选的变异规则 |
| **暴力破解** | 通过可配置的字符集和长度进行穷举式的字符空间枚举 |
| **变异规则** | leet speak、大小写转换、数字后缀、前缀、重复、反转 |
| **自动哈希检测** | 通过特征自动识别 MD5、SHA-1、SHA-256、SHA-512、bcrypt |
| **批量破解** | 一次性破解文件中的多个哈希 |
| **交互模式** | 方向键引导菜单 —— 无需任何命令行参数 |
| **哈希生成器** | 从任意明文密码生成哈希 |
| **Hashcat 命令** | 为任意哈希获取 GPU 加速的等效命令 |
| **Keyspace 估算器** | 在运行暴力破解前计算候选数量和预计时间 |
| **撞库演示** | 模拟真实世界的密码重用攻击及防御策略 |
| **算法信息表** | MD5、SHA-1、SHA-256、SHA-512、bcrypt、Argon2id 的安全性概述 |
| **中英双语** | 完整的国际化支持 —— 自动检测系统语言环境,可通过 `--lang` 覆盖 |
## 支持的算法
| 算法 | 位数 | 已破解? | Hashcat 模式 | 备注 |
|-----------|------|---------|--------------|-------|
| MD5 | 128 | 是 | 0 | 自 2004 年起被完全破解。GPU 上破解速度约 500 亿次/秒 |
| SHA-1 | 160 | 是 | 100 | 2017 年发生 SHAttered 攻击。已被 NIST 废弃 |
| SHA-256 | 256 | 否 | 1400 | 安全但不含 salt —— 容易受到彩虹表攻击 |
| SHA-512 | 512 | 否 | 1700 | 更强但依然没有内置 salt |
| bcrypt | 184 | 否 | 3200 | 内置 salt + 工作因子。推荐用于密码 |
| Argon2id | 256 | 否 | 13400 | 2015 年 PHC 优胜者。内存密集型。当前的最佳实践 |
## 安装
```
# Clone repo
git clone https://github.com/YOURUSERNAME/crack-pwssd-hashes.git
cd crack-pwssd-hashes
# 安装依赖
pip install -r requirements.txt
```
**环境要求:** Python 3.10+ · `rich` · `bcrypt` · `questionary`
## 用法
### 交互模式(推荐初学者使用)
```
python crack.py
```
启动包含所有功能的引导式方向键菜单:
```
What do you want to do?
> Crack a single hash
Crack a hash file (multiple hashes)
─────────────────────────────────
Generate hashes from a password
Show hashcat commands for a hash
Keyspace estimator (brute force)
─────────────────────────────────
Credential stuffing demo
View algorithm info table
─────────────────────────────────
Change language
Exit
```
### CLI 模式(适用于脚本和高级用户)
#### 破解单个哈希
```
# 自动检测 algorithm
python crack.py --hash 5f4dcc3b5aa765d61d8327deb882cf99 --algo auto --attack dict
# 指定 algorithm
python crack.py --hash 5f4dcc3b5aa765d61d8327deb882cf99 --algo MD5 --attack dict
# 使用 mutation rules(功能更强大)
python crack.py --hash --algo MD5 --attack dict --rules best
```
#### 变异规则
| 规则 | 作用 |
|------|-------------|
| `leet` | a→4, e→3, i→1, o→0, s→5, t→7 |
| `caps` | 首字母大写、全大写、全小写变体 |
| `suffix` | 追加后缀:1, 12, 123, 1234, !, !!, 2024, 2025... |
| `prefix` | 添加前缀:1, 123, the, my... |
| `dup` | 单词重复:passwordpassword |
| `rev` | 反转:drowssap |
| `best` | caps + suffix + leet(推荐) |
| `all` | 组合所有规则 |
```
python crack.py --hash --algo MD5 --attack dict --rules best
python crack.py --hash --algo MD5 --attack dict --rules all
```
#### 暴力破解
```
# 仅数字,最多 6 个字符
python crack.py --hash --algo MD5 --attack brute --charset digits --max-len 6
# 小写字母,1-4 个字符
python crack.py --hash --algo MD5 --attack brute --charset lower --max-len 4
# 字母数字,1-5 个字符
python crack.py --hash --algo MD5 --attack brute --charset alphanum --max-len 5
```
可用字符集:
| 字符集 | 字符 |
|---------|-----------|
| `digits` | 0-9 |
| `lower` | a-z |
| `upper` | A-Z |
| `alpha` | a-z + A-Z |
| `alphanum` | a-z + A-Z + 0-9 |
| `hex` | 0-9 + a-f |
| `special` | 标点符号 |
| `full` | 上述所有字符 |
#### 批量破解(哈希文件)
```
python crack.py --hash-file hashes/samples.txt --algo MD5 --attack dict
```
哈希文件格式 —— 每行一个哈希,`#` 用于注释:
```
# 我的测试 hashes
5f4dcc3b5aa765d61d8327deb882cf99
e10adc3949ba59abbe56e057f20f883e
```
#### 显示 Hashcat 命令 (GPU)
```
python crack.py --hash --algo MD5 --hashcat
```
#### 算法信息表
```
python crack.py --info
```
#### 撞库演示
```
python crack.py --demo stuffing
```
#### 生成测试用的哈希
```
# 所有 algorithms
python generate_hash.py "mypassword"
# 特定 algorithm
python generate_hash.py "mypassword" --algo sha256
python generate_hash.py "mypassword" --algo bcrypt --rounds 10
# 保存到文件(供 --hash-file 使用)
python generate_hash.py "mypassword" --save hashes/my_hashes.txt
```
### 语言
```
# 西班牙语
python crack.py --lang es --hash --algo auto --attack dict
# 英语
python crack.py --lang en --hash --algo auto --attack dict
# 从系统 locale 自动检测(默认)
python crack.py --hash --algo auto --attack dict
# 通过环境变量强制使用西班牙语
$env:LANG = "es_ES"
python crack.py
```
### 其他参数
| 参数 | 描述 |
|------|-------------|
| `--quiet` | 隐藏进度输出 |
| `--keyspace` | 在暴力破解前显示 keyspace 大小 |
| `--wordlist PATH` | 使用自定义字典(例如 rockyou.txt) |
| `--min-len N` | 暴力破解的最小长度(默认:1) |
| `--max-len N` | 暴力破解的最大长度(默认:6) |
## 典型 CTF 工作流
```
# 1. 未知 hash — 自动检测并尝试 wordlist
python crack.py --hash d8578edf8458ce06fbc5bb76a58c5ca4 --algo auto --attack dict
# 2. 不在 wordlist 中 — 添加 mutations
python crack.py --hash --algo MD5 --attack dict --rules best
# 3. 仍然没有结果 — 短期 brute force
python crack.py --hash --algo MD5 --attack brute --charset alphanum --max-len 5
# 4. 需要 GPU 算力 — 获取 hashcat 命令
python crack.py --hash --algo MD5 --hashcat
```
如需进行 GPU 破解,请下载 [hashcat](https://hashcat.net) 和 [rockyou.txt](https://github.com/brannondorsey/naive-hashcat/releases/download/data/rockyou.txt)。
## 项目结构
```
crack-pwssd-hashes/
│
├── crack.py # Main CLI entry point
├── generate_hash.py # Hash generator utility
├── requirements.txt
│
├── hashers/
│ ├── identifier.py # Auto-detect hash type by regex pattern
│ └── algorithms.py # compute(), verify_bcrypt(), ALGO_INFO
│
├── attacks/
│ ├── dictionary.py # Wordlist-based attack engine
│ ├── brute_force.py # Exhaustive enumeration (itertools.product)
│ ├── rules.py # Password mutation rules
│ └── credential_stuffing.py # Stuffing simulation + DEFENSE_STRATEGIES
│
├── utils/
│ ├── display.py # Rich-based UI (tables, panels, progress)
│ ├── lang.py # i18n — all EN/ES strings + t() + detect_lang()
│ └── interactive.py # Guided interactive mode (questionary)
│
├── wordlists/
│ └── common.txt # ~100 most common passwords (sample)
│
└── hashes/
└── samples.txt # Verified test hashes (answers in common.txt)
```
## 你将学到什么
- **为什么 MD5 和 SHA-1 已被破解** —— 碰撞攻击、GPU 破解速度
- **为什么原始的 SHA-256/SHA-512 用于密码不安全** —— 无 salt、彩虹表漏洞
- **bcrypt/Argon2 如何防御 GPU 攻击** —— 工作因子、内置 salt
- **字典攻击机制** —— 字典、变异规则,以及为什么 "p@ssw0rd" 不安全
- **暴力破解复杂度** —— keyspace 大小,为什么密码长度比复杂度更重要
- **撞库** —— 跨服务的密码重用如何使攻击成为可能
- **防御策略** —— MFA、速率限制、HaveIBeenPwned、设备指纹识别
## 免责声明
本工具**仅供**以下用途:
- CTF(Capture The Flag)竞赛
- 学术网络安全课程作业
- 测试您自己的系统
- 学习密码安全概念
**严禁将此工具用于您不拥有或未获得明确书面授权进行测试的任何账户、系统或哈希。** 在大多数司法管辖区,未经授权的访问都是非法的。
标签:CTF工具, DOS头擦除, PoC, SysWhispers, VEH, 字典攻击, 密码破解, 暴力破解, 漏洞搜索, 用户模式钩子绕过, 逆向工具