John
the
Ripper
1.9.0をmacOS Xにインストールして使ってみる
- 更新履歴
はじめに
インストール
総当たり方式でZIPファイルのパスワード を解読する
解析に時間がかかる場合
モードの説明
搭載されているパスワードリストの確認
Probable Wordlists
並行処理を行う場合
ベンチマークの実行
更新履歴
- 2023/08/04 初版
- 2023/08/07 パスワードリストについての記事を追加
はじめに
- このドキュメントは.パスワードクラッキングツールのJohn the Ripperをインストールして,使ってみる.
- 今回は,macOS Monterey(12.6.6)を使って,HomeBrew配下でインストールを行うので簡単だが,GPUを使った高速解析機能が使え ないデメリットが ある.
- 総当たり方式で調査する方法もあるが,パスワードリストを使って効率的に調査することもできるので,外部のパスワードリストを入手する方 法につ いても記載している.
インストール
- HomeBrewでパッケージを探す.
$ brew search john🆑
==> Formulae
john
john-jumbo🈁
johnnydep
[MacPro2013:ujpadmin 18:27:35 ~ ]
$
- 今回の対象はjohn-jumboなので情報を確認.
$ brew info john-jumbo🆑
==> john-jumbo: stable 1.9.0 (bottled)
Enhanced version of john, a UNIX password cracker
https://www.openwall.com/john/
Conflicts with:
john (because both install the same binaries)
Not installed
From:
https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/john-jumbo.rb
License: GPL-2.0-or-later
==> Dependencies
Build: pkg-config ✔
Required: gmp ✔, openssl@3 ✔
==> Analytics
install: 193 (30 days), 804 (90 days), 1,198 (365 days)
install-on-request: 193 (30 days), 804 (90 days), 1,198 (365 days)
build-error: 0 (30 days)
[MacPro2013:ujpadmin 18:34:39 ~ ]
$
- 必要なライブラリは,gmp(multiple precision arithmetic library:多倍精度演算ライブラリ)とOpenSSLの模様.
- 結構な数がインストールされている模様.
- インストールを実行する.
$ brew install john-jumbo🆑
Running `brew update --auto-update`...
==> Homebrew collects anonymous analytics.
Read the analytics documentation (and how to opt-out) here:
https://docs.brew.sh/Analytics
No analytics have been recorded yet (nor will be during this
`brew` run).
Installing from the API is now the default behaviour!
You can save space and time by running:
brew untap homebrew/core
brew untap homebrew/cask
==> Downloading
https://formulae.brew.sh/api/formula_tap_migrations.jws.json
#########################################################################################
100.0%
-略-
==> Downloading
https://formulae.brew.sh/api/cask_tap_migrations.jws.json
#########################################################################################
100.0%
==> Fetching dependencies for john-jumbo: openssl@3
==> Fetching openssl@3
==> Downloading
https://ghcr.io/v2/homebrew/core/openssl/3/manifests/3.1.2-1
#########################################################################################
100.0%
==> Downloading
https://ghcr.io/v2/homebrew/core/openssl/3/blobs/sha256:0acd29c85897b753de593d47
#########################################################################################
100.0%
==> Fetching john-jumbo
==> Downloading
https://ghcr.io/v2/homebrew/core/john-jumbo/manifests/1.9.0_1-1
#########################################################################################
100.0%
==> Downloading
https://ghcr.io/v2/homebrew/core/john-jumbo/blobs/sha256:0ace1b1a1ce24edde854033
#########################################################################################
100.0%
==> Installing dependencies for john-jumbo: openssl@3
==> Installing john-jumbo dependency: openssl@3
==> Pouring openssl@3--3.1.2.monterey.bottle.1.tar.gz
🍺 /usr/local/Cellar/openssl@3/3.1.2: 6,495 files, 30MB
==> Installing john-jumbo
==> Pouring john-jumbo--1.9.0_1.monterey.bottle.1.tar.gz
==> Caveats
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
==> Summary
🍺 /usr/local/Cellar/john-jumbo/1.9.0_1: 446 files, 76MB 🈁
==> Running `brew cleanup john-jumbo`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
-略-
Pruned 0 symbolic links and 2 directories from /usr/local
==> Caveats
==> john-jumbo
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
[MacPro2013:ujpadmin 18:36:03 ~ ]
$
- インストールできた模様.
/usr/local/Cellar/john-jumbo/1.9.0_1というディレクトリにインストールされてい る.
- ツールを実行し,ヘルプを実行する.
$ john -h🆑
John the Ripper 1.9.0-jumbo-1 [darwin21.6.0 64-bit x86_64 SSE4.2
AC]
Copyright (c) 1996-2019 by Solar Designer and others
Homepage: http://www.openwall.com/john/
Usage: john [OPTIONS] [PASSWORD-FILES]
--single[=SECTION[,..]] "single crack" mode,
using default or named rules
--single=:rule[,..]
same, using "immediate" rule(s)
--wordlist[=FILE] --stdin wordlist mode, read words from
FILE or stdin
--pipe
like
--stdin, but bulk reads, and allows rules
--loopback[=FILE]
like
--wordlist,
but extract words from a .pot file
--dupe-suppression
suppress all dupes in wordlist (and force preload)
--prince[=FILE]
PRINCE
mode,
read words from FILE
--encoding=NAME
input
encoding
(eg. UTF-8, ISO-8859-1). See also
doc/ENCODINGS
and
--list=hidden-options.
--rules[=SECTION[,..]] enable word
mangling rules (for wordlist or PRINCE
modes),
using
default or named rules
--rules=:rule[;..]]
same, using "immediate" rule(s)
--rules-stack=SECTION[,..] stacked rules, applied after regular
rules or to
modes
that
otherwise don't support rules
--rules-stack=:rule[;..] same, using "immediate"
rule(s)
--incremental[=MODE]
"incremental" mode [using section MODE]
--mask[=MASK]
mask
mode
using MASK (or default from john.conf)
--markov[=OPTIONS]
"Markov" mode (see doc/MARKOV)
--external=MODE
external
mode
or word filter
--subsets[=CHARSET]
"subsets" mode (see doc/SUBSETS)
--stdout[=LENGTH]
just
output
candidate passwords [cut at LENGTH]
--restore[=NAME]
restore
an
interrupted session [called NAME]
--session=NAME
give
a
new session the NAME
--status[=NAME]
print
status
of a session [called NAME]
--make-charset=FILE make
a charset file. It will be overwritten
--show[=left]
show
cracked
passwords [if =left, then uncracked]
--test[=TIME]
run
tests
and benchmarks for TIME seconds each
--users=[-]LOGIN|UID[,..] [do not] load this (these) user(s)
only
--groups=[-]GID[,..] load
users [not] of this (these) group(s) only
--shells=[-]SHELL[,..] load users
with[out] this (these) shell(s) only
--salts=[-]COUNT[:MAX] load salts
with[out] COUNT [to MAX] hashes
--costs=[-]C[:M][,...] load salts
with[out] cost value Cn [to Mn]. For
tunable
cost
parameters, see doc/OPTIONS
--save-memory=LEVEL
enable memory saving, at LEVEL 1..3
--node=MIN[-MAX]/TOTAL this node's number
range out of TOTAL count
--fork=N
fork
N
processes
--pot=NAME
pot
file
to use
--list=WHAT
list
capabilities,
see --list=help or doc/OPTIONS
--devices=N[,..]
set
OpenCL
device(s) (see --list=opencl-devices)
--format=NAME
force
hash
of type NAME. The supported formats can
be
seen
with --list=formats and --list=subformats
[MacPro2013:ujpadmin 18:41:00 ~ ]
$
- よく使うオプションは次から説明する.
総当たり方式でZIPファイルのパスワード を解読する
- お試し用にパスワード付きZIPファイルを作成し,解析してみる.
- 今回の手順は,パスワード付きZIPファイルを作成し,パスワード情報を取り出し,解析を行う.
- まずは,パスワード付きファイルを作る.
$ zip -e data.zip data.txt🆑
Enter password:🔑
Verify password:🔑
adding: data.txt (stored 0%)
[MacPro2013:ujpadmin 19:02:31 ~/bin/john ]
$
- 今回はパスワード長を3文字にした.
- パスワード付きZIPファイルから,zip2johnコマンドを使ってパスワード情報を取得.
- 今回は,zip2johnコマンドはフルパスで指定した.
$ /usr/local/Cellar/john-jumbo/1.9.0_1/share/john/zip2john
data.zip > passInfo.txt🆑
ver 1.0 efh 5455 efh 7875 data.zip/data.txt PKZIP Encr: 2b chk,
TS_chk, cmplen=17, decmplen=5, crc=3BB935C6
[MacPro2013:ujpadmin 19:03:13 ~/bin/john ]
$
- 取得したパスワード情報のファイルを確認.
$ cat passInfo.txt
data.zip/data.txt:$pkzip2$1*2*2*0*11*5*3bb935c6*0*42*0*11*3bb9*9846*e89a8cc9a8b642837e41440734a6b5ed40*$/pkzip2$:data.txt:data.zip::data.zip
[MacPro2013:ujpadmin 19:07:58 ~/bin/john ]
$
- 今回は,パスワード総当たりで調査を実施.
$ john --incremental=ASCII passInfo.txt🆑
Using default input encoding: UTF-8
Loaded 1 password hash (PKZIP [32/64])
Press 'q' or Ctrl-C to abort, almost any other key for status
app
(data.zip/data.txt) 🈁
1g 0:00:00:13 DONE (2023-08-04 19:04) 0.07163g/s 2824Kp/s 2824Kc/s
2824KC/s byh..ap0
Use the "--show" option to display all of the cracked passwords
reliably
Session completed
[MacPro2013:ujpadmin 19:04:24 ~/bin/john ]
$
- 13秒でパスワードが解析できた.
- 2回目に実行するともっと速かった.
解析に時間がかかる場合
- パスワード長が長い場合は時間がかかる.その場合は,エンターキーを押すとステータスが表示される.
$ john --incremental=ASCII passInfo.txt🆑
Using default input encoding: UTF-8
Loaded 1 password hash (PKZIP [32/64])
Press 'q' or Ctrl-C to abort, almost any other key for status
0g 0:00:32:43 0g/s 6852Kp/s 6852Kc/s 6852KC/s
rct29ce3..rct29cl3 🈁
モードの説明
ジョン・ザ・リッパーのクラッキングモード。https://www.openwall.com/john/doc/MODES.shtml
- Wordlist mode
- よく使われるパスワードリストを持っている必要がある.
- Single crack mode
- ホームディレクトリ名とかをベースにパスワードを推測する高速モード.
- Incremental mode
- パスワードとして利用可能な文字の組み合わせを試す.
- オプション指定で,ルールを指定可能.
- 「ASCII」(すべての95の印刷可能なASCII文字)
- 「LM_ASCII」(LMハッシュで使用)
- LMはLAN Manager,つまりWindowsのパスワード.
- 「Alnum」(すべての62文字の英数字)
- 「Alpha」(すべての52文字)
- 「LowerNum」(小文字と数字、合計36桁)
- 「UpperNum」(大文字と数字、合計36桁)
- 「LowerSpace」(小文字とスペース、合計27)
- 「Lower」(小文字)
- 「Upper」(大文字)
- 「Digits」(数字のみ)
- External mode
- 外部クラッキングモード.外部の関数プログラムを利用する場合の模様.
- john.confファイルに,次のような定義がある.
[Incremental:ASCII]
File = $JOHN/ascii.chr
MinLen = 0
MaxLen = 13
CharCount = 95
- この例では,IncrementalモードでASCIIを指定すると,最小0桁から最大13桁となる.
- また,Externalモードについても外部関数について記載が.
# Some pre-defined word filters as used to generate the supplied
.chr files
[List.External:Filter_ASCII]
void filter()
{
int i, c;
i = 0;
while (c = word[i++])
if (c < 0x20 || c
> 0x7e || i > 13) {
word
=
0; return;
}
}
- システムによって一定のパスワードルールがある場合は,それに近い記載をすれば良いのだろう.
- .chrファイルが提供されている.
$ cd /usr/local/Cellar/john-jumbo/1.9.0_1/share/john/🆑
[MacPro2013:ujpadmin 19:35:22
/usr/local/Cellar/john-jumbo/1.9.0_1/share/john ]
$ ls -la *.chr🆑
-rw------- 1 ujpadmin admin 4086722 5 15 2019
alnum.chr
-rw------- 1 ujpadmin admin 4174257 5 15 2019
alnumspace.chr
-rw------- 1 ujpadmin admin 1950539 5 15 2019
alpha.chr
-rw------- 1 ujpadmin admin 5720262 5 15 2019
ascii.chr
-rw------- 1 ujpadmin admin 465097 5 15 2019
digits.chr
-rw------- 1 ujpadmin admin 1466791 5 15 2019
lanman.chr
-rw------- 1 ujpadmin admin 7449800 5 15 2019
latin1.chr
-rw------- 1 ujpadmin admin 1184244 5 15 2019
lm_ascii.chr
-rw------- 1 ujpadmin admin 1161863 5 15 2019
lower.chr
-rw------- 1 ujpadmin admin 2464980 5 15 2019
lowernum.chr
-rw------- 1 ujpadmin admin 1209621 5 15 2019
lowerspace.chr
-rw------- 1 ujpadmin admin 668568 5 15 2019
upper.chr
-rw------- 1 ujpadmin admin 1220961 5 15 2019
uppernum.chr
-rw------- 1 ujpadmin admin 9286825 5 15 2019 utf8.chr
[MacPro2013:ujpadmin 19:35:27
/usr/local/Cellar/john-jumbo/1.9.0_1/share/john ]
$
搭載されているパスワードリストの確認
- 標準搭載されているパスワードリスト.
$ ls -la *.lst🆑
-rw------- 1 ujpadmin admin 26325 5 15 2019
password.lst
[MacPro2013:ujpadmin 19:42:35
/usr/local/Cellar/john-jumbo/1.9.0_1/share/john ]
$
- 中身を確認.
$ head -n 20
/usr/local/Cellar/john-jumbo/1.9.0_1/share/john/password.lst🆑
#!comment: This list has been compiled by Solar Designer of
Openwall
Project
#!comment: in 1996 through 2011. It is assumed to be in the
public domain.
#!comment:
#!comment: This list is based on passwords most commonly seen on a
set of Unix
#!comment: systems in mid-1990's, sorted for decreasing number of
occurrences
#!comment: (that is, more common passwords are listed
first).
It has been
#!comment: revised to also include common website passwords from
public lists
#!comment: of "top N passwords" from major community website
compromises that
#!comment: occurred in 2006 through 2010.
#!comment:
#!comment: Last update: 2011/11/20 (3546 entries)
#!comment:
#!comment: For more wordlists, see
http://www.openwall.com/wordlists/
123456🈁
12345
password
password1
123456789
12345678
1234567890
- よりパスワードリストを取得したい場合は購入することができる.
- Openwall wordlists collection full version - paid download - $27.95
- private download link valid for 1+ week
- ZIP archive (main wordlists collection): 151 MB (uncompresses to 610 MB)
- two gz archives (pwgen passwords bonus): 126 MB and 124 MB (uncompress to 397 MB and 409 MB)
- Openwall wordlists collection フルバージョン - 有料ダウンロード - $27.95
- プライベートダウンロードリンクは1週間以上有効
- ZIPアーカイブ(メイン単語リストコレクション): 151 MB (610MBに解凍)
- 2つのgzアーカイブ(pwgenパスワードボーナス): 126 MB および 124 MB (397 MB および 409 MB に解凍)
- この価格を高いとみるか安いとみるか...
Probable Wordlists
- Githubでパスワードリストが公開されている.
- The Why
Password wordlists are not hard to find. It seems like every few weeks we hear about a massive, record-breaking data breach that has scattered millions of credentials across the internet for everyone to see. If our data is leaked, we'll change our passwords, the hard-working security teams will address the vulnerabilities and everyone will wait until they hear about the next breach. - その理由
パスワードの単語リストを見つけるのは難しくない。数週間おきに、何百万ものクレデンシャルがインターネット上にばらまかれ、誰もが 閲覧できるようになったという、記録的な大規模データ漏洩のニュースを耳にするような気がする。私たちのデータが流出した場合、私た ちはパスワードを変更し、勤勉なセキュリティチームは脆弱性に対処し、誰もが次の流出について聞くまで待つだろう。 - このパスワードリストを入手して確認.
$ git clone https://github.com/berzerk0/Probable-Wordlists🆑
Cloning into 'Probable-Wordlists'...
remote: Enumerating objects: 3200, done.
remote: Total 3200 (delta 0), reused 0 (delta 0), pack-reused
3200
Receiving objects: 100% (3200/3200), 58.64 MiB | 10.35 MiB/s,
done.
Resolving deltas: 100% (613/613), done.
[MacPro2013:ujpadmin 09:48:44 ~/bin/john ]
$
- ファイルを確認.
$ tree Probable-Wordlists/🆑
Probable-Wordlists/
├── Analysis-Files
│ ├── Analysis-Files-Megalinks.md
│ ├── Analysis-Files-Torrents
│ │ ├──
ProbWL-v2-Analysis-Files-7z.torrent
│ │ └──
ProbWL-v2-Analysis-Files-targz.torrent
│ ├── Appearances-Top12Thousand-probable-v2.txt
│ ├── Appearances-Top1575-probable-v2.txt
│ ├── Appearances-Top304Thousand-probable-v2.txt
│ ├── ProbWL-197-rule-probable-v2.rule
│ ├── ProbWL-26-rule-probable-v2.rule
│ ├── ProbWL-51-rule-probable-v2.rule
│ ├── ProbWL-547-rule-probable-v2.rule
│ └── README.md
├── Changelog.md
├── Contributing.md
├── Dictionary-Style
│ ├── Dictionary-Style-MegaLinks.md
│ ├── Dictionary-Style-Rev-2-Torrents
│ │ ├──
ProbWL-v2-Dictionary-Style-7z.torrent
│ │ └──
ProbWL-v2-Dictionary-Style-targz.torrent
│ ├── README.md
│ └── Technical_and_Default
│ ├── Domains_ProbWL.txt
│ ├──
Password_Default_ProbWL.txt 🈁
│ ├──
Username_Default_ProbWL.txt🈁
│ └── tld.txt
├── Downloads.md
├── License.txt
├── ProbableWordlistLogo.png
├── README.md
└── Real-Passwords
├── README.md
├── Real-Password-Rev-2-Torrents
│ ├──
ProbWL-v2-Real-Passwords-7z.torrent
│ └──
ProbWL-v2-Real-Passwords-targz.torrent
├── Real-Passwords-MegaLinks.md
├── Top12Thousand-probable-v2.txt🈁
├── Top1575-probable-v2.txt🈁
├── Top207-probable-v2.txt🈁
├── Top304Thousand-probable-v2.txt🈁
└── WPA-Length
├── README.md
├──
Real-Password-WPA-MegaLinks.md
├──
Top204Thousand-WPA-probable-v2.txt
├──
Top447-WPA-probable-v2.txt
├──
Top4800-WPA-probable-v2.txt
├──
Top62-WPA-probable-v2.txt
└──
WPA-Length-Rev-2-Torrents
├──
ProbWL-v2-Real-WPA-Passwords-7z.torrent
└──
ProbWL-v2-Real-WPA-Passwords-targz.torrent
10 directories, 41 files
[MacPro2013:ujpadmin 09:48:59 ~/bin/john ]
$
- 収録されているのは次のようなもの.
- よく使いそうなパスワードリスト
- ネットワーク機器などのデフォルトで使われているユーザIDとパスワード
- Username_Default_ProbWL.txt
- Password_Default_ProbWL
- リアルパスワード
- These Are The Passwords!
- パスワードの出現率の多い順のリストになっている.小さいファイルにあるパスワードは出現率が高い.
- Top12Thousand-probable-v2.txt
- Top207-probable-v2.txt
- Top304Thousand-probable-v2.txt
- Top1575-probable-v2.txt
- WPA
- WPA/2セキュリティで保護されたルーターで使用される形式
- 小さいファイルは大きいファイルに含まれている.
- Top62-WPA-probable-v2.txt
- Top204Thousand-WPA-probable-v2.txt
- Top447-WPA-probable-v2.txt
- Top4800-WPA-probable-v2.txt
- 他にもトップドメインのリストなども含まされていた.
並行処理を行う場合
- CPUをたくさん搭載している場合,forkオプションを指定することで複数のプロセスを起動できる.
- 今回は,6コアのマシンを使って解析するので,5としてみた.
$ john --incremental=ASCII --fork=5 passInfo.txt🆑
Using default input encoding: UTF-8
Loaded 1 password hash (PKZIP [32/64])
Node numbers 1-5 of 5 (fork)
Press 'q' or Ctrl-C to abort, almost any other key for status
- 実行するとプロセスはしたのはこんな感じ.
- たくさんのCPUを搭載していると速いのだろう.
- 実行中に途中経過を見るためにエンタキーを押してみる.
Press 'q' or Ctrl-C to abort, almost any other key for status
1 0g 0:00:04:37 0g/s 6432Kp/s 6432Kc/s 6432KC/s
pyzinb87..pyzianna
4 0g 0:00:04:37 0g/s 5941Kp/s 5941Kc/s 5941KC/s
ssmbr41..ssmbbg2
5 0g 0:00:04:37 0g/s 5950Kp/s 5950Kc/s 5950KC/s
iapp1n38..iapp1n1.
3 0g 0:00:04:37 0g/s 5995Kp/s 5995Kc/s 5995KC/s
18dic2982..18dic2952
2 0g 0:00:04:37 0g/s 5987Kp/s 5987Kc/s 5987KC/s
gwtz6y!..gwtz6ja
1 0g 0:00:05:01 0g/s 6459Kp/s 6459Kc/s 6459KC/s
rlecip06..rlecipio
- プロセスごとにKp/sが出ている.
- シングルだと6800Kp/sだったので,若干プロセスあたりの処理件数は減っている模様.
ベンチマークの実行
- このツールにはベンチマークテスト機能があるというので,試してみた.
$ john --test🆑
Benchmarking: descrypt, traditional crypt(3) [DES 128/128
SSE2]... DONE
Many salts: 5208K c/s real, 5260K c/s virtual
Only one salt: 4959K c/s real, 5059K c/s
virtual
Benchmarking: bsdicrypt, BSDI crypt(3) ("_J9..", 725 iterations)
[DES 128/128 SSE2]... DONE
Speed for cost 1 (iteration count) of 725
Many salts: 171264 c/s real, 174759 c/s
virtual
Only one salt: 170368 c/s real, 170368 c/s
virtual
Benchmarking: md5crypt, crypt(3) $1$ (and variants) [MD5 128/128
SSE4.1 4x5]... DONE
Many salts: 26260 c/s real, 26795 c/s virtual
Only one salt: 24198 c/s real, 24938 c/s
virtual
Benchmarking: md5crypt-long, crypt(3) $1$ (and variants) [MD5
32/64]... DONE
Raw: 8088 c/s real, 8253 c/s virtual
Benchmarking: bcrypt ("$2a$05", 32 iterations) [Blowfish 32/64
X3]... DONE
Speed for cost 1 (iteration count) of 32
Raw: 1090 c/s real, 1101 c/s virtual
ー略ー
- 永遠に終わらない感じだったので途中で終了.
- ベンチマークによって何が分かるのかが,わからなかった...