【注意】このサイトに記載されていることを他人に試すことは「不正アクセス禁止法」に該当する場合があります。詳しくはこちらから

ハッカーはCrunchを使い指定した文字情報でワードリストを作成する(Kali Linux)

ホワイトハッカーの知識座学,Kali Linuxツール,Crunch

指定した文字情報でワードリストを作成する方法を理解するためにまとめてみました。
Crunchの動作確認は自分のローカルテスト環境で行っています。(VM VirtualBox)

Crunchとは

Crunchは、標準的な文字セットや、指定した文字セットを指定できるワードリスト作成ツールです。
総当り用のパスワードリストなどが簡単に作成できます。

Crunchで作成したファイルは主にHydraの入力ファイルとして使用されます。たとえば、ログイン名ファイルとパスワードファイルを生成させて不正アクセスを試みます。

機能

  • crunchは組み合わせと順列の両方の方法でワードリストを生成する
  • 出力を行数やファイルサイズで分割できる
  • レジュームのサポート
  • パターンが数字と記号をサポート
  • パターンが大文字と小文字を別々にサポートするようになりました
  • 複数のファイルを生成する際にステータスレポートを表示
  • 「@」,「%^」のリテラルをサポートする新しい"-l"オプションを追加しました
  • 重複する文字を制限する新しい-dオプションを追加しました
  • unicodeのサポート

ツールの場所

[Applications]→[05-Password Attacks]→[Password Profiling & Wordlists]→[Crunch]

ツールと使用方法

crunch <最小文字数> <最大文字数> [options]

例 crunch 1 3 01234567890 -o password.txt

【実行イメージ】少し端折って整形しています。

┌──(kali__kali)-[~]
└─$ crunch 1 3 01234567890 -o password.txt
Crunch will now generate the following amount of data: 4320 bytes
0 MB
0 GB
0 TB
0 PB
Crunch will now generate the following number of lines: 1110

┌──(kali__kali)-[~]
└─$ cat password.txt

0
1
2
3
:
:
997
998
999

オプション(GENERAL OPTIONS)

-h

このヘルプメッセージを表示して終了します。

-b number[type]

Specifies the size of the output file, only works if -o START is used, i.e.: 60MB
The output files will be in the format of starting letter-ending letter for example: ./crunch 4 5 -b 20mib -o START will generate 4 files: aaaa-gvfed.txt, gvfee-ombqy.txt, ombqz-wcydt.txt, wcydu-zzzzz.txt valid values for type are kb, mb, gb, kib, mib, and gib. The first three types are based on 1000 while the last three types are based on 1024. NOTE There is no space between the number and type.
For example 500mb is correct 500 mb is NOT correct.

出力ファイルのサイズを指定します。-o STARTを使用した場合のみ有効です。
例えば、"crunch 4 5 -b 20mib -o START"では、aaaaa-gvfed.txt, gvfee-ombqy.txt, ombqz-wcydt.txt, wcydu-zzzz.txtの4つのファイルが生成されます。 最初の3つのタイプは1000を基準にしており、最後の3つのタイプは1024を基準にしています。 注:数字とタイプの間にスペースはありません。
例えば、「500mb」は正しく、「500 mb」は正しくありません。

┌──(kali__kali)-[~]
└─$ crunch 4 5 -b 20mib -o START
Crunch will now generate the following amount of data: 73573136 bytes
70 MB
0 GB
0 TB
0 PB
Crunch will now generate the following number of lines: 12338352
crunch: 28% completed generating output
crunch: 57% completed generating output
crunch: 85% completed generating output
crunch: 100% completed generating output

┌──(kali__kali)-[~]
└─$ ls
aaaa-gvfed.txt ombqz-wcydt.txt
gvfee-ombqy.txt wcydu-zzzzz.txt

-c number

Specifies the number of lines to write to output file, only works if -o START is used, i.e.: 60 The output files will be in the format of starting letter-ending letter for example: ./crunch 1 1 -f /pentest/password/crunch/charset.lst mixalpha-numeric-all-space -o START -c 60 will result in 2 files: a-7.txt and 8-\ .txt The reason for the slash in the second filename is the ending character is space and ls has to escape it to print it. Yes you will need to put in the \ when specifying the filename because the last character is a space.

出力ファイルに書き込む行数を指定します。-o STARTが使用されている場合にのみ機能します。
例:60出力ファイルは、開始文字と終了文字の形式になります。
“crunch 1 1 -f /usr/share/crunch/charset.lst mixalpha-numeric-all-space -o START -c 60″は、a-7.txtと8- \ .txtの2つのファイルになります。2番目のファイル名のスラッシュの理由は終了文字です。 はスペースであり、lsはそれを印刷するためにエスケープする必要があります。 はい、最後の文字はスペースであるため、ファイル名を指定するときに\を入力する必要があります。

┌──(kali__ali)-[~]
└─$ crunch 1 1 -f /usr/share/crunch/charset.lst mixalpha-numeric-all-space -o START -c 60
Crunch will now generate the following amount of data: 120 bytes
0 MB
0 GB
0 TB
0 PB
Crunch will now generate the following number of lines: 60
crunch: 100% completed generating output
crunch: 158% completed generating output

┌──(kali__kali)-[~]
└─$ ls
'8- .txt' a-7.txt

-d numbersymbol

Limits the number of duplicate characters. -d 2@ limits the lower case alphabet to output like aab and aac. aaa would not be generated as that is 3 consecutive letters of a. The format is number then symbol where number is the maximum number of consecutive characters and symbol is the symbol of the the character set you want to limit i.e. @,%^ See examples 17-19.

重複する文字の数を制限します。 -d 2 @は、小文字のアルファベットをaabやaacのように出力するように制限します。 aaaは、aの3つの連続した文字であるため、生成されません。 形式はnumberthen symbolです。ここで、numberは連続する文字の最大数であり、symbolは制限する文字セットの記号です。つまり@、%^。

Example 1

┌──(kali__kali)-[~]
└─$ crunch 5 5 -d 2@ -t @@@%% -o example1.txt
Crunch will now generate the following amount of data: 10530000 bytes
10 MB
0 GB
0 TB
0 PB
Crunch will now generate the following number of lines: 1755000

crunch: 100% completed generating output
┌──(kali__kali)-[~]
└─$ cat example1.txt | more
aab00
aab01
aab02
aab03
aab04
aab05
aab06
:
:
zzy97
zzy98
zzy99

crunch will generate 5 character strings staring with aab00 and ending at zzy99. Notice that aaa and zzz are not present.

crunchは、aab00で始まり、zzy99で終わる5文字の文字列を生成します。 aaaとzzzは存在しないことに注意してください。

Example 2

┌──(kali__kali)-[~]
└─$ crunch 10 10 -t @@@^%%%%^^ -d 2@ -d 3% 20mb -o START | more
Crunch will now generate the following amount of data: 69307002121500 bytes
66096307 MB
64547 GB
63 TB
0 PB
Crunch will now generate the following number of lines: 6300636556500
aab!0001!!
aab!0001!@
aab!0001!#
aab!0001!$
aab!0001!%
aab!0001!^
aab!0001!&
aab!0001!*
:
:

crunch will generate 10 character strings starting with aab!0001!! and ending at zzy 9998 The output will be written to 20mb files.

crunchは、aab!0001!!!で始まり、zzy 9998で終わる10文字の文字列を生成します。出力は20MBのファイルに書き込まれます。

Example 3

┌──(kali__kali)-[~]
└─$ crunch 8 8 -d 2@ -o example3.txt
Crunch will now generate the following amount of data: 1863320062500 bytes
1777000 MB
1735 GB
1 TB
0 PB
Crunch will now generate the following number of lines: 207035562500

crunch: 0% completed generating output
:

┌──(kali㉿kali)-[~]
└─$ cat START | more 8 ⚙
aabaabaa
aabaabab
aabaabac
aabaabad
aabaabae
:
※すごい時間がかかりました。

crunch will generate 8 characters that limit the same number of lower case characters to 2. Crunch will start at aabaabaa and end at zzyzzyzz.
crunchは、同じ数の小文字を2つに制限した8つの文字を生成します。Crunchは、aabaabaaで始まり、zzyzzyzzで終わります。

-e string

Specifies when crunch should stop early.
クランチが早期に停止するタイミングを指定します。

-f /path/to/charset.lst charset-name

Specifies a character set from the charset.lst
charset.lstから文字セットを指定する。

-i

Inverts the output so instead of aaa,aab,aac,aad, etc you get aaa,baa,caa,daa,aba,bba,etc.
出力を反転して、aaa,aab,aac,aadなどの代わりにaaa,baa,caa,daa,aba,bbaなどを表示します。

-l

When you use the -t option this option tells crunch which symbols should be treated as literals.
This will allow you to use the placeholders as letters in the pattern.
The -l option should be the same length as the -t option. See example 15.
tオプションを使用した場合、このオプションは、どのシンボルをリテラルとして扱うかをクランチに伝えます。
これにより、プレースホルダーをパターンの文字として使用することができます。
lオプションは、-tオプションと同じ長さでなければなりません。例15を参照してください。

Example 1

┌──(kali__kali)-[~]
└─$ crunch 7 7 -t p@ss,%^ -l a@aaaaa | more
Crunch will now generate the following amount of data: 68640 bytes
0 MB
0 GB
0 TB
0 PB
Crunch will now generate the following number of lines: 8580
p@ssA0!
p@ssA0@
p@ssA0#
p@ssA0$
p@ssA0%
p@ssA0^
p@ssA0&
p@ssA0*
:
:

crunch will now treat the @ symbol as a literal character and not replace the character with a uppercase letter. this will generate.
crunchは、@記号をリテラル文字として扱い、その文字を大文字に置き換えないようになりました。

-m

Merged with -p. Please use -p instead.
pに統合されました。 代わりに-pをお使いください。

-o wordlist.txt

Specifies the file to write the output to, eg: wordlist.txt
出力先のファイルを指定します(例:wordlist.txt)

-p charset OR -p word1 word2 …

Tells crunch to generate words that don’t have repeating characters. By default crunch will generate a wordlist size of #of_chars_in_charset ^ max_length. This option will instead generate #of_chars_in_charset!. The ! stands for factorial.
For example say the charset is abc and max length is 4.. Crunch will by default generate 3^4 = 81 words. This option will instead generate 3! = 3x2x1 = 6 words(abc,acb,bac,bca,cab,cba). THIS MUST BE THE LAST OPTION! This option CANNOT be used with -s and it ignores min and max length however you must still specify two numbers.
繰り返す文字を持たない単語を生成するようにcrunchに指示する。
デフォルトでは、crunchは#of_chars_in_charset ^ max_lengthのワードリストサイズを生成します。このオプションは代わりに #of_chars_in_charset! を生成します。!は階乗を表しています。
例えば、charsetがabcで、最大長が4だとします。 Crunchはデフォルトで3^4 = 81ワードを生成します。 このオプションは、代わりに 3! = 3x2x1 = 6 単語(abc, acb, bac, bca, cab, cba)を生成します。 これは最後のオプションでなければなりません。 このオプションは、-sと一緒に使うことはできません。また、最小長と最大長は無視されますが、2つの数字を指定する必要があります。

-q filename.txt

Tells crunch to read filename.txt and permute what is read. This is like the -p option except it gets the input from filename.txt.
crunchにfilename.txtを読み込ませ、読み込んだ内容をパーミュレートするように指示します。 これは、filename.txtから入力を得ることを除けば、-pオプションのようなものです。

-r

Tells crunch to resume generate words from where it left off. -r only works if you use -o.
You must use the same command as the original command used to generate the words. The only exception to this is the -s option. If your original command used the -s option you MUST remove it before you resume the session. Just add -r to the end of the original command.
crunchが単語生成を中断したところから再開するように指示します。 -rは、-oを使用した場合にのみ機能します。
単語を生成するために使用した元のコマンドと同じコマンドを使用しなければなりません。唯一の例外は -s オプションです。元のコマンドに-sオプションが使用されていた場合、セッションを再開する前にそれを削除しなければなりません。元のコマンドの最後に-rを追加してください。

-s startblock

Specifies a starting string, eg: 03god22fs.
開始文字列を指定します。(例:03god22fs)

-t @,%^

Specifies a pattern, eg: @@god@@@@ where the only the @’s, ,’s, %’s, and ^’s will change.
@ will insert lower case characters.
, will insert upper case characters.
% will insert numbers.
^ will insert symbols.
パターンを指定します。@@god@@@@ ここでは、@、 , 、 % 、 ^ の部分のみが変更されます。
「@」は小文字を挿入します。
「,」大文字を挿入します。
「%」は、数字を挿入します。
「^」は記号を挿入します。

-u

The -u option disables the printpercentage thread. This should be the last option.
uオプションは、printpercentageスレッドを無効にします。 これは最後のオプションにしてください。

-z gzip, bzip2, lzma, and 7z

Compresses the output from the -o option. Valid parameters are gzip, bzip2, lzma, and 7z.
gzip is the fastest but the compression is minimal. bzip2 is a little slower than gzip but has better compression. 7z is slowest but has the best compression.
oオプションの出力を圧縮します。 有効なパラメータは gzip, bzip2, lzma, 7z です。
bzip2 は gzip より少し遅いですが、圧縮率はより高くなります。 7zは最も遅いが、圧縮率は最も高い。

Crunchツールのまとめ

Crunchツールで任意の文字列を作成する機能なら、Excelでも代用は可能だとおもっていました。
しかし、オプション機能を確認すると単語リストを作成するための優れたツールだということがわかりました。

使い方はややこしいですが、この文字列なら脆弱なパスワード確認できそうですね。