LoginSignup
154
113

More than 3 years have passed since last update.

GPUでZIPパスワードを解析する

Last updated at Posted at 2019-12-05

GPUでZIPパスワードを解析する

企業間のファイルのやり取りにZIPファイルの暗号化がされていることが多いのですが、その暗号は意味がなかったり、弱かったり、余計にセキュリティリスクが高くなっています。ZIPの暗号化が使えないことを証明するにはパスワードを解析するのが一番です。

パスワードが解析できるなら、もうあとからパスワードを送る必要はないのです。

用意するもの

  • Windows PC
    Windows10を使いました。

  • GPU
    できる限り早いやつ
    ノートPCなので、外付けGPUケースにThunderbolt3でGPUを接続しています。
    GTX 2080とケースで 10万円ぐらいかかっています。

  • CUDA Toolkit
    あらかじめ入れておきましょう。

  • hashcat

hashcatのWindows版で公式サイトからダウンロードしたもので、バージョンが5.1.0の場合は古いので対応していません。

  • Windows版のJohn the ripper

から john the rippper の Windows binariesをダウンロードします。

事前準備 (最新版は対応済みのため不要)

hashcat.exe --help で実行して、 17210 のZIPが対応してれば不要です。 (6.1.1では対応を確認)

Windows用のバイナリはLinux上から作成します。Ubuntuでコンパイルします。WindowsからならWSLのUbuntuでコンパイル可能です。

$ git clone https://github.com/hashcat/hashcat.git
$ sudo apt install  mingw-w64 win-iconv-mingw-w64-dev
vim src/Makefile

の500行目ぐらいの

/opt/win-iconv-64

/usr/x86_64-w64-mingw32
にパスを変更します。

$ make win

hashcat.exeが生成されます。

対応しているハッシュのサンプル

番号 対象
13600 WinZip
17200 PKZIP (Compressed) *
17210 PKZIP (Uncompressed) *
17220 PKZIP (Compressed Multi-File) *
17225 PKZIP (Mixed Multi-File) *
17230 PKZIP (Compressed Multi-File Checksum-Only) *

ZIPファイルの暗号化は6種類ありますが、今回は 17210 です。
https://hashcat.net/wiki/doku.php?id=example_hashes

ハッシュの抽出

johnの中にzip2johnがあります。このプログラムがzipファイルからハッシュを取り出します。

zip2johnを使って暗号化された部分を抽出します。

C:\Users\...\john\run>zip2john.exe ..\..\testpass.zip
ver 2.0 testpass.zip/example500.hash PKZIP Encr: cmplen=47, decmplen=35, crc=6D73B418
testpass.zip/example500.hash:$pkzip2$1*1*2*0*2f*23*6d73b418*0*2d*0*2f*6d73*a033*73f283fe523fe65d3f981b0921d2a94a71f69d8c1686c2f0a5a1d62ec2402c8bb954dbb9cbef2372f560ec11f32f0e*$/pkzip2$:example500.hash:testpass.zip::..\..\testpass.zip

得られた結果から、$pkzip2の部分を抜き出し、zippass.txtに解析用ハッシュを書きます。

C:\..\hashcat> echo $pkzip2$1*1*2*0*2f*23*6d73b418*0*2d*0*2f*6d73*a033*73f283fe523fe65d3f981b0921d2a94a71f69d8c1686c2f0a5a1d62ec2402c8bb954dbb9cbef2372f560ec11f32f0e*$/pkzip2$ >zippass2.txt

hashcatを実行します

  • #1 GeForce RTX 2080
  • #2 Intel(R) UHD Graphics 620

と2つのGPUを使ってくれています。

GeForce RTX 2080では10GH/s
Intel UHD 620では 180MH/s

ぐらいのスピードが出ています。秒間100億回と1.8億回試していることになります。

オプションは、ブルートフォースモードで全力で8文字パスワードを評価しています。

C:\...\hashcat>hashcat.exe -a 3 -w 4 -m 17210 ..\..\zippass.txt ?a?a?a?a?a?a?a?a
hashcat (v5.1.0-1488-g52e83c22+) starting...

* Device #1: CUDA SDK Toolkit installation NOT detected.
             CUDA SDK Toolkit installation required for proper device support and utilization
             Falling back to OpenCL Runtime

* Device #1: WARNING! Kernel exec timeout is not disabled.
             This may cause "CL_OUT_OF_RESOURCES" or related errors.
             To disable the timeout, see: https://hashcat.net/q/timeoutpatch
OpenCL API (OpenCL 1.2 CUDA 10.2.95) - Platform #1 [NVIDIA Corporation]
=======================================================================
* Device #1: GeForce RTX 2080, 6656/8192 MB (2048 MB allocatable), 46MCU

OpenCL API (OpenCL 2.1 ) - Platform #2 [Intel(R) Corporation]
=============================================================
* Device #2: Intel(R) UHD Graphics 620, 6384/6448 MB (3224 MB allocatable), 24MCU
* Device #3: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz, skipped

Minimum password length supported by kernel: 0
Maximum password length supported by kernel: 256

Hashes: 1 digests; 1 unique digests, 1 unique salts
Bitmaps: 16 bits, 65536 entries, 0x0000ffff mask, 262144 bytes, 5/13 rotates

Applicable optimizers:
* Not-Iterated
* Single-Hash
* Single-Salt
* Brute-Force

Watchdog: Temperature abort trigger set to 90c

Host memory required for this attack: 1357 MB

[s]tatus [p]ause [b]ypass [c]heckpoint [q]uit =>

Session..........: hashcat
Status...........: Running
Hash.Name........: PKZIP (Uncompressed)
Hash.Target......: $pkzip2$1*1*2*0*2f*23*6d73b418*0*2d*0*2f*6d73*a033*...kzip2$
Time.Started.....: Thu Dec 05 16:48:19 2019 (5 secs)
Time.Estimated...: Thu Dec 12 23:51:23 2019 (7 days, 7 hours)
Guess.Mask.......: ?a?a?a?a?a?a?a?a [8]
Guess.Queue......: 1/1 (100.00%)
Speed.#1.........: 10338.5 MH/s (292.36ms) @ Accel:64 Loops:1024 Thr:1024 Vec:1
Speed.#2.........:   188.9 MH/s (259.90ms) @ Accel:64 Loops:128 Thr:256 Vec:1
Speed.#*.........: 10527.4 MH/s
Recovered........: 0/1 (0.00%) Digests
Progress.........: 59710111744/6634204312890625 (0.00%)
Rejected.........: 0/59710111744 (0.00%)
Restore.Point....: 0/7737809375 (0.00%)
Restore.Sub.#1...: Salt:0 Amplifier:19456-20480 Iteration:0-1024
Restore.Sub.#2...: Salt:0 Amplifier:2688-2816 Iteration:0-128
Candidates.#1....: ,lek$^&* -> WKYz,|**
Candidates.#2....: 8frerane -> Zma1Esan
Hardware.Mon.#1..: Temp: 39c Fan: 30% Util:100% Core:1980MHz Mem:6800MHz Bus:4
Hardware.Mon.#2..: N/A

$pkzip2$1*1*2*0*2f*23*6d73b418*0*2d*0*2f*6d73*a033*73f283fe523fe65d3f981b0921d2a94a71f69d8c1686c2f0a5a1d62ec2402c8bb954dbb9cbef2372f560ec11f32f0e*$/pkzip2$:dhu12345

あっという間に解読完了です。WordやExcelのパスワードなども解読できますが、新しいバージョンのものは固めになっています。

対策

zipで暗号化して送るのは会社間のプロトコルですので簡単には崩せません。ZIPパスワード形式にAESを使うとか、Officeファイルのパスワードを使ったほうがより強固です。

154
113
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
154
113