使用 sp64 工具程式產出馬可夫鏈模型的字典清單 (Word generator)

per-position Markov chain attack – 深入 hashcat 系列文章

by iok
發佈日期: 更新日期: 577 人次瀏覽
sp64

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

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

Markov chain (馬可夫鏈) 是一種隨機過程的統計機率模型,hashcat 應用馬可夫鏈加快破解速度,若對馬可夫鏈還不熟悉的讀者可以參考這篇文章

前 2 篇文章,我們介紹了如何使用 hcstatgenhcstat2gen 產生 hashcat 第一代與第二代馬可夫鏈統計資料模型的儲存格式。

這篇文章,要跟大家介紹如何使用 sp64 工具程式,產出馬可夫鏈模型的字典清單(word generator)。sp64 支援第 1 代元老級的馬可夫鏈模型 (hcstat),最長支援密碼長度到 64 個字元。

接下來,請大家跟我一起探索 sp64 工具程式,如何產出馬可夫鏈模型的字典清單吧!

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

Photo by Ian Livesey on StockSnap

sp64 簡介

sp64 是 hashcat 的 GitHub 專案 statsprocessor 所產出的工具程式。程式原始碼位於:https://github.com/hashcat/statsprocessor/blob/master/src/sp.c

基於 per-position 的馬可夫鏈 (Markov chain) 密碼產生器 (word generator),僅支援匯入第一代的馬可夫鏈統計資料模型的儲存格式(hcstatgen),最長支援密碼長度到 64 個字元。

kali Linux 使用者,請安裝 statsprocessor 套件,來使用 sp64 。安裝路徑在 /usr/bin/sp64 ,後續程式使用範例,為了縮短篇幅,統一使用 sp64 代替。

眼尖的讀者會發現 statsprocessor 套件,還有 1 個 sp32 的程式。但在 kali linux 這 2 支程式是完全相同。

sp64 的使用參數說明

sp64 指令使用方式如下:

$ sp64 [options]… hcstat-file [filter-mask]

hcstat-file 需使用 hcstatgen 程式產生馬可夫鏈統計資料模型檔案,比方說 hello.stat 。想知道如何產生 hello.stat,請參閱此篇文章

options (選項) 則支援程式參數,如下:

  • --pw-min=NUM :最小產出密碼長度
  • --pw-max=NUM :最大產出密碼長度,最長支援至 64 位
  • --output-file=FILE:輸出檔案名稱
  • --markov-disable:關閉馬可夫鏈統計模型功能,改為傳統暴力破解列舉
  • --markov-classic:傳統馬可夫鏈統計模型,不管字母所在位置(no per-position),把所有字母位置(第1 ~ 第64) 的機率全部加總計算
  • --threshold=NUM:印出前面<NUM>個字元就結束,不指定參數時,預設是全印,與hashcat --markov-threshold 功能相同
  • --combinations:印出排列組合的數量
  • --hex-charset:預設 filter-mask 或 –custom-charset1、–custom-charset2、–custom-charset3、–custom-charset4預設的輸入字元為 hex (16進位) 格式,例如
  • --skip=NUM:跳過印出多少字元
  • --limit=NUM:僅印出多少字元

至於 filter-mask 用法則是與此篇文章相同,在此不贅述。有興趣的讀者可自行參閱文中的 hashcat Mask Mode 一節。

sp64 的操作範例

  • 第 1 個範例,sp64 使用 3 個參數,第 1 個參數是 --pw-min,第 2 個參數是 --pw-max。第 3 個參數是 hcstatgen 產出的檔案名稱 (hcstat-file),比方說是 hello.stat。?l?l 是產出密碼的 mask,代表是 2 位數的小寫字母。

    就會依照 hello.stat 所紀錄的馬可夫鏈統計模型,從 1 位依序產出至 2 位的小寫字母字典檔。
$ sp64 --pw-min=1 --pw-max=2 hello.stat ?l?l
h
w
a
b
c
d
...
x
y
z
he
ho
ha
hb
...
zw
zx
zy
zz
  • 第 2 個範例,加上--threshold 參數 。可以觀察到當 threshold 設定時, sp64 程式就會不管 pw-max 的值了。
$ sp64 --pw-min=1 --pw-max=2 --threshold=2 hello.stat ?l?l
h
w
he
ho
we
wo

$ sp64 --pw-min=1 --pw-max=3 --threshold=2 hello.stat ?l?l
h
w
he
ho
we
wo

$ sp64 --pw-min=2 --pw-max=2 --threshold=2 hello.stat ?l?l
he
ho
we
wo
  • 第 3 個範例,加上 --combinations 參數。計算並印出排列組合的數量。
$ sp64 --combination hello.stat ?l
26

$ sp64 --combination hello.stat ?l?l
702

$ sp64 --combination hello.stat ?l?l?l
18278

$ sp64 --combination hello.stat ?l?l?l?l
475254
  • 第 4 個範例,加上 --skip 參數,印出結果。未加上 --skip 參數之前,會印出 26 個字元。
$ sp64 hello.stat ?l
h
w
a
b
c
d
e
f
g
i
j
k
l
m
n
o
p
q
r
s
t
u
v
x
y
z

加上 --skip = 1 ,少印出 h 字元,--skip = 2 ,少印出 h 與 w 字元。

$ sp64 hello.stat --skip=1 ?l
w
a
b
c
d
e
f
g
i
j
k
l
m
n
o
p
q
r
s
t
u
v
x
y
z

$ sp64 hello.stat --skip=1 ?l 
w
a
b
c
d
e
f
g
i
j
k
l
m
n
o
p
q
r
s
t
u
v
x
y
z
  • 第 5 個範例,加上 --limit 參數,會僅印出多少字元。
$ sp64 hello.stat --limit=1 ?l
h

$ sp64 hello.stat --limit=2 ?l
h
w

$ sp64 hello.stat --limit=3 ?l
h
w
a

結論

這篇文章介紹了 sp64,教大家如何操作 sp64 工具程式,產生第 1 代 hcstat (馬可夫鏈儲存格式) 的字典檔清單 (Word generator),可以產出快速的字典檔內容。

希望對讀者有幫助,若你喜歡這篇文章,請幫我分享給你的好朋友、社群媒體,並且在底下留言鼓勵我。期待在下篇,再與你見面。

相關文章

留言