john-the-ripper詳細
ここで簡単なjohn the ripperの使い方を説明したがもう少し詳しく。
クラックするファイルの作成
パスワードファイルとシャドウファイルからjhon the ripper用のファイルを生成
$ sudo unshadow /etc/passwd /etc/shadow > johnpasswd
辞書を使ったクラック
$ john --users=user2 --wordlist=pawwword johnpasswd
解析されたパスワードの表示
$ john --users=user2 --show johnpasswd
簡単な例題
- ubuntuでuser名がuser1、パスワードがuser1というアカウントを作ってみた。
$ john --users=user1 johnpasswd Loaded 1 password hash (crypt, generic crypt(3) [?/64]) Press 'q' or Ctrl-C to abort, almost any other key for status user1 (user1) 1g 0:00:00:00 100% 1/3 5.000g/s 480.0p/s 480.0c/s 480.0C/s user1..User10 Use the "--show" option to display all of the cracked passwords reliably Session completed
結果はこうなる。一瞬で終わる。
$ john --users=user1 --show johnpasswd user1:user1:1001:1001:,,,:/home/user1:/bin/bash 1 password hash cracked, 0 left
- 次にuser名がuser2、パスワードはmiyoko
$ john --users=user2 --single johnpasswd Loaded 1 password hash (crypt, generic crypt(3) [?/64]) Press 'q' or Ctrl-C to abort, almost any other key for status 0g 0:00:00:01 100% 0g/s 525.9p/s 525.9c/s 525.9C/s user21962..user21900 Session completed
結果はこうなってダメ。
$ john --users=user2 --show johnpasswd 0 password hashes cracked, 1 left
デフォルトで用意されているパスワードファイルを用いると、
$ john --users=user2 --wordlist=/usr/share/john/password.lst johnpasswd Loaded 1 password hash (crypt, generic crypt(3) [?/64]) Press 'q' or Ctrl-C to abort, almost any other key for status 0g 0:00:00:06 100% 0g/s 539.7p/s 539.7c/s 539.7C/s !@#$%..sss Session completed
やっぱりだめ
$ john --users=user2 --show johnpasswd 0 password hashes cracked, 1 left
どこかから持ってきた、日本語がらみのパスワードファイルを使ってみると、
$ john --users=user2 --wordlist=./lower_j johnpasswd Loaded 1 password hash (crypt, generic crypt(3) [?/64]) Press 'q' or Ctrl-C to abort, almost any other key for status miyoko (user2) 1g 0:00:01:47 100% 0.009267g/s 532.0p/s 532.0c/s 532.0C/s miyakosi..mizika Use the "--show" option to display all of the cracked passwords reliably Session completed
ばれた!!
$ john --users=user2 --show johnpasswd user2:miyoko:1002:1002:,,,:/home/user2:/bin/bash 1 password hash cracked, 0 left
- 次にuser名がuser3、パスワードはMiyoko
$ john --users=user3 --wordlist=./lower_j johnpasswd Loaded 1 password hash (crypt, generic crypt(3) [?/64]) Press 'q' or Ctrl-C to abort, almost any other key for status 0g 0:00:03:35 100% 0g/s 528.5p/s 528.5c/s 528.5C/s zyuuseki..zzetu Session completed
結果はダメ。最初が大文字になっただけなのに。
$ john --users=user3 --show johnpasswd 0 password hashes cracked, 1 left
次にuser2で、次のような方法をやってみた。これは総当たりなのか?
$ john -inc=ascii --users=user2 johnpasswd Loaded 1 password hash (crypt, generic crypt(3) [?/64]) Press 'q' or Ctrl-C to abort, almost any other key for status miyoko (user2) 1g 0:06:54:47 0.000040g/s 540.5p/s 540.5c/s 540.5C/s miyoll..miyo94 Use the "--show" option to display all of the cracked passwords reliably Session completed
$ john --users=user2 --show johnpasswd user2:miyoko:1002:1002:,,,:/home/user2:/bin/bash 1 password hash cracked, 0 left
解読はできたが7時間かかっている。次にdigitsというのを試してみたが、
$ john -inc=digits --users=user2 johnpasswd Loaded 1 password hash (crypt, generic crypt(3) [?/64]) Press 'q' or Ctrl-C to abort, almost any other key for status 0g 0:05:05:18 0g/s 536.1p/s 536.1c/s 536.1C/s 8778339..8797521 0g 0:09:06:09 0g/s 538.7p/s 538.7c/s 538.7C/s 45281429..45282556 0g 0:18:51:16 0g/s 541.1p/s 541.1c/s 541.1C/s 46274085..46291804 0g 1:00:20:04 0g/s 541.5p/s 541.5c/s 541.5C/s 57892628..57895988 0g 1:00:20:06 0g/s 541.5p/s 541.5c/s 541.5C/s 57850068..57854911 Session aborted
24時間経っても終わらない。これは数字だけのパスワードを延々探すんだなきっと。
(参考)結果の削除など
解析結果の消去
デモ等で解析結果を消去するには、ホームディレクトリ下の.john/john.potを削除する
うにっくすのユーザ追加、パスワード変更など
$ sudo adduser user1 $ sudo passwd user2
john --users=user3 --wordlist=lower_j johnpasswd
Loaded 1 password hash (crypt, generic crypt(3) [?/64])
Press 'q' or Ctrl-C to abort, almost any other key for status
0g 0:00:03:33 100% 0g/s 532.5p/s 532.5c/s 532.5C/s zyuuseki..zzetu
Session completed
Loaded 1 password hash (crypt, generic crypt(3) [?/64])
Press 'q' or Ctrl-C to abort, almost any other key for status
0g 0:00:03:33 100% 0g/s 532.5p/s 532.5c/s 532.5C/s zyuuseki..zzetu
Session completed
john --users=root --wordlist=../lower_j johnpasswd
Loaded 1 password hash (md5crypt [MD5 32/64 X2])
Press 'q' or Ctrl-C to abort, almost any other key for status
0g 0:00:00:05 100% 0g/s 19409p/s 19409c/s 19409C/s zzetu
Loaded 1 password hash (md5crypt [MD5 32/64 X2])
Press 'q' or Ctrl-C to abort, almost any other key for status
0g 0:00:00:05 100% 0g/s 19409p/s 19409c/s 19409C/s zzetu