一、准备工作
1.工具安装
Kali Linux 内置部分工具,需补充安装以下工具:
sudo apt update sudo apt install pdfcrack hashcat john -y git clone https://github.com/magnumripper/JohnTheRipper # 更新版John
2.字典准备
-
常用字典:Kali 默认字典路径 /usr/share/wordlists/(如 rockyou.txt)。
-
自定义字典:使用 crunch 或 cewl 生成针对性字典:
crunch 6 8 1234567890 -o custom_num.dict # 生成6-8位纯数字字典 cewl https://example.com -d 3 -m 5 -w site_words.txt # 爬取网站关键词生成字典
-
或者自行准备字典
二、破解PDF文档密码
方法1:使用pdfcrack
pdfcrack -f encrypted.pdf -w /usr/share/wordlists/rockyou.txt # 字典攻击 pdfcrack -f encrypted.pdf --charset="ABCDEFGHIJKLMNOPQRSTUVWXYZ" --minpw=4 --maxpw=6 # 暴力破解(4-6位大写字母)
方法2:使用John the Ripper
1.提取PDF哈希:
pdf2john encrypted.pdf > pdf_hash.txt
2.执行破解
john --format=pdf pdf_hash.txt --wordlist=/usr/share/wordlists/rockyou.txt #使用字典的方式 john --show pdf_hash.txt # 查看结果 john pdf_hash.txt #直接破解
三、破解Excel/Word文档密码
步骤1:提取Office文件哈希
使用 office2john.py 提取哈希(需手动下载脚本):
python3 office2john.py kali.docx > mima.txt python3 office2john.py encrypted.xlsx >> mima.txt # 追加哈希 office2john kali.docx > mima.txt
步骤2:使用John破解
转换哈希格式: 确保哈希格式为 $office$version...(office2john.py 输出可直接使用)。 执行破解:
hashcat -m 9600 office_hash.txt /usr/share/wordlists/rockyou.txt # 字典模式 hashcat -m 9600 -a 3 office_hash.txt ?d?d?d?d?d?d # 暴力破解6位数字 john mima.txt
四、成功率与优化
-
字典质量:
-
使用针对性字典(如公司名、生日、常见密码组合)可大幅提升成功率。
-
-
扩展规则:
-
在John或hashcat中使用规则(如 --rules=best64)对字典进行变形(如添加后缀、大小写变换)。
-
-
硬件加速:
-
若使用NVIDIA显卡,安装 nvidia-opencl-dev 驱动提升hashcat速度。
-
五、注意事项
1.法律风险: 仅限破解自己拥有合法权限的文件,非法破解他人文件将面临刑事处罚。 2.复杂度限制: 超过8位的复杂密码(如 Pa$$w0rd!2023)可能需要数月甚至无法破解。 3.文件加密类型: 现代Office/PDF默认使用AES-256加密,传统RC4加密更容易被破解。
六、替代方案
-
在线服务(慎用):
-
部分网站(如 lostmypass.com)提供付费破解,但存在隐私泄露风险。
-
-
内存取证:
-
若文档曾被打开且内存未清除,可使用 volatility 工具提取内存中的密码明文。
-
重要提醒:技术无罪,滥用有责!请务必在合法授权范围内使用上述方法。