John the Ripper
2026/5/29工具工具John密码破解大约 3 分钟
John the Ripper
链接
是什么
John the Ripper,常简称 John,是密码破解工具。它特别适合和各种 xxx2john 工具配合,把压缩包、PDF、Office、SSH key 等转换成可破解哈希。
CTF 中常见用途:
- 破解 ZIP/RAR/7z 密码
- 破解 Linux shadow 密码
- 破解 PDF/Office 密码
- 破解 SSH 私钥口令
安装与配置
Ubuntu/Kali:
sudo apt update
sudo apt install johnKali 通常自带 jumbo 版本和大量 *2john 脚本。
验证:
john --list=formats基本用法
字典破解
john hash.txt --wordlist=rockyou.txt查看结果
john hash.txt --showZIP 破解
zip2john secret.zip > zip.hash
john zip.hash --wordlist=rockyou.txt
john zip.hash --showSSH 私钥
ssh2john id_rsa > ssh.hash
john ssh.hash --wordlist=rockyou.txt更多模式
增量模式(暴力破解)
john hash.txt --incremental
john hash.txt --incremental=digits # 只尝试数字
john hash.txt --incremental=lower # 只尝试小写字母
john hash.txt --incremental=alpha # 字母
john hash.txt --incremental=alnum # 字母数字规则模式
john hash.txt --wordlist=rockyou.txt --rules
john hash.txt --wordlist=rockyou.txt --rules=single
john hash.txt --wordlist=rockyou.txt --rules=jumbo单次破解模式
john hash.txt --single基于用户名等信息生成候选密码。
外部模式
john hash.txt --external=filter使用自定义过滤规则。
常用 2john 工具
查看可用工具
ls /usr/share/john/*2john*
ls /usr/lib/john/*2john*ZIP 破解
zip2john secret.zip > zip.hash
john zip.hash --wordlist=rockyou.txtRAR 破解
rar2john secret.rar > rar.hash
john rar.hash --wordlist=rockyou.txt7z 破解
7z2john secret.7z > 7z.hash
john 7z.hash --wordlist=rockyou.txtPDF 破解
pdf2john secret.pdf > pdf.hash
john pdf.hash --wordlist=rockyou.txtOffice 破解
office2john secret.docx > office.hash
john office.hash --wordlist=rockyou.txtSSH 私钥
ssh2john id_rsa > ssh.hash
john ssh.hash --wordlist=rockyou.txtLinux shadow
unshadow /etc/passwd /etc/shadow > unshadowed.txt
john unshadowed.txt --wordlist=rockyou.txtKeePass
keepass2john database.kdbx > keepass.hash
john keepass.hash --wordlist=rockyou.txtBitcoin wallet
bitcoin2john wallet.dat > bitcoin.hash
john bitcoin.hash --wordlist=rockyou.txt规则文件
常用规则
/etc/john/john.conf 中的规则:
[List.Rules:Wordlist] — 字典规则
[List.Rules:Single] — 单次规则
[List.Rules:Jumbo] — Jumbo 规则
[List.Rules:KoreLogic] — KoreLogic 规则自定义规则
编辑 /etc/john/john.conf:
[List.Rules:MyRule]
# 在词尾添加数字
Az"[0-9]"
# 在词首添加数字
A0"[0-9]"
# 大小写切换
c
# 首字母大写
cT1
# 重复词
dd使用自定义规则:
john hash.txt --wordlist=rockyou.txt --rules=MyRule常用规则变换
c — 大小写切换
cT1 — 首字母大写
Az"" — 追加字符
A0"" — 前置字符
dd — 重复
$[0-9] — 追加数字
^[0-9] — 前置数字CTF常用技巧
先找对应的 2john
ls /usr/share/john/*2john*常见:
zip2john
rar2john
7z2john
pdf2john
ssh2john
office2john
keepass2john和 hashcat 分工
John 转换格式方便,hashcat GPU 加速强。复杂题可先用 *2john 提取,再看是否能转 hashcat 模式。
使用题目线索做小字典
printf "admin\nctf\npassword\n123456\n" > words.txt
john hash.txt --wordlist=words.txt多个哈希文件
# 合并多个哈希
cat hash1.txt hash2.txt > combined.hash
john combined.hash --wordlist=rockyou.txt查看破解进度
john hash.txt --status恢复破解会话
john --restore
john --restore=session-name导出结果
john hash.txt --show
john hash.txt --show --format=raw-md5
john hash.txt --show > results.txt常见问题
zip2john 找不到
可能安装的不是 jumbo 版本。Kali 更省心,或从 John jumbo 源码/包安装。
No password hashes loaded
哈希格式不对,或转换步骤失败。重新检查 *2john 输出。
破解很慢
先用小字典和题目信息,不要盲目暴力。
格式不支持
# 查看支持的格式
john --list=formats
# 指定格式
john hash.txt --format=raw-md5 --wordlist=rockyou.txt
john hash.txt --format=raw-sha256 --wordlist=rockyou.txt内存不足
# 使用 --fork 多进程
john hash.txt --wordlist=rockyou.txt --fork=4
# 减少内存使用
john hash.txt --wordlist=rockyou.txt --save-memory结果不显示
# 显示所有结果
john hash.txt --show
# 显示特定格式
john hash.txt --show --format=raw-md5
# 显示未破解
john hash.txt --show=left关联
- 编码、哈希与加密
- 压缩包与嵌套文件
- hashcat
- file
- xxd与hexdump