官方网站:http://www.openwall.com/john/
下载:wget http://www.openwall.com/john/j/john-1.8.0.tar.gz
解压:tar -xvf john-1.8.0.tar.gz
进入src目录:
cd john-1.8.0 && cd src
make
根据自己系统版本选择。
make clean linux-x86-64
编译成功会在run目录下生成john可执行文件。
John the Ripper 的使用方法
- 检测(或者说破解)弱口令
1)Linux 的用户口令保存在 “/etc/shadow” 文件中,可先将其拷贝到一个文本文档中:
# shadow 加密保存 root 或其他用户的口令
sudo cat /etc/shadow
root:$6$6VgjtRpu$DbbXO54tDOsqhEQD1rqrwrL83cd4fSUisNHvFu69VA5mYIKtE556LQzzbaSxGLQFh7u.smpe2meRjTPn5y0uJ1:17716:0:99999:7:::
andy:$6$DK4ye8lg$.DWNm6KZbt.0gbpwN/KoKUoC.2wONd.JQL/Dp8jGYOcUHAt37ecz24Zy5bfq3EUw8Ajt1aAuQT.hWEqxPr1Su1:17716:0:99999:7:::
#拷贝 shadow 文件
sudo cp /etc/shadow shadow.txt
2)执行检测或破解
#执行检测或破解
andy@localhost:~$ run/john shadow.txt
Loaded 2 password hashes with 2 different salts (crypt, generic crypt(3) [?/64])
Press 'q' or Ctrl-C to abort, almost any other key for status
123456 (andy)
123456 (root)
andy@localhost:~$ run/john --show shadow.txt
root:123456:17716:0:99999:7:::
andy:123456:17716:0:99999:7:::
- 更新弱口令字典
1)John the Ripper 针对弱口令的检测或破解,其实就是利用了弱口令字典。其默认的字典保存在 “run” 目录中,文件名为 “password.lst”,下面截取了一小段,感受一下
123456
12345
password
password1
123456789
12345678
1234567890
abc123
computer
tigger
1234
qwerty
money
carmen
mickey
secret
summer
internet
a1b2c3
123
service
2)做一个实验,我把用户的密码强度提高,比如123456@china,这就不在弱口令字典中了
andy@localhost:~$ sudo passwd andy
[sudo] password for andy:
Enter new UNIX password:
Retype new UNIX password:
3)重新拷贝 “/etc/shadow” 文件,然后进行检测或破解,你会发现经过很长时间也破解不了
4)将该密码也作为弱口令添加到弱口令字典中,再进行检测或破解呢?
重新执行检测或破解,这次很快就破解了。也就是说,随着时间的延续发展,可以不断的更新弱口令字典,以保证口令的强度。
andy@localhost:~$ run/john shadow.txt
Loaded 2 password hashes with 2 different salts (crypt, generic crypt(3) [?/64])
Remaining 1 password hash
Press 'q' or Ctrl-C to abort, almost any other key for status
123456@china (andy)
andy@localhost:~$ run/john --show shadow.txt
root:123456:17716:0:99999:7:::
andy:123456@china:17821:0:99999:7:::
2 password hashes cracked, 0 left