Zaczynam nową serię Capture The Flag poświęconą systemowi operacyjnemu linux. Myślę, że każdy użytkownik systemu linux będzie miał możliwość poznania nowych i ciekawy sztuczek w tym systemie.
W celu zalogowania się do poziomu 0 należy skorzystać z programu do logowania się przez usługę SSH, ja będę korzystał z aplikacji putty do wejścia na zdalną maszynę.
Level 0
Host: bandit.labs.overthewire.org:2220
login : bandit0
password: bandit0

login as: bandit0
This is a OverTheWire game server. More information on http://www.overthewire.org/wargames
bandit0@bandit.labs.overthewire.org's password:
Linux bandit.otw.local 5.4.8 x86_64 GNU/Linux
,----.. ,----, .---.
/ / \ ,/ .`| /. ./|
/ . : ,` .' : .--'. ' ;
. / ;. \ ; ; / /__./ \ : |
. ; / ` ; .'___,/ ,' .--'. ' \' .
; | ; \ ; | | : | /___/ \ | ' '
| : | ; | ' ; |.'; ; ; \ \; :
. | ' ' ' : `----' | | \ ; ` |
' ; \; / | ' : ; . \ .\ ;
\ \ ', / | | ' \ \ ' \ |
; : / ' : | : ' |--"
\ \ .' ; |.' \ \ ;
www. `---` ver '---' he '---" ire.org
Welcome to OverTheWire!
If you find any problems, please report them to Steven or morla on
irc.overthewire.org.
--[ Playing the games ]--
This machine might hold several wargames.
If you are playing "somegame", then:
* USERNAMES are somegame0, somegame1, ...
* Most LEVELS are stored in /somegame/.
* PASSWORDS for each level are stored in /etc/somegame_pass/.
Write-access to homedirectories is disabled. It is advised to create a
working directory with a hard-to-guess name in /tmp/. You can use the
command "mktemp -d" in order to generate a random and hard to guess
directory in /tmp/. Read-access to both /tmp/ and /proc/ is disabled
so that users can not snoop on eachother. Files and directories with
easily guessable or short names will be periodically deleted!
Please play nice:
* don't leave orphan processes running
* don't leave exploit-files laying around
* don't annoy other players
* don't post passwords or spoilers
* again, DONT POST SPOILERS!
This includes writeups of your solution on your blog or website!
--[ Tips ]--
This machine has a 64bit processor and many security-features enabled
by default, although ASLR has been switched off. The following
compiler flags might be interesting:
-m32 compile for 32bit
-fno-stack-protector disable ProPolice
-Wl,-z,norelro disable relro
In addition, the execstack tool can be used to flag the stack as
executable on ELF binaries.
Finally, network-access is limited for most levels by a local
firewall.
--[ Tools ]--
For your convenience we have installed a few usefull tools which you can find
in the following locations:
* gef (https://github.com/hugsy/gef) in /usr/local/gef/
* pwndbg (https://github.com/pwndbg/pwndbg) in /usr/local/pwndbg/
* peda (https://github.com/longld/peda.git) in /usr/local/peda/
* gdbinit (https://github.com/gdbinit/Gdbinit) in /usr/local/gdbinit/
* pwntools (https://github.com/Gallopsled/pwntools)
* radare2 (http://www.radare.org/)
* checksec.sh (http://www.trapkit.de/tools/checksec.html) in /usr/local/bin/checksec.sh
--[ More information ]--
For more information regarding individual wargames, visit
http://www.overthewire.org/wargames/
For support, questions or comments, contact us through IRC on
irc.overthewire.org #wargames.
Enjoy your stay!
bandit0@bandit:~$
Po zalogowaniu się na zdalną maszynę naszym celem jest znalezienie flagi. Zaczynamy od przeszukania katalogu domowego.
bandit0@bandit:~$ ls
readme
bandit0@bandit:~$ cat readme
boJ9jbbUNNfktd78OOpsqOltutMc3MY1
bandit0@bandit:~$
Mamy pierwszą flagę, którą jest hasło do poziomu nr 1
Level 1
Host: bandit.labs.overthewire.org:2220
Login: bandit1
Password: boJ9jbbUNNfktd78OOpsqOltutMc3MY1
Na stronie overthewire mamy podpowiedź do tego zadania, które informuje nas, że hasło znajduje się w pliku o nazwie „-„, który znajduje się w katalogu użytkownika bandit1. Głównym problemem z tym zadaniem jest fakt iż znak „-” stosowany jest do wskazywania opcji do wpisywanych komend. Aby to obejść należy wskazać bezpośrednio ten plik przy pomocy ścieżki względnej lub bezwzględnej.
bandit1@bandit:~$ cat ./-
CV1DtqXWVFXTvM2F0k09SHz0YwRINYA9
bandit1@bandit:~$
Level 2
Host: bandit.labs.overthewire.org:2220
Login: bandit2
Password: CV1DtqXWVFXTvM2F0k09SHz0YwRINYA9
W tym zadaniu również wskazany jest plik, gdzie znajduje się flaga, tym razem jest to plik o nazwie zawierającej spacje: spaces in this filename, znajdujący się w katalogu domowym użytkownika. Wyświetlenie pliku zawierającego spacje wymaga zastosowania znaku \ przed znakiem spacji. Innym sposobem jest użycie tabulatora aby komputer sam dopisał resztę nazwy.
bandit2@bandit:~$ cat spaces\ in\ this\ filename
UmHadQclWmgdLOKQ3YNgjWxGoRMb5luK
bandit2@bandit:~$
Level 3
Host: bandit.labs.overthewire.org:2220
Login: bandit3
Password: UmHadQclWmgdLOKQ3YNgjWxGoRMb5luK
Na tym poziomie hasło do kolejnego poziomu zapisane jest w ukrytym pliku, który jest zapisany w katalogu inhere. Aby zobaczyć zawartość katalogu z zawartością zawierającą pliki ukryte należy zastosować opcję a.
bandit3@bandit:~$ ls
inhere
bandit3@bandit:~$ cd inhere/
bandit3@bandit:~/inhere$ ls -a
. .. .hidden
bandit3@bandit:~/inhere$ cat .hidden
pIwrPrtPN36QITSp3EQaw936yaFoFgAB
bandit3@bandit:~/inhere$
Level 4
Host: bandit.labs.overthewire.org:2220
Login: bandit4
Password: pIwrPrtPN36QITSp3EQaw936yaFoFgAB
Na tym poziomie hasło jest zapisane w katalogu inhere, gdzie znajduje się grupa plików, lecz tylko jeden jest zapisany w czytelny sposób.
bandit4@bandit:~$ file ./inhere/-file0*
./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:~$ cat ./inhere/-file07
koReBOKuIDDepwhWk7jZC0RTdopnAYKh
bandit4@bandit:~$
Level 5
Host: bandit.labs.overthewire.org:2220
Login: bandit5
Password: koReBOKuIDDepwhWk7jZC0RTdopnAYKh
Hasło do kolejnego poziomu znajduje się w katalogu inhere i posiada następujące cechy : jest zapisany w mozliwy do odczytania sposób, posiada wielkość 1033 bajtów i nie posiada praw do uruchamiania.
bandit5@bandit:~$ find . -type f -size 1033c
./inhere/maybehere07/.file2
bandit5@bandit:~$ cat ./inhere/maybehere07/.file2
DXjZPULLxYr17uwoI01bNLQbtFemEgo7
bandit5@bandit:~$
Level 6
Host: bandit.labs.overthewire.org:2220
Login: bandit6
Password: DXjZPULLxYr17uwoI01bNLQbtFemEgo7
Hasło do następnego poziomu znajduje się w katalogu somewhere on the server i posiada następujące właściwości:
- właścicielem jest użytkownik bandit7
- właścicielem jest grupa bandit6
- posiada rozmiar 33 bajtów
bandit6@bandit:~$ find / -type f -group bandit6 -user bandit7 -size 33c 2>/dev/null
/var/lib/dpkg/info/bandit7.password
bandit6@bandit:~$ cat /var/lib/dpkg/info/bandit7.password
HKBPTKQnIay4Fw76bEy8PVxKEDQRKTzs
bandit6@bandit:~$
Warto tutaj podać omówienie komendy find, która posiada tutaj sporo parametrów group to nazwa grupy do której należą właściciele, user to nazwa właściciela, natomiast 2>/dev/null to pominięcie plików, które mogą zostać wyświetlone pomimo iż nie posiadamy uprawnień do tych plików. Chodzi o zapewnienie czytelności wyniku.
Level 7
Host: bandit.labs.overthewire.org:2220
Login: bandit7
Password: HKBPTKQnIay4Fw76bEy8PVxKEDQRKTzs
Hasło znajduje się w pliku data.txt, za słowem millionth
bandit7@bandit:~$ cat data.txt |grep millionth
millionth cvX2JJa4CFALtqS87jk27qwqGhBM9plV
bandit7@bandit:~$
Level 8
Host: bandit.labs.overthewire.org:2220
Login: bandit8
Password: cvX2JJa4CFALtqS87jk27qwqGhBM9plV
Hasło zapisane jest pliku data.txt, występuje wyłącznie raz w tym pliku.
bandit8@bandit:~$ sort data.txt |uniq -u
UsvVyFSfZZWbi6wgC7dAFyFuR6jQQUhR
bandit8@bandit:~$
Zaczynam od posortowania pliku, a pokazuję tylko ten unikalny wiersz.
Level 9
Host: bandit.labs.overthewire.org:2220
Login: bandit9
Password: UsvVyFSfZZWbi6wgC7dAFyFuR6jQQUhR
Hasło do następnego poziomu jest przechowywane w pliku data.txt w jednym z niewielu ciągów czytelnych dla człowieka, poprzedzonych kilkoma znakami „=”.
bandit9@bandit:~$ strings data.txt |grep ==
========== the*2i"4
========== password
Z)========== is
&========== truKLdjsbJ5g7yyJ2X2R0o3a5HQJFuLk
bandit9@bandit:~$
Level 10
Host: bandit.labs.overthewire.org:2220
Login: bandit10
Password: truKLdjsbJ5g7yyJ2X2R0o3a5HQJFuLk
Hasło do następnego poziomu jest przechowywane w pliku data.txt w zakodowanej formie o nazwie base64.
bandit10@bandit:~$ cat data.txt |base64 -d
The password is IFukwKGsFW8MOq3IRFqrxE1hxTNEbUPR
bandit10@bandit:~$