OverTheWire Wargames Banditを10まで解いたWrite up
http://overthewire.org/wargames/bandit/
0~10まで解いてみました。
・Bandit0
readmeを読むだけ。cat readmeで終わり。
・Bandit1
ホームディレクトリに"-"というファイルがあるのでcatするだけ。
・Bandit2
スペースを含むファイルを読む。""で括れば良い。
cat "spaces in this filename"
・Bandit3
頭に"."がついたhiddenファイルを読む。
hiddenファイルはlsコマンドに-aオプションを付ければ見れる。
inhereフォルダの中に.hiddenファイルがあるので読むだけ。
cat inhere/.hidden
・Bandit4
バイナリファイルのなかに1つだけtextファイルが有る。
fileコマンドを使って見ていくと、-file07だけがASCII textだった。
なお、ファイル名の頭に"-"がついているので、catする際はコマンドとして認識されないように"--"をつける
cd inhere
cat -- -file07
・Bandit5
下記条件なので、findコマンドにsizeとreadableオプションつけて実行。
- human-readable
- 1033 bytes in size
- not executable
maybehere07/.file2がヒットするのでそれを読む。
cd inhere
find -size 1033c -readable
cat maybehere07/.file2
・Bandit6
下記条件なので、findコマンドにsizeオプションとgroupオプション、userオプションを付けて実行。
- owned by user bandit7
- owned by group bandit6
- 33 bytes in size
色々出て来るが、頭にfind:が付いていないファイルが1つだけ見つかるので、それを読む。
find / -size 33c -user bandit7 -group bandit6
cat /var/lib/dpkg/info/bandit7.password
・Bandit7
大量の文字列があるテキストファイルからパスワードを探す。
パスワードは"millionth"の隣りにあるよとのことなのでgrep。
cat data.txt | grep "millionth"
・Bandit8
大量の文字列の中で本当のパスワードは唯一重複無しとのことなので、uniqで1回しか出ないものを探す。
cat data.txt | sort | uniq -c
・Bandit9
バイナリファイル中の、いくつかの‘=’で始まる文字列がパスワード。
読める文字を探すため、stringsを使う。=は複数なのでとりあえず2つでgrep。
strings data.txt | grep ==
・Bandit10
base64エンコード文字列があるのでそれをデコードするだけ。
cat data.txt | base64 -d
IFukwKGsFW8MOq3IRFqrxE1hxTNEbUPR