sekai013's blog

JavaScriptとかを勉強する

KSNCTF #4 Villager A [uncompleted]

問題

ksnctf - 4 Villager A

考えたこと

SSH しろって書いてあるので SSH する(ググった)。

ssh q4@ctfq.sweetduet.info -p 10022

ログインできた。とりあえず

[q4@localhost ~]$ ls
flag.txt  q4  readme.txt

ちょろw

[q4@localhost ~]$ cat flag.txt 
cat: flag.txt: 許可がありません

はい。

[q4@localhost ~]$ cat readme.txt
You are not allowed to connect internet and write the home directory.
If you need temporary directory, use /tmp.
Sometimes this machine will be reset.

なるほど。

[q4@localhost ~]$ file q4 
q4: setuid ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped

なるほど。実行できるらしい。
何回か実行した結果、名前を入力すると、それを echo して、その後 do you want the flag? という質問を繰り返し、 no と入力されるとプログラムを終了するという感じのプログラムなのは分かった。
ググったり gdb disas したりした結果、 名前を echo するところに format string の脆弱性があることが分かった。

ここから1時間半くらい何もわからなかったので風呂入って寝た。得点も高いし初心者にはまだ早いということにした。
x86 に慣れるとか gdb の使い方を知るとかが必要な気がする。
飛ばして他の問題を一通り解いてきたら戻ってきたい。