あらすじ
私は思った、cracklibの辞書を強化したいと。https://github.com/danielmiessler/SecLists/raw/master/Passwords/Common-Credentials/10-million-password-list-top-1000000.txt とか使うことで。
cracklibの辞書について
cracklib-check コマンドでパスワードをチェックするとき、専用の辞書が利用される。CentOS 7では /usr/share/cracklib/
に配置されている。
現状確認
CentOS 7.9ではcracklibの辞書はこのようになっていて、約184万ワードの辞書が利用されているようだ。
# ll /usr/share/cracklib/
total 9192
-rw-r--r--. 1 root root 1024 Jun 10 2014 cracklib-small.hwm
-rw-r--r--. 1 root root 250120 Jun 10 2014 cracklib-small.pwd
-rw-r--r--. 1 root root 13232 Jun 10 2014 cracklib-small.pwi
-rw-r--r--. 1 root root 360 Jun 10 2014 cracklib.magic
-rw-r--r--. 1 root root 1024 Jun 10 2014 pw_dict.hwm
-rw-r--r--. 1 root root 8663484 Jun 10 2014 pw_dict.pwd
-rw-r--r--. 1 root root 460232 Jun 10 2014 pw_dict.pwi
# cracklib-unpacker /usr/share/cracklib/pw_dict | wc -l
1840865
create-cracklib-dict コマンドを使って辞書を作成するとして、デフォルトの辞書はどうなっているだろう?
インストールされているパッケージ情報からすると、cracklib-dictは以下のバージョンになっている。
# yum info cracklib-dicts
...
インストール済みパッケージ
名前 : cracklib-dicts
アーキテクチャー : x86_64
バージョン : 2.9.0
リリース : 11.el7
容量 : 9.0 M
リポジトリー : installed
提供元リポジトリー : base
要約 : The standard CrackLib dictionaries
URL : http://sourceforge.net/projects/cracklib/
ライセンス : LGPLv2+
説明 : The cracklib-dicts package includes the CrackLib
: dictionaries. CrackLib will need to use the dictionary
: appropriate to your system, which is normally put in
: /usr/share/dict/words. Cracklib-dicts also contains the
: utilities necessary for the creation of new dictionaries.
:
: If you are installing CrackLib, you should also install
: cracklib-dicts.
オリジナルを確認
GitHubにあるcracklibの辞書から辞書を作成するとサイズが合わない…。ワード数も20万ほど異なっている。
# wget https://github.com/cracklib/cracklib/archive/v2.9.0.tar.gz
# tar xvzf v2.9.0.tar.gz
# cd cracklib-2.9.0/cracklib-words/src
# wc -l words clarkson-passwords
1654193 words
45953 clarkson-passwords
1700146 合計
# create-cracklib-dict words clarkson-passwords
1654191 1654191
# ll
...
-rw-r--r-- 1 root root 7491003 6月 22 11:12 pw_dict.pwd
調査時のmasterブランチでも同じワード数だった。
# wget https://github.com/cracklib/cracklib/raw/master/words/files/cracklib/words.bz2
# bunzip2 words.bz2
# ll
...
-rw-r--r-- 1 root root 16695342 6月 19 19:15 words
# wc -l words
1654193 words
# create-cracklib-dict words
1654191 1654191
rpmソースを確認
CentOS 7版のrpmソースをダウンロードして確認すると、それっぽいものが見つかった。
# cd /usr/local/src/
# mkdir cracklib-srpm
# cd cracklib-srpm
# yumdownloader --source cracklib-dicts
# rpm2cpio cracklib-2.9.0-11.el7.src.rpm cracklib | cpio --list
ASSurnames.gz
Congress.gz
Domains.gz
Dosref.gz
Family-Names.gz
Ftpsites.gz
Given-Names.gz
Jargon.gz
LCarrol.gz
Movies.gz
Paradise.Lost.gz
Python.gz
Trek.gz
cartoon.gz
common-passwords.txt.gz
cracklib-2.9.0-inttypes.patch
cracklib-2.9.0-packlib-gztype.patch
cracklib-2.9.0-packlib-lookup.patch
cracklib-2.9.0-packlib-reentrant.patch
cracklib-2.9.0-python-gzdicts.patch
cracklib-2.9.0-simplistic.patch
cracklib-2.9.0-translation-updates.patch
cracklib-2.9.0.tar.gz
cracklib-words-20080507.gz
cracklib.default.zh_CN.po
cracklib.spec
cracklib2_2.8.19-1.debian.tar.gz
cracklib2_2.8.19-1.dsc
etc-hosts.gz
famous.gz
fast-names.gz
female-names.gz
male-names.gz
myths-legends.gz
names.french.gz
names.hp.gz
other-names.gz
pass_file.gz
ry-threshold10.txt
sf.gz
shakespeare.gz
surnames.finnish.gz
13106 blocks
rpmソースを展開して辞書に関係しているファイルだけ残す。create-cracklib-dictコマンドで辞書を作ってみると、当然だがワード数もファイルサイズも同じものができあがった。
ll ./
合計 5824
-rw-rw-r-- 1 root root 678 10月 15 17:56 ASSurnames.gz
-rw-rw-r-- 1 root root 2501 10月 15 17:56 Congress.gz
-rw-rw-r-- 1 root root 1617 10月 15 17:56 Domains.gz
-rw-rw-r-- 1 root root 2074 10月 15 17:56 Dosref.gz
-rw-rw-r-- 1 root root 46264 10月 15 17:56 Family-Names.gz
-rw-rw-r-- 1 root root 2653 10月 15 17:56 Ftpsites.gz
-rw-rw-r-- 1 root root 23343 10月 15 17:56 Given-Names.gz
-rw-rw-r-- 1 root root 32363 10月 15 17:56 Jargon.gz
-rw-rw-r-- 1 root root 7049 10月 15 17:56 LCarrol.gz
-rw-rw-r-- 1 root root 116264 10月 15 17:56 Movies.gz
-rw-rw-r-- 1 root root 18486 10月 15 17:56 Paradise.Lost.gz
-rw-rw-r-- 1 root root 12138 10月 15 17:56 Python.gz
-rw-rw-r-- 1 root root 2081 10月 15 17:56 Trek.gz
-rw-rw-r-- 1 root root 668 10月 15 17:56 cartoon.gz
-rw-rw-r-- 1 root root 2792 10月 15 17:56 common-passwords.txt.gz
-rw-rw-r-- 1 root root 4515718 10月 15 17:56 cracklib-words-20080507.gz
-rw-rw-r-- 1 root root 45523 10月 15 17:56 etc-hosts.gz
-rw-rw-r-- 1 root root 2033 10月 15 17:56 famous.gz
-rw-rw-r-- 1 root root 6874 10月 15 17:56 fast-names.gz
-rw-rw-r-- 1 root root 12131 10月 15 17:56 female-names.gz
-rw-rw-r-- 1 root root 10116 10月 15 17:56 male-names.gz
-rw-rw-r-- 1 root root 5432 10月 15 17:56 myths-legends.gz
-rw-rw-r-- 1 root root 2482 10月 15 17:56 names.french.gz
-rw-rw-r-- 1 root root 153541 10月 15 17:56 names.hp.gz
-rw-rw-r-- 1 root root 18413 10月 15 17:56 other-names.gz
-rw-rw-r-- 1 root root 430855 10月 15 17:56 pass_file.gz
-rw-r--r-- 1 root root 424639 10月 15 17:56 ry-threshold10.txt
-rw-rw-r-- 1 root root 3167 10月 15 17:56 sf.gz
-rw-rw-r-- 1 root root 2653 10月 15 17:56 shakespeare.gz
-rw-rw-r-- 1 root root 1961 10月 15 17:56 surnames.finnish.gz
# create-cracklib-dict -o test.dict *
skipping line: 1
1840866 1840865
# ll test.dict.*
-rw-r--r-- 1 root root 1024 12月 3 09:02 test.dict.hwm
-rw-r--r-- 1 root root 8663484 12月 3 09:02 test.dict.pwd
-rw-r--r-- 1 root root 460232 12月 3 09:02 test.dict.pwi
まとめ
CentOS 7では、cracklibの辞書はRedHatの独自の拡張がされている様子。
そもそもcracklib-unpackerを使えば、オリジナルの辞書ファイルを入手する必要は無かったようにも感じる。