グリーン免許エンジニアのNotepad

エンジニアの免許を取得したてのほやほやエンジニアが作るNotepadです。Notepad(メモ帳)以上のことは書けません。

Linuxの勉強としてOverTheWireのbanditをちょっとだけやってみた

  • banditとは

The Bandit wargame is aimed at absolute beginners. It will teach the basics needed to be able to play other wargames. If you notice something essential is missing or have ideas for new levels, please let us know!

http://overthewire.org/wargames/bandit/

要は、初心者向けのCTF的な立ち位置。

 

ではさっそく

 

  • レベル0
ポート:2220
ユーザ名:bandit0
パスワード:bandit0
 
  • レベル0→レベル1
bandit0@bandit:~$ cat readme
boJ9jbbUNNfktd78OOpsqOltutMc3MY1
 
 
  • レベル1→レベル2
    • 「-」のファイルはそのままでは開けないので絶対パスで開くかカレントディレクトリを表す「./」をつけて開く
bandit1@bandit:~$ cat ./-
CV1DtqXWVFXTvM2F0k09SHz0YwRINYA9
 
  • レベル2→レベル3
    • スペースの入ったファイル名は「'」で囲って開く
bandit2@bandit:~$ cat 'spaces in this filename'
UmHadQclWmgdLOKQ3YNgjWxGoRMb5luK
 
 
  • レベル3→レベル4
    • 「.」から始まる隠しファイルを表示するには「-a」オプションを付けると確認できる
bandit3@bandit:~/inhere$ ls -a
.  ..  .hidden
bandit3@bandit:~/inhere$ cat .hidden
pIwrPrtPN36QITSp3EQaw936yaFoFgAB
 
 
  • レベル4→レベル5
    • ファイルタイプを判定する「file」コマンドを使って、実行可能ファイルか、テキストファイルか、その他のデータかなどを確認できる
bandit4@bandit:~$ file ./inhere/*
./inhere/-file00: data
./inhere/-file01: data
./inhere/-file02: data
./inhere/-file03: data
./inhere/-file04: data
./inhere/-file05: data
./inhere/-file06: data
./inhere/-file07: ASCII text
./inhere/-file08: data
./inhere/-file09: data
bandit4@bandit:~/inhere$ cat ./-file07
koReBOKuIDDepwhWk7jZC0RTdopnAYKh
 
 
  • レベル5→レベル6
    • 「find」コマンドを使ってファイルやディレクトリを検索できる
    • 「-ls」オプションは結果をファイル詳細付きで表示する
    • grep」で文字列を検索できる
    • 「コマンド1 | コマンド2」をすることでコマンド1の結果をコマンド2へ引き渡すことができる
bandit5@bandit:~/inhere$ find -ls | grep 1033
   923900      4 -rw-r-----   1 root     bandit5      1033 Dec 28 14:34 ./maybehere07/.file2
bandit5@bandit:~/inhere$ cat ./maybehere07/.file2
DXjZPULLxYr17uwoI01bNLQbtFemEgo7
 
 
  • レベル6→レベル7
    • 「-user」オプションを使って所有者名で検索
    • 「-group」オプションを使ってグループ名で検索
    • 「2>/dev/null」を使って標準エラー出力を捨てることでエラーを省いた結果を表示できる
bandit6@bandit:/$ find -user bandit7 -group bandit6 2>/dev/null
./var/lib/dpkg/info/bandit7.password
 
bandit6@bandit:/var/lib/dpkg/info$ cat /var/lib/dpkg/info/bandit7.password
HKBPTKQnIay4Fw76bEy8PVxKEDQRKTzs
 
 
  • レベル7→レベル8
bandit7@bandit:~$ cat data.txt | grep millionth
millionth       cvX2JJa4CFALtqS87jk27qwqGhBM9plV
 
 
  • レベル8→レベル9
    • 「sort」コマンドを使用してファイルを並び替え
    • 「sort」コマンドの出力結果を「uniq」コマンドで重複した行を削除
    • 「uniq」コマンドに「-u」オプションを付けることで重複した行をまとめるのではなく削除する
bandit8@bandit:~$ sort data.txt | uniq -u
UsvVyFSfZZWbi6wgC7dAFyFuR6jQQUhR
 
 
  • レベル9→レベル10
    • 「strings」コマンドでバイナリファイルの表示可能な文字列を出力
    • grep」コマンドで「===*」を検索
    • 「*」は直前の1文字の0回以上の繰り返しを表現
bandit9@bandit:~$ strings data.txt | grep ===*
========== theP`
========== password
L========== isA
========== truKLdjsbJ5g7yyJ2X2R0o3a5HQJFuLk
 
 
  • レベル10→レベル11
    • base64」コマンドの「-d」オプションを利用してbase64をでコード
bandit10@bandit:~$ cat data.txt
VGhlIHBhc3N3b3JkIGlzIElGdWt3S0dzRlc4TU9xM0lSRnFyeEUxaHhUTkViVVBSCg==
 
bandit10@bandit:~$ base64 -d data.txt
The password is IFukwKGsFW8MOq3IRFqrxE1hxTNEbUPR
 
 
  • レベル11→レベル12
    • rot13のシーザー暗号だったのでデコード
bandit11@bandit:~$ cat data.txt
Gur cnffjbeq vf 5Gr8L4qetPEsPk8htqjhRK8XSP6x2RHh
bandit11@bandit:~$ python
Python 2.7.12 (default, Nov 20 2017, 18:23:56)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import codecs
>>> codecs.decode('Gur cnffjbeq vf 5Gr8L4qetPEsPk8htqjhRK8XSP6x2RHh','rot13')
u'The password is 5Te8Y4drgCRfCx8ugdwuEX8KFC6k2EUu'
 
The password is 5Te8Y4drgCRfCx8ugdwuEX8KFC6k2EUu
 
 
 
かなりLinuxの勉強になるので今後も解いていこうと思う
© 2018-2023 tt. All Rights Reserved.