[Mac] Zip 密碼忘記了!用 John the Ripper 暴力破解

[Mac] Zip 密碼忘記了!用 John the Ripper 暴力破解

最近有個 zip 檔案,密碼忘記是什麼了,

想說就拿個破解工具來試試~

看到 John the Ripper 這個工具蠻多人推薦使用,就來試一試吧~

 

參考資料:Crack (ZIP) passwords with John the Ripper

 

1. 安裝 John the Ripper

在 Mac 上用 Homebrew 就可以把 John the Ripper 裝好,

用 brew 可以找到 john 和 john-jumbo 兩個套件,

既然 john-jumbo 寫說是 john 的加強版,自然是裝 john-jumob 囉:

brew install john-jumbo

 

2. 產生 zip 的 hash 檔

要使用 John the Ripper 猜密碼前,得先產生 zip 檔的 hash 值,

這個工作可以用 john-jumbo 附的 zip2john 達成~

不過用 Homebrew 裝起來的話,

只有 john 可以在 PATH 裡找到,zip2john 是不行的~

用 brew list john-jumbo 可以看到相關的路徑,

像我的是在 /usr/local/Cellar/john-jumbo/1.8.0/share/john/zip2john,

執行 zip2john ZIP_FILE > ZIP_HASH 來產生 hash 檔:

testuser@localhost ~ $ /usr/local/Cellar/john-jumbo/1.8.0/share/john/zip2john test.zip > test.john
ver 14  efh 5455  efh 7875  test.zip->DownloadFile.class PKZIP Encr: 2b chk, TS_chk, cmplen=1452, decmplen=2423, crc=15767577

 

這個 hash 檔的內容像是下面這樣:

test.zip:$pkzip2$1*2*3*0*5ac*977*15767577*0*4c*8*8*1576*58d2*test.zip*$/pkzip2$:::::test.zip

 

3. 使用 John the Ripper 來猜密碼

執行 john –incremental ZIP_HASH 來開始暴力破解…

這個動作的時間有可能會非常非常久… 

而我拿來舉例的這個 test.zip 的密碼事實上是 12345,

John 大概是有內建一些預設密碼 (或是會先試短數字類的?),

所以相當快就找到密碼了:

testuser@localhost ~ $ john --incremental test.john
Loaded 1 password hash (PKZIP [32/64])
Press 'q' or Ctrl-C to abort, almost any other key for status
12345            (test.zip)
1g 0:00:00:00 DONE (2015-06-30 00:22) 3.333g/s 213.3p/s 213.3c/s 213.3C/s 123456..112234
Use the "--show" option to display all of the cracked passwords reliably
Session completed

 

猜到密碼的話,用 john –show ZIP_HASH 就能看到猜出來的密碼了:

testuser@localhost ~ $ john --show test.john
test.zip:12345:::::test.zip
1 password hash cracked, 0 left

 

不過 John 似乎並不是一定先嘗試短的密碼,

像我將密碼設成 PaS$ 這樣 4 個字元,結果 John 找了好久都還沒成功…

(本頁面已被瀏覽過 7,733 次)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料