oliverjueguen/zip2hashcat

GitHub: oliverjueguen/zip2hashcat

从加密 ZIP 文件中提取 hashcat 原生格式的密码哈希,支持 ZipCrypto 和 WinZip AES 加密类型的自动识别与模式匹配。

Stars: 0 | Forks: 1

# zip2hashcat

zip2hashcat

从 ZIP 文件中提取原生 **hashcat 兼容格式** 的密码哈希。类似于 `zip2john`,但专为 hashcat 设计。无需安装 John。 ## 目录 * 📥 [安装](#install) * 💻 [用法](#usage) * ⚙️ [支持的格式](#supported-formats) * 🔍 [工作原理](#how-it-works) * ⚡ [zip2hashcat vs zip2john](#zip2hashcat-vs-zip2john) ## 安装 zip2hashcat 需要 **Python 3.10+** 且 **零依赖** —— 只需下载并运行: ``` wget https://raw.githubusercontent.com/oliverjueguen/zip2hashcat/main/zip2hashcat.py && chmod +x zip2hashcat.py ``` 如需永久设置,可使用 pipx 安装: ``` pipx install git+https://github.com/oliverjueguen/zip2hashcat ``` 或者使用 pip: ``` pip install git+https://github.com/oliverjueguen/zip2hashcat ``` ## 用法 ``` ./zip2hashcat.py secret.zip # Extract hash + show info and commands ./zip2hashcat.py secret.zip -o hash.txt # Save hash to file ./zip2hashcat.py secret.zip -q # Just the hash (for piping) ./zip2hashcat.py secret.zip --info # Inspect ZIP encryption details ``` ### 输出示例 ``` ╔════════════════════════════════════════╗ ║ zip2hashcat v1.0.0 ║ ╚════════════════════════════════════════╝ File: secret.zip Entries: 2 total, 2 encrypted Encryption: ZIPCRYPTO Hashcat mode: -m 17220 (PKZIP (Compressed Multi-File)) Files: • document.pdf • notes.txt Hashcat command: hashcat -m 17220 -a 0 hash.txt /usr/share/wordlists/rockyou.txt With rules: hashcat -m 17220 -a 0 hash.txt /usr/share/wordlists/rockyou.txt -r /usr/share/hashcat/rules/best64.rule Brute-force (8 chars): hashcat -m 17220 -a 3 hash.txt ?a?a?a?a?a?a?a?a ``` ### 通过管道直接传输给 Hashcat ``` ./zip2hashcat.py secret.zip -q | hashcat -m 17200 -a 0 - /usr/share/wordlists/rockyou.txt ``` ### 命令行选项 ``` positional arguments: zipfile Path to password-protected ZIP file(s) options: -o, --output Save hash to file -q, --quiet Only output the hash (for piping) --json Output results as JSON --info Show ZIP encryption info only -V, --version Print version and exit -h, --help Show help message and exit ``` ## 支持的格式 | 加密类型 | Hashcat 模式 | 哈希格式 | 描述 | | --- | --- | --- | --- | | ZipCrypto (单文件, 压缩) | `-m 17200` | `$pkzip$` | 最常见的传统 ZIP | | ZipCrypto (单文件, 存储) | `-m 17210` | `$pkzip$` | 未压缩条目 | | ZipCrypto (多文件, 压缩) | `-m 17220` | `$pkzip$` | 多文件,全部 deflate 压缩 | | ZipCrypto (混合多文件) | `-m 17225` | `$pkzip$` | 压缩与存储混合 | | WinZip AES-128 | `-m 13600` | `$zip2$` | 现代加密 | | WinZip AES-192 | `-m 13600` | `$zip2$` | 现代加密 | | WinZip AES-256 | `-m 13600` | `$zip2$` | 现代加密 (最常见) | 正确的 hashcat 模式是基于 ZIP 的加密方法、压缩类型和条目数量**自动检测**的。 ## 工作原理 zip2hashcat 直接解析 ZIP 二进制结构(本地文件头、中央目录、AES 扩展字段),以提取 hashcat 所需的加密材料: - **ZipCrypto**:提取 12 字节加密头 + 加密数据 + CRC32 校验和 → `$pkzip$` 格式 - **WinZip AES**:提取盐值 + 密码验证字节 + 认证码 → `$zip2$` 格式 使用当前的 `$pkzip$` 格式(而非旧版 `$pkzip2$`,后者存在[校验和 bug](https://github.com/hashcat/hashcat/issues/2719))。 ## zip2hashcat 与 zip2john 对比 | | zip2john | zip2hashcat | | --- | --- | --- | | 依赖项 | 需要 John the Ripper | **独立** (纯 Python) | | 输出格式 | John 格式 (需要 `cut -d ':' -f 2`) | **hashcat 就绪** | | 模式检测 | 手动 | **自动** | | 哈希格式 | `$pkzip$` / `$pkzip2$` (旧版本) | `$pkzip$` (当前版) | | 开箱即用命令 | ❌ | ✅ | | AES 支持 | 通过 zip2john | **原生** | | 安装 | 完整 John 套件 | **单文件 wget** | ## 作者 由 [@oliverjueguen](https://github.com/oliverjueguen) 制作 ## 许可证 MIT
标签:Bitdefender, CTF工具, DOS头擦除, Hashcat, PKZIP, Python, zip2john替代, ZIP文件, 哈希提取, 密码学, 密码破解, 手动系统调用, 数据取证, 无后门, 漏洞搜索, 离线攻击, 逆向工具