telnet caitsith.pwn.seccon.jp
User:root
Password:seccon
The goal is to find the flag word by "somehow" reading all *.txt files.
telnet caitsith.pwn.seccon.jp問題文に指示されているとおり、telnetでcaitsith.pwn.seccon.jpに接続し、ログインします。
User:root
Password:seccon
すべての *.txt ファイルを読め
まず、lsコマンドでカレントディレクトリのファイルを確認します。
$ ls早速、flags.txtがありますが、この時点ではアクセス権がなく中身を見ることができません。
bin flags.txt linuxrc stage1.txt stage4.txt usr
dev init proc stage2.txt stage5.txt
etc lib sbin stage3.txt tmp
まず、stage1.txtファイルを見てみましょう。
$ cat stage1.txtテキストファイルの先頭行を読むのに使うコマンドは何か?と聞かれています。
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.
headコマンドですね。
それを環境変数stage1に設定すれば、次のstage2.txtファイルにアクセスできるようです。
$ stage1=head shstage2.txtファイルを読めるようになりました。テキストファイルの最終行から読むのに使うコマンドは何か?と聞かれています。
$ cat stage2.txt
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.
これは、tailコマンドですね。
$ stage2=tail sh次は、特定のパターンにマッチする行を取り出すのに使うコマンドは何か?と聞いてきています。
$ cat stage3.txt
What command do you use when you want to pick up lines that match specific patte
rns?
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.
これは、grepコマンドですね。
$ stage3=grep sh次は、テキストファイルを処理したいときに使うコマンドは何?ということで、awkコマンドかな。
$ cat stage4.txt
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.
$ stage4=awk shついに最後です。テキストファイルを処理するために使うコマンドのうちの1つでのみflags.txtファイルを読めるようです。
$ cat stage5.txt
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コマンドかなぁ。
$ sed '1r aa' flags.txtということで、flagをゲットしました。
OK. You have read all .txt files. The flag word is shown below.
SECCON{CaitSith@AQUA}
![[改訂第3版]Linuxコマンドポケットリファレンス](http://ecx.images-amazon.com/images/I/51ZPkoBGdZL._SL160_.jpg)








