观察 John the Ripper 如何处理加盐哈希
在本步骤中,你将使用流行的密码破解工具 John the Ripper 来观察它如何处理加盐和未加盐的哈希。这将展示加盐的实际影响。
首先,让我们尝试使用一个简单的单词列表来破解 salted_passwords.txt 中的密码。我们将为此演示使用一个小型自定义单词列表。
在你的 ~/project 目录中创建一个名为 wordlist.txt 的单词列表文件,其中包含一些常用密码:
echo "password" > ~/project/wordlist.txt
echo "user1password" >> ~/project/wordlist.txt
echo "anotherpassword" >> ~/project/wordlist.txt
echo "shortpass" >> ~/project/wordlist.txt
echo "123456" >> ~/project/wordlist.txt
现在,使用此单词列表针对你的 salted_passwords.txt 文件运行 John the Ripper:
john --wordlist=~/project/wordlist.txt ~/project/salted_passwords.txt
John the Ripper 将会分析哈希。你应该会看到输出表明它正在尝试破解密码。它可能会很快找到 user2 的密码,因为这是一个未加盐的 MD5 哈希,并且“password”在单词列表中。如果相应的明文在单词列表中,它也会找到加盐的密码。
示例输出可能如下所示:
Using default input encoding: UTF-8
Loaded 4 password hashes with no different salts to crack (crypt, generic crypt(3) [MD5/Blowfish/SHA1/SHA256/SHA512/XSHAa/XSHAab/bcrypt/scrypt])
Will run 4 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
password (user2)
user1password (user1)
anotherpassword (user3)
shortpass (user4)
4g 0:00:00:00 DONE (2023-10-27 10:30) ...
Session completed.
John 运行完成后,你可以使用 --show 选项查看已破解的密码:
john --show ~/project/salted_passwords.txt
此命令将显示 John 成功破解的任何密码。
user2:password (user2)
user1:user1password (user1)
user3:anotherpassword (user3)
user4:shortpass (user4)
4 password hashes cracked, 0 left
John the Ripper 被设计用来处理各种哈希格式,包括带有嵌入式盐的格式。它会自动提取盐并在破解过程中使用它。然而,每个密码都存在唯一的盐,这显著增加了破解所需的计算量,尤其是在大规模攻击中。