この大会は2019/12/21 1:00(JST)~2019/12/26 1:00(JST)に開催されました。
今回もチームで参戦。結果は81点で627チーム中90位でした。
自分で解けた問題をWriteupとして書いておきます。
Not A Flag (Misc 1)
Discordに入り、#informationタグを見ると、メッセージにフラグが書いてあった。
KAF{D1SC0RD_1S_9R3A7}
Tupper needs help (Misc 5)
タッパーの自己言及式の問題。https://takitamblog.tk/skrypty/Tupper/でkの値を入力し、グラフに表示させる。さらにGraph options and functionsで、Flip verticallyとFlip horizontallyを使って向きを変えると、フラグが表示された。
KAF{MY_KIPOD_IS_HUGE}
SmellyOnion (Misc 10)
$ file onion onion: Zip archive data, at least v2.0 to extract $ unzip onion Archive: onion 4b inflating: 80 $ unzip 80 Archive: 80 41 inflating: 62 $ unzip 62 Archive: 62 46 inflating: 53
何重にもZIP圧縮されていて、ZIPコメントにフラグの各文字のASCIIコードが16進数で入っている。それを文字にしてつなげていく。
import zipfile name = 'onion' flag = '' while True: try: with zipfile.ZipFile(name) as zf: flag += chr(int(zf.comment, 16)) name = zf.namelist()[0] zf.extractall('') except: break print flag
KAF{21P_PH1L32_R_AW3S0M3_D0NT_Y0U_TH1NK}
Dinary (Misc 15)
Stegsolveで開き、[Analyze]-[Data Extract]でRedのLSBにチェックを入れて、Previewを見る。すると文章が出てきて、フラグが書いてあった。
Hello World!, Yesterday my kipod went free and i can't find him! KAF{wh3r3_1s_my_k1p0d?} Maybe YOU can help me find my kipod? (his name is "Fibon") Hope you'll find him, he should go on a tour really soon.
KAF{wh3r3_1s_my_k1p0d?}
KipodStab (Web 5)
Apacheのデフォルト画面になっている。よくあるファイル、ディレクトリを探索してみる。
$ python3 dirsearch.py -u http://ctf.kaf.sh:3040/ -e php,html,txt _|. _ _ _ _ _ _|_ v0.3.9 (_||| _) (/_(_|| (_| ) Extensions: php, html, txt | HTTP method: get | Threads: 10 | Wordlist size: 6719 Error Log: /mnt/hgsf/Shared/logs/errors-19-12-25_12-44-54.log Target: http://ctf.kaf.sh:3040/ [12:44:54] Starting: [12:45:03] 403 - 199B - /.ht_wsr.txt [12:45:03] 403 - 199B - /.hta [12:45:03] 403 - 199B - /.htaccess-dev [12:45:03] 403 - 199B - /.htaccess-marco [12:45:03] 403 - 199B - /.htaccess.BAK [12:45:03] 403 - 199B - /.htaccess-local [12:45:03] 403 - 199B - /.htaccess.bak1 [12:45:03] 403 - 199B - /.htaccess.orig [12:45:03] 403 - 199B - /.htaccess.old [12:45:03] 403 - 199B - /.htaccess.sample [12:45:03] 403 - 199B - /.htaccess.save [12:45:03] 403 - 199B - /.htaccess_orig [12:45:03] 403 - 199B - /.htaccess_sc [12:45:03] 403 - 199B - /.htaccess.txt [12:45:03] 403 - 199B - /.htaccessBAK [12:45:03] 403 - 199B - /.htaccessOLD [12:45:03] 403 - 199B - /.htaccessOLD2 [12:45:03] 403 - 199B - /.htaccess_extra [12:45:03] 403 - 199B - /.htaccess~ [12:45:03] 403 - 199B - /.htgroup [12:45:04] 403 - 199B - /.htpasswd-old [12:45:04] 403 - 199B - /.htpasswd_test [12:45:04] 403 - 199B - /.htpasswds [12:45:04] 403 - 199B - /.htusers [12:46:50] 200 - 107B - /Dockerfile [12:47:09] 301 - 237B - /icons -> http://ctf.kaf.sh:3040/icons/ [12:47:13] 200 - 9KB - /index.html Task Completed
Dockerfileはアクセスできそう。
$ curl http://ctf.kaf.sh:3040/Dockerfile FROM httpd:alpine WORKDIR /usr/local/apache2/htdocs/ COPY . . # Flag is KAF{dOn7_5748_doCK3R_CON741n3R2}
KAF{dOn7_5748_doCK3R_CON741n3R2}
BackHash (Crypto 10)
ハッシュの結果にf1a9が含まれていると、フラグに置き換えられるらしい。いろいろ試したところ、入力文字長によりハッシュのアルゴリズムが変わる。
長さ % 3 == 0 の場合 md5 長さ % 3 == 1 の場合 sha1 -> md5 長さ % 3 == 2 の場合 base64 -> sha1 -> md5
ブルートフォースで条件を満たすものを探す。
from hashlib import md5, sha1 from base64 import b64encode import string import itertools found = False for r in range(1, 5): for c in itertools.product(string.printable, repeat=r): text = ''.join(c) if r % 3 == 0: h = md5(text).hexdigest() elif r % 3 == 1: h = md5(sha1(text).hexdigest()).hexdigest() else: h = md5(sha1(b64encode(text)).hexdigest()).hexdigest() if 'f1a9' in h: found = True print '"' + text + '"' print h break if found: break
実行結果は以下の通り。
"A " 78f1a945e13a76042a4f9c6a5570197f
"A "("を除く)を入力すると、フラグが表示された。
KAF{Dn4k_f1a9z___much_f1a9_l0t5_h4ppy}
SmpleKye (Crypto 10)
AA :提示された2文字 BBB+:入力文字3文字以上
AABBB+のsha256に、BBB+と同じ値が入っているとフラグが表示されるらしい。ブルートフォースで条件を満たすものを探す。この際、短い文字列で見つからない場合はAAを別の値にして再度試す。
以下は4dが提示されたときのコード。
from hashlib import sha256 import string import itertools found = False for r in range(3, 6): for c in itertools.product(string.hexdigits[:16], repeat=r): text = '4d' + ''.join(c) h = sha256(text).hexdigest() if text in h: found = True print '"' + text + '"' print h break if found: break
実行結果は以下の通り。
"4d626d" 8790967735e5eccadbd6100f389e2cd1b3a839dab2a4d626d78c7835dd598e40
626dを入力すると、フラグが表示された。
KAF{ju57_4_51mpl3_pr00F_0F_w0Rk}