NahamCon CTF (in 2020) writeup
NahamCon CTF、2人チームで参加しました。
1570ポイントで257位でした。300位以内目指していたので嬉しい。
mobile全部解きたかった…。相方もOSINT全部解きたかったと申しておりました。
web, crypt, pwnは勉強しなければ…。
相方のも含めてWriteup書きます。
Agent 95
普通にアクセスするともっと古いWindowsでアクセスしろと言われる。
Agent 95はWindows 95のユーザエージェントという意味だと思ったのでそれを指定。
$ curl -H "User-Agent: Mozilla/4.0 (compatible; MSIE 4.0; Windows 95)" "http://jh2i.com:50000/" flag{user_agents_undercover} (snip)
flag{user_agents_undercover}
Localghost
トップページとghost.htmlには特に怪しい点はない。
/jquery.jscroll2.jsというファイルを読み込んでいて、jqueryにそんなファイルあったか?と思って見てみたら
Hexエンコードされた文字列があったので、デコードしてみたら"flag"と難読化された文字列があったので、更にデコードするとフラグ。
flag: JCTF{spoooooky_ghosts_in_storage}
Voltex
接続すると大量のバイトが流れてくるが、その中にflagが紛れている。
from pwn import * conn = remote('jh2i.com', 50017) s = conn.recvuntil('flag') flag = conn.recvuntil('}') print('flag' + flag.decode('utf-8'))
flag: flag{more_text_in_the_vortex}
Candroid
dex2jarでデコンパイルすると、password.txtの内容と比較して合っていればflagを表示するアプリということがわかった。
表示するflagはリソースのstringsに入っているようなので、apktoolでリソースをデコンパイルした。
$ apktool d candroid.apk $ cd res $ grep -r "flag" .
flag: flag{4ndr0id_1s_3asy}
Read The Rules
ruleページのソースにある。
flag: flag{we_hope_you_enjoy_the_game}
CLIsay
stringsをかけると2つに分かれたフラグ文字列が確認できるのでくっつける。
flag: flag{Y0u_c4n_r3Ad_M1nd5}
Metameme
メタ情報を見ろとのこと。
$ exiftool hackermeme.jpg (snip) Creator : flag{N0t_7h3_4cTuaL_Cr3At0r} (snip)
flag: flag{N0t_7h3_4cTuaL_Cr3At0r}
Mr. Robot
/robots.txtにフラグ。
flag: flag{welcome_to_robots.txt}
UGGC
どんなusernameを入力してもログインできるが、adminだけ拒否される。
ログインするとユーザ名が換字暗号?されたcookieがセットされるので、cookieを"nqzva"に書き換えてリロードするとフラグ。
flag: flag{H4cK_aLL_7H3_C0okI3s}
Pang
pngを開くだけ。crcがおかしいけど…
flag: flag{wham_bam_thank_you_for_the_flag_maam}
Doh
steghideで。
$ steghide extract -sf doh.jpg Enter passphrase: wrote extracted data to "flag.txt". $ cat flag.txt JCTF{an_annoyed_grunt}
flag: JCTF{an_annoyed_grunt}
Time keeper
Webアーカイブでapporima.comを検索すると、4/18時点のアーカイブがあり、/flag.txtがあると書かれている。
現在のURLではアクセスできないが、webアーカイブ上では/flag.txtを閲覧することができる。
flag: JCTF{the_wayback_machine}
Ends Meet
見るべき場所は、このアプリ独特のクラス。今回で言うとcom.example.endsmeet配下。
MainActivity.classを見ると、urlとbase64エンコードされたパスがある。
合わせるとhttp://jh2i.com:50038/api/v2/data
になる。
Something seems to be off. Your User Agent does not seem to match the default user agent for the HTTP Library used in the app.
ブラウザでアクセスするとユーザエージェントがライブラリのデフォルトのものじゃないと言われる。親切。
Volleyを使っているようなので調べると、VolleyのデフォルトのUAは"volley/0"らしい。
$ curl -H "User-Agent: volley/0" "http://jh2i.com:50038/api/v2/data" flag{rev3rsIng_ApKs_l1k3_A_Pr0}
flag: flag{rev3rsIng_ApKs_l1k3_A_Pr0}
Volatile
メモリイメージ。タイトル通りVolatilityを使う。
$ vol.py -f memdump.raw imageinfo Volatility Foundation Volatility Framework 2.6.1 INFO : volatility.debug : Determining profile based on KDBG search... Suggested Profile(s) : Win7SP1x86_23418, Win7SP0x86, Win7SP1x86_24000, Win7SP1x86 AS Layer1 : IA32PagedMemoryPae (Kernel AS) AS Layer2 : FileAddressSpace (/Users/ayaka/Downloads/NahamConCTF/memdump.raw) PAE type : PAE DTB : 0x185000L KDBG : 0x8276fc28L Number of Processors : 1 Image Type (Service Pack) : 1 KPCR for CPU 0 : 0x82770c00L KUSER_SHARED_DATA : 0xffdf0000L Image date and time : 2020-04-20 21:16:55 UTC+0000 Image local date and time : 2020-04-20 14:16:55 -0700 $ vol.py -f memdump.raw --profile=Win7SP1x86_23418 pstree (snip) 0x85a10520:explorer.exe 2136 2104 32 779 2020-04-20 21:15:59 UTC+0000 . 0x85a06b50:regsvr32.exe 2436 2136 0 ------ 2020-04-20 21:16:00 UTC+0000 . 0x85ea04f0:cmd.exe 3460 2136 1 18 2020-04-20 21:16:21 UTC+0000 (snip)
filescanコマンドでは特に怪しいものが見つからなかったので、pstreeで見ると、explorer.exeからcmd.exeを起動しているので、
コマンド履歴と実行結果を取得できるconsolesを使う。
$ vol.py -f memdump.raw --profile=Win7SP1x86_23418 consoles Volatility Foundation Volatility Framework 2.6.1 ************************************************** ConsoleProcess: conhost.exe Pid: 3468 Console: 0xc781c0 CommandHistorySize: 50 HistoryBufferCount: 1 HistoryBufferMax: 4 OriginalTitle: %SystemRoot%\system32\cmd.exe Title: C:\Windows\system32\cmd.exe AttachedProcess: cmd.exe Pid: 3460 Handle: 0x5c ---- CommandHistory: 0x2f0448 Application: cmd.exe Flags: Allocated, Reset CommandCount: 1 LastAdded: 0 LastDisplayed: 0 FirstCommand: 0 CommandCountMax: 50 ProcessHandle: 0x5c Cmd #0 at 0x2f4680: echo JCTF{nice_volatility_tricks_bro} ---- Screen 0x2d62d8 X:80 Y:300 Dump: Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\JCTF>echo JCTF{nice_volatility_tricks_bro} JCTF{nice_volatility_tricks_bro} C:\Users\JCTF>
flag: JCTF{nice_volatility_tricks_bro}
Fake File
grep -r flag / 2>/dev/null
かgrep -r flag .
辺りで出てきた。
/home/user/.. :flag{we_should_have_been_worried_about_u2k_not_y2k}
".."というファイル名とは…。
flag: flag{we_should_have_been_worried_about_u2k_not_y2k}
Alkatraz
flag.txtはあるがlessやcatが使えない。echoは使えるので調べていたら、echoでファイル内容を閲覧できるのを知った。
ls flag.txt less flag.txt /bin/rbash: line 2: less: command not found echo $(<flag.txt) flag{congrats_you_just_escaped_alkatraz}
flag: flag{congrats_you_just_escaped_alkatraz}
Trapped
何のコマンドを打っても同じメッセージが返ってきて使えないが、trapコマンドを打った時だけ違うメッセージが返ってくる。
user@host:/home/user$ ls ls You're stuck in the trap! user@host:/home/user$ trap trap trap -- 'trap_card' DEBUG
どうやらDEBUGシグナルをtrapする状態になっているらしいので、解除する。
user@host:/home/user$ trap - DEBUG trap - DEBUG user@host:/home/user$ cat flag.txt cat flag.txt flag{you_activated_my_trap_card}
flag: flag{you_activated_my_trap_card}
Microsooft
docxファイルはzipファイルとして解凍できる。解凍して"flag"でgrep。
$ unzip microsooft.zip Archive: microsooft.zip inflating: [Content_Types].xml creating: _rels/ inflating: _rels/.rels creating: docProps/ inflating: docProps/app.xml inflating: docProps/core.xml creating: src/ inflating: src/gfxdata.txt extracting: src/gfxdata.zip inflating: src/oof.txt inflating: src/unencrypted.docx creating: word/ creating: word/_rels/ inflating: word/_rels/document.xml.rels inflating: word/document.xml inflating: word/fontTable.xml inflating: word/settings.xml inflating: word/styles.xml $ grep -r flag . ./src/oof.txt:Sed eget sem mi. Nunc ornare tincidunt nulla quis imperdiet. Donec quis dignissim lorem, vel dictum felis. Morbi blandit dapibus lorem nec blandit. Pellentesque ornare auctor est, vitae ultrices nulla efficitur quis. flag{oof_is_right_why_gfxdata_though} Morbi vel velit vel sem malesuada volutpat interdum ut elit. Duis orci nisl, suscipit non maximus sit amet, consectetur at diam. Vestibulum cursus odio vitae eros mollis sodales. Ut scelerisque magna diam, sit amet porttitor massa tincidunt tempus. Vivamus libero nulla, facilisis id faucibus sit amet, ultricies non dolor. Maecenas ornare viverra dui, nec vestibulum nisl pretium id. Nam fringilla maximus quam non porttitor. Curabitur eget ultricies metus. Nunc hendrerit dolor non nulla volutpat sollicitudin. Suspendisse hendrerit odio nec luctus venenatis. Nullam lobortis fringilla aliquam.
flag: flag{oof_is_right_why_gfxdata_though}
New Years Resolution
nameserverがどうたらと書かれているのでdigしてみたらフラグ。
% dig jh2i.com any ; <<>> DiG 9.10.6 <<>> jh2i.com any ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 14251 ;; flags: qr rd ra; QUERY: 1, ANSWER: 7, AUTHORITY: 0, ADDITIONAL: 9 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;jh2i.com. IN ANY ;; ANSWER SECTION: jh2i.com. 3600 IN SPF "flag{next_year_i_wont_use_spf}" (snip)
flag: flag{next_year_i_wont_use_spf}
Finsta
"finsta"はインスタのサブ垢とかの意味らしいので、"NahamConTron"をInstagramで検索したらユーザとフラグが出てきた。
flag: flag{i_feel_like_that_was_too_easy}