使用自定义词表与 John the Ripper
在上一步中,我们使用了 John the Ripper
及其默认设置。现在,我们将通过创建和使用自定义词表来提高我们的破解成功率。词表是一个包含潜在密码的文件,破解工具会针对哈希测试这些密码。自定义词表可以定制为包含常见密码或与目标相关的特定术语,这通常会增加成功的机会。
我们将继续在 Kali Linux 容器的 shell 中,位于 /root
目录中。让我们创建一个名为 custom_wordlist.txt
的文件,其中包含一个用于演示的潜在密码的小列表。运行以下命令来创建此文件:
echo -e "password123\nadmin123\nsimplepass\ntest1234\nqwerty" > /root/custom_wordlist.txt
此命令将五个示例密码写入 custom_wordlist.txt
。要确认文件已正确创建,请使用以下命令显示其内容:
cat /root/custom_wordlist.txt
你应该看到如下所示的密码列表:
password123
admin123
simplepass
test1234
qwerty
现在,让我们将此自定义词表与 John the Ripper
一起使用,以破解 sample_hashes.txt
中的哈希。运行以下命令以启动破解过程:
john --wordlist=/root/custom_wordlist.txt /root/sample_hashes.txt
此命令使用 --wordlist
选项指定自定义词表。该过程可能需要几秒钟,你可能会看到类似这样的输出:
Using default input encoding: UTF-8
Loaded 2 password hashes with 2 different salts (sha512crypt, crypt(3) $6$ [SHA512 256/256 AVX2 4x])
Cost 1 (iteration count) is 5000 for all loaded hashes
Will run 4 OpenMP threads
Proceeding with wordlist mode
完成后,通过运行以下命令来检查结果:
john --show /root/sample_hashes.txt
如果任何密码与词表中的条目匹配,输出可能如下所示:
user1:password123
user2:simplepass
2 password hashes cracked, 0 left
如果没有破解其他密码,则表明哈希与我们的小词表不匹配,这对于学习来说是可以接受的。这一步展示了如何使用自定义数据增强破解尝试。接下来,我们将通过在相同的哈希上使用 Hashcat
来比较这种方法。