深入 hashcat 系列:Combinator Attack Mode

by iok
發佈日期: 更新日期: 1.5K 人次瀏覽
深入 hashcat 系列:Combinator Attack Mode

前言

hashcat 是一套開源 (MIT License) 的離線密碼破解軟體,還能利用顯示卡 GPU 加快破解速度。其官網宣稱是「世界上最快的密碼破解工具」,廣泛支援許多常用的雜湊值演算法,以及破解攻擊模式。

「深入 hashcat 系列」是針對想要深耕資安領域的你,所撰寫的一系列文章。每篇文章針對 hashcat 其中一個參數、參數值或功能,進行說明,並搭配實做指令範例,幫助你快速掌握 hashcat 。

在上一篇我們提到了 Straight Mode (字典攻擊模式),讓使用者能使用字典檔進行密碼破解。這一篇,我們來介紹 Combinator Attack Mode,能組合 2 個字典檔進行破解,並套用至 hashcat 進行比對,確認密碼是否為字典檔中的單字。

*請留意文章中提到的工具軟體,請在授權環境下執行測試與使用,禁止在非授權環境下執行!

Photo by Michael Sum on Unsplah

正文

人取密碼的時候,有時喜歡用英文名字加上生日組合。針對這種情形,用 Hashcat 破解密碼時,就可以使用 Combinartor Attack (參數 -a 1) 攻擊模式(Attack Mode) ,讓 hashcat 將 2 個字典檔合併在一起後,進行破解。或是加入 --stdout參數產出字典檔。

舉例來說,英文名字字典檔,擷取美國國家社會安全局網頁公告 1922 年到 2021 年 100 個美國最常見的名字,依字母順序排列如下:

Aaron
Adam
Alan
...
William
Willie
Zachary

ref: https://www.ssa.gov/oact/babynames/decades/century.html

365天的生日列表如下:

0101
0102
0103
...
1228
1229
1230
1231

若是僅想用 hashcat 產生組合字典檔,指令如下。關鍵參數是 --stdout,讓 hashcat 只產生字典檔,不進行破解。

$ hashcat -a 1 name.txt date.txt --stdout > name-date.txt
$ cat name-date.txt
Aaron0101
Aaron0102
Aaron0103
Aaron0104
Aaron0105
...
Zachary1227
Zachary1228
Zachary1229
Zachary1230
Zachary1231

產生完的字典檔,再用先前文章提到的 Straight Mode (-a 0),就可以進行破解了。

假如,我們要破解的密碼是 George0502,MD5 雜湊值是 b607418f5aa54e5a7d6b99b18c0cd87a

$ echo -n "George0502" |md5sum |sed -e 's/  -//g'> hash.txt
$ cat hash.txt
b607418f5aa54e5a7d6b99b18c0cd87a

要使用 hashcat 的 Combinator Attack Mode ,不產生字典檔,直接進行破解,指令執行結果參考如下:

$ hashcat -a 1 hash.txt name.txt date.txt
hashcat (v5.1.0) starting...

...
Dictionary cache hit:
* Filename..: name.txt
* Passwords.: 100
* Bytes.....: 672
* Keyspace..: 100

Dictionary cache hit:
* Filename..: date.txt
* Passwords.: 341
* Bytes.....: 1705
* Keyspace..: 341
...
Dictionary cache hit:
* Filename..: name.txt
* Passwords.: 100
* Bytes.....: 672
* Keyspace..: 34100

b607418f5aa54e5a7d6b99b18c0cd87a:George0502

Session..........: hashcat
Status...........: Cracked
Hash.Type........: MD5
Hash.Target......: b607418f5aa54e5a7d6b99b18c0cd87a
Time.Started.....: Sat Sep  3 15:21:10 2022 (0 secs)
Time.Estimated...: Sat Sep  3 15:21:10 2022 (0 secs)
Guess.Base.......: File (name.txt), Left Side
Guess.Mod........: File (date.txt), Right Side
Speed.#1.........: 17557.9 kH/s (0.10ms) @ Accel:128 Loops:42 Thr:256 Vec:1
Recovered........: 1/1 (100.00%) Digests, 1/1 (100.00%) Salts
Progress.........: 12600/34100 (36.95%)
Rejected.........: 0/12600 (0.00%)
Restore.Point....: 0/100 (0.00%)
Restore.Sub.#1...: Salt:0 Amplifier:84-126 Iteration:0-42
Candidates.#1....: Aaron0323 -> Zachary0502
Hardware.Mon.#1..: Temp: 39c Util: 40% Core:1032MHz Mem:2505MHz Bus:16

執行結果中,出現的第三次的 Dictionary cache hit 有提到 Keyspace:34100,即代表兩個字典檔組合後有 34100 個密碼,進行爆破。

結語

hashcat 是如此強大,可以讓我們組合兩個字典檔,進行暴力密碼破解。如果你喜歡這篇文章,.請幫我分享文章給你的朋友,並且留言鼓勵我。也歡迎你繼續瀏覽 深入 hashcat 系列其他文章。

參考文獻:

相關文章

留言