Kenasz/MarryTheHash
GitHub: Kenasz/MarryTheHash
一款专注于 CTF 场景的哈希识别与排名字典生成工具,帮助参赛者快速完成哈希格式判定、命令建议和字典构建。
Stars: 0 | Forks: 0
# MarryTheHash





```
__ __ _____ _ _ _ _
| \/ | __ _ _ __ _ __ _ _ |_ _| |__ ___| | | | __ _ ___| |__
| |\/| |/ _` | '__| '__| | | | | | | '_ \ / _ \ |_| |/ _` / __| '_ \
| | | | (_| | | | | | |_| | | | | | | | __/ _ | (_| \__ \ | | |
|_| |_|\__,_|_| |_| \__, | |_| |_| |_|\___|_| |_|\__,_|___/_| |_|
|___/
```
**MarryTheHash** 是一个专注于 CTF 的 CLI 工具包,用于哈希识别、John/Hashcat 命令建议、hashdump 扫描,以及根据虚构的挑战上下文生成排名的字典表。
它是为授权实验室、CTF、训练靶机和个人的密码恢复练习而构建的。它**不**包含泄露的密码数据库。
## 功能
- 识别常见的 CTF/实验室哈希格式并对可能的候选项进行排名。
- 提供 John the Ripper 和 Hashcat 命令建议。
- 扫描混合哈希文件、Windows pwdump 风格的转储以及 Linux shadow 风格的样本。
- 导出分组的破解文件,以实现更清晰的工作流。
- 为存档和加密文件(如 ZIP、RAR、7z、SSH 密钥、Office、PDF、KeePass)以及相关的 John 格式提供转换器建议。
- 将虚构的 CTF 上下文与密码行为特征进行匹配。
- 生成可控的字典表级别:`top`、`balanced`、`aggressive` 和 `all`。
- 运行内置的字典表质量检查,以减少程序化/AI 生成的垃圾词汇。
- 通过您自己的 API 密钥或本地 Ollama 设置提供可选的 AI 提供商支持。
## 允许的用途
- CTF 挑战
- 实验室环境
- 个人密码恢复
- 授权的安全审计
- 安全教育和防御性研究
## 不允许的用途
- 针对真实人员
- 攻击真实账户
- 未经授权的密码猜测
- 对真实服务使用泄露的密码转储
## 安装
Linux/macOS:
```
git clone https://github.com/Kenasz/MarryTheHash.git
cd MarryTheHash
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -e .
```
Windows PowerShell:
```
git clone https://github.com/Kenasz/MarryTheHash.git
cd MarryTheHash
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -e .
```
检查 CLI:
```
marry --help
marry doctor
```
## 快速演示
识别哈希:
```
marry identify 5f4dcc3b5aa765d61d8327deb882cf99
```
建议破解命令:
```
marry suggest 5f4dcc3b5aa765d61d8327deb882cf99 --wordlist generated/wordlist_top.txt
```
扫描内置的演示文件:
```
marry scan examples/hash_samples.txt
marry scan --windows examples/windows_hashdump.txt
marry scan --linux examples/linux_shadow_samples.txt
```
根据内置的演示计划构建排名的 CTF 字典表:
```
marry build-wordlist --plan examples/raven_ctf_plan.json --out-dir generated
```
输出文件夹包含:
```
generated/wordlist_top.txt
generated/wordlist_balanced.txt
generated/wordlist_aggressive.txt
generated/wordlist_all.txt
generated/wordlist_report.json
generated/README.txt
```
本地测试哈希的 John 工作流示例:
```
echo -n "Raven04" | md5sum | awk '{print $1}' > test.hash
marry build-wordlist --plan examples/raven_ctf_plan.json --out-dir generated
john --format=Raw-MD5 --wordlist=generated/wordlist_top.txt test.hash
john --show --format=Raw-MD5 test.hash
```
预期结果:
```
Raven04
```
## 常用命令
```
marry --help
marry doctor
marry identify
marry suggest
marry scan hashes.txt --source auto --export exported_hashes
marry convert archive.zip
marry profiles
marry profile-suggest "fictional CTF forum admin Raven born 2004"
marry build-wordlist --plan examples/raven_ctf_plan.json
```
使用 `--no-banner` 以获得更简洁的、适合脚本的输出:
```
marry --no-banner identify 5f4dcc3b5aa765d61d8327deb882cf99
```
## 支持的哈希覆盖范围
检测器包含常见的 CTF 和实验室格式,例如:
- 原始 MD5, SHA1, SHA224, SHA256, SHA384, SHA512
- NTLM, LM, NetNTLMv1, NetNTLMv2
- 旧版 MySQL/MySQL323 和 MySQL 4.1+/MySQL5
- Unix `crypt`: descrypt, md5crypt, sha256crypt, sha512crypt, bcrypt, yescrypt, Argon2
- WordPress/phpass, Drupal7, Joomla 旧版 `md5:salt`
- Django PBKDF2-SHA256, 旧版 Django SHA1/MD5
- 类 JWT token 提示
- Kerberos AS-REP/TGS 哈希提示
- WPA/WPA2 22000 样式
- John 转换器输出:ZIP, RAR, 7z, PDF, Office, KeePass, SSH 私钥, GPG, Bitcoin 钱包
哈希识别是基于模式的。模糊的原始哈希可能会匹配多种算法,因此 CTF 上下文仍然很重要。
## 测试
安装 pytest:
```
python -m pip install pytest
```
运行冒烟测试:
```
python -m pytest -q
```
当前的冒烟测试覆盖范围检查:
- CLI 帮助
- 哈希样本扫描
- Windows pwdump 风格扫描
- Linux shadow 风格扫描
- MD5 识别/建议
- 演示字典表生成
## 可选的 AI 模式
AI 支持是可选的。核心 pipeline 无需它即可工作。
```
marry api-key set openrouter
marry ai-plan --context "fictional CTF user: Warcraft modding forum admin Raven born 2004"
marry ai-send --provider openrouter --prompt ai_plan_prompt.txt --out ai_plan.json
marry build-wordlist --plan ai_plan.json
```
本地 Ollama 可以作为实验性提供商使用,但小型 VM 可能没有足够的内存来实现稳定的本地推理。
## 项目卫生
运行时文件会被 Git 故意忽略:
```
.env
ai_plan.json
ai_plan_prompt.txt
ai_profile_package.json
ai_plan_raw.txt
ai_wordgen_raw.txt
wordlist.txt
wordlist_*.txt
generated/
generated_demo/
*.hash
*.pot
*.egg-info/
__pycache__/
```
运行:
```
marry doctor
```
以检查本地工具、映射、配置、字典表和常见的意外运行时文件。
## 路线图
- 更多哈希格式提示和转换器建议。
- 更多演示场景。
- 针对微型本地模型的可选轻量级 AI 挖掘模式。
- 用于自动化测试运行的 GitHub Actions CI。
- 更简洁的打包发行版。
## 免责声明
本项目仅用于 CTF、授权实验室、教育和防御性安全实践。
标签:AI风险缓解, DOS头擦除, Python, 哈希识别, 安全规则引擎, 密码破解, 文档结构分析, 无后门, 逆向工具