DEFCON CTF 2009 Crypto 300
If your gang's pretty good, you'll work your way in.
http://shallweplayaga.me/crypto/354d8654372c0e5fff66803da7d9dfed
まず何のファイルか確認
$ file 354d8654372c0e5fff66803da7d9dfed 354d8654372c0e5fff66803da7d9dfed: tcpdump capture file (little-endian) - version 2.4 (Ethernet, capture length 65535)
パケットファイルなのでwiresharkで確認するとHTTP通信が行われている
HTTPヘッダが特殊で "Content-Length: \r\n\t159\r\n" という感じ
RFC的には2行目以降の行の先頭にタブを入れれば複数行にまたがるヘッダもOK
$ hexdump -C 354d8654372c0e5fff66803da7d9dfed 00001510 20 17 50 f5 16 65 6e 74 2d 4c 65 6e 67 74 68 3a | .P..ent-Length:| 00001520 0d 0a 09 31 35 39 0d 0a 43 6f 6e 6e 65 63 74 69 |...159..Connecti| 00001530 6f 6e 3a 0d 0a 09 63 6c 6f 73 65 0d 0a 0d 0a 1f |on:...close.....| 00001540 8b 08 00 7b 07 20 4a 02 03 01 88 00 77 ff 1f 8b |...{. J.....w...|
サーバから159バイトのデータが送られているので取り出す
$ hexdump -C data 00000000 1f 8b 08 00 7b 07 20 4a 02 03 01 88 00 77 ff 1f |....{. J.....w..| 00000010 8b 08 18 32 02 20 4a 00 03 73 70 6f 6f 6e 00 d5 |...2. J..spoon..| 00000020 c4 84 31 1e 49 4a 8f 94 5a 9b 77 c3 49 df 94 00 |..1.IJ..Z.w.I...| 00000030 01 5a 00 a5 ff 8c 0d 04 03 03 02 d1 da e6 68 76 |.Z............hv| 00000040 56 41 34 60 c9 49 73 cb 86 35 89 d7 bf 58 ab 5b |VA4`.Is..5...X.[| 00000050 a2 40 fb b8 70 73 91 82 44 bc f7 d1 9a a3 29 09 |.@..ps..D.....).| 00000060 53 2c 0c 48 4e d6 da 04 23 d3 0a 24 b8 3a eb b1 |S,.HN...#..$.:..| 00000070 76 86 c1 5f b1 da cf af a3 67 04 72 6a ea 45 10 |v.._.....g.rj.E.| 00000080 45 f9 29 e3 a2 a7 63 e9 41 b4 e2 b2 a7 7b 47 f5 |E.)...c.A....{G.| 00000090 6d 28 cf 5a 00 00 00 06 ed 23 a6 88 00 00 00 |m(.Z.....#.....| $ file data data: gzip compressed data, from Unix, last modified: Sat May 30 01:04:11 2009, max compression
送られているのはgzipで圧縮されたファイル
gzipで展開する
$ mv data data.gz $ gzip -d data.gz $ file data data: gzip compressed data, was "spoon", has comment, from Unix, comment, last modified: Sat May 30 00:41:38 2009
展開したら再びgzipで圧縮されたファイルとなる
今度はファイル名"spoon"、コメント有、らしい
GZIPファイルフォーマット
http://www.gzip.org/zlib/rfc-gzip.html
$ hexdump -C data 00000000 1f 8b 08 18 32 02 20 4a 00 03 73 70 6f 6f 6e 00 |....2. J..spoon.| 00000010 d5 c4 84 31 1e 49 4a 8f 94 5a 9b 77 c3 49 df 94 |...1.IJ..Z.w.I..| 00000020 00 01 5a 00 a5 ff 8c 0d 04 03 03 02 d1 da e6 68 |..Z............h|
ファイル名:73 70 6f 6f 6e(spoon)
コメント :d5 c4 84 31 1e 49 4a 8f 94 5a 9b 77 c3 49 df 94
再び展開する
$ cp data spoon.gz $ gzip -d spoon.gz $ file spoon spoon: data $ hexdump -C spoon 00000000 8c 0d 04 03 03 02 d1 da e6 68 76 56 41 34 60 c9 |.........hvVA4`.| 00000010 49 73 cb 86 35 89 d7 bf 58 ab 5b a2 40 fb b8 70 |Is..5...X.[.@..p| 00000020 73 91 82 44 bc f7 d1 9a a3 29 09 53 2c 0c 48 4e |s..D.....).S,.HN| 00000030 d6 da 04 23 d3 0a 24 b8 3a eb b1 76 86 c1 5f b1 |...#..$.:..v.._.| 00000040 da cf af a3 67 04 72 6a ea 45 10 45 f9 29 e3 a2 |....g.rj.E.E.)..| 00000050 a7 63 e9 41 b4 e2 b2 a7 7b 47 |.c.A....{G| 0000005a
展開したらただのデータ列
暗号の問題(Crypto 300)であるため暗号文だと推測
gpgに渡してみる
$ gpg spoon gpg: CAST5暗号化済みデータ パスフレーズを入力: gpg: 1 個のパスフレーズで暗号化 gpg: 復号に失敗しました: 鍵が不正です
復号にはパスワードが必要
コメントに謎のデータ列があったためそれを使用
パスワードに"d5c484311e494a8f945a9b77c349df94"を入力
$ gpg spoon gpg: CAST5暗号化済みデータ gpg: 1 個のパスフレーズで暗号化 gpg: spoon: 未知の拡張子 新しいファイル名を入力してください [spoon]: spoon2 gpg: 警告: メッセージの完全性は保護されていません $ cat spoon2 The eggs are not a lie. NOT A LIE. The eggs are not a lie. NOT A LIE. The eggs are not a lie. NOT A LIE. ....
この"The eggs are not a lie. NOT A LIE."が答え