[OverTheWire] Bandit 0-10

Wstęp:

Seria poświęcona wszystkim tym którzy chcą nabyć biegłość w posługiwaniu się systemem Linux. Gorąco rekomenduje ją wszystkim, którzy chcą zacząć swoją przygodę z testami bezpieczeństwa ale nie tylko, ponieważ doskonała znajomość Linuxa przyda się w niemal każdej działce IT 🙂

0

Level Goal

The goal of this level is for you to log into the game using SSH. The host to which you need to connect is bandit.labs.overthewire.org, on port 2220. The username is bandit0 and the password is bandit0. Once logged in, go to the Level 1 page to find out how to beat Level 1.

Commands you may need to solve this level

ssh

Zaczynamy nawiązania połączenia. Używając protokołu ssh logujemy się zdalnie na maszynę:

ssh bandit0@bandit.labs.overthewire.org -p 2220

Logując się na poszczególne poziomy, należy każdorazowo używać tej komendy zmieniając jedynie użytkownika (ja dla wygody, w następnych przykładach będę to pomijał).

Level Goal

The password for the next level is stored in a file called readme located in the home directory. Use this password to log into bandit1 using SSH. Whenever you find a password for a level, use SSH (on port 2220) to log into that level and continue the game.

Commands you may need to solve this level

ls, cd, cat, file, du, find

Odczytujemy znajdujący się tam plik:

bandit0@bandit:~$ ls -la
total 24
drwxr-xr-x 2 root root 4096 May 7 20:14 .
drwxr-xr-x 41 root root 4096 May 7 20:14 ..
-rw-r--r-- 1 root root 220 May 15 2017 .bash_logout
-rw-r--r-- 1 root root 3526 May 15 2017 .bashrc
-rw-r--r-- 1 root root 675 May 15 2017 .profile
-rw-r----- 1 bandit1 bandit0 33 May 7 20:14 readme
bandit0@bandit:~$ cat readme
boJ9jbbUNNfktd78OOpsqOltutMc3MY1

Zapisujemy flagę. Posłuży ona nam jako hasło do następnego poziomu.

1

Level Goal

The password for the next level is stored in a file called - located in the home directory

Commands you may need to solve this level

ls, cd, cat, file, du, find

Logujemy się na bandit1 i przeglądamy pliki w scieżce domowej. Odczytujemy plik podając tym razem ścieżkę bezwzględną pliku:

bandit1@bandit:~$ ls -la
total 24
-rw-r----- 1 bandit2 bandit1 33 May 7 20:14 -
drwxr-xr-x 2 root root 4096 May 7 20:14 .
drwxr-xr-x 41 root root 4096 May 7 20:14 ..
-rw-r--r-- 1 root root 220 May 15 2017 .bash_logout
-rw-r--r-- 1 root root 3526 May 15 2017 .bashrc
-rw-r--r-- 1 root root 675 May 15 2017 .profile
bandit1@bandit:~$ cat /home/bandit1/-
CV1DtqXWVFXTvM2F0k09SHz0YwRINYA9

2

Level Goal

The password for the next level is stored in a file called spaces in this filename located in the home directory

Commands you may need to solve this level

ls, cd, cat, file, du, find

Rozwiązując ten level napotkałem na problem występowania spacji w nazwie pliku. Aby uzyskać hasło do następnego poziomu należy wziąć nazwę pliku w nawiasy:

bandit2@bandit:~$ ls
spaces in this filename
bandit2@bandit:~$ cat 'spaces in this filename'
UmHadQclWmgdLOKQ3YNgjWxGoRMb5luK

3

Level Goal

The password for the next level is stored in a hidden file in the inhere directory.

Commands you may need to solve this level

ls, cd, cat, file, du, find

Tym razem plik z hasłem jest ukryty. Użyłem komendy ls z przełącznikami -la:

bandit3@bandit:~$ ls -la
total 24
drwxr-xr-x 3 root root 4096 May 7 20:14 .
drwxr-xr-x 41 root root 4096 May 7 20:14 ..
-rw-r--r-- 1 root root 220 May 15 2017 .bash_logout
-rw-r--r-- 1 root root 3526 May 15 2017 .bashrc
drwxr-xr-x 2 root root 4096 May 7 20:14 inhere
-rw-r--r-- 1 root root 675 May 15 2017 .profile
bandit3@bandit:~$ cd inhere/
bandit3@bandit:~/inhere$ ls -la
total 12
drwxr-xr-x 2 root root 4096 May 7 20:14 .
drwxr-xr-x 3 root root 4096 May 7 20:14 ..
-rw-r----- 1 bandit4 bandit3 33 May 7 20:14 .hidden
bandit3@bandit:~/inhere$ cat .hidden
pIwrPrtPN36QITSp3EQaw936yaFoFgAB

4

Level Goal

The password for the next level is stored in the only human-readable file in the inhere directory. Tip: if your terminal is messed up, try the “reset” command.

Commands you may need to solve this level

ls, cd, cat, file, du, find

Tym razem naszym zadaniem było znalezienie pliku human-readable. W swoim rozwiązaniu założyłem, że jest to plik ASCII. Należy użyć komendy find w następujący sposób:

bandit4@bandit:~$ find . -type f -exec file {} + | grep ASCII
./inhere/-file07: ASCII text
./.bashrc: ASCII text
./.profile: ASCII text
./.bash_logout: ASCII text
bandit4@bandit:~$ cat ./inhere/-file07
koReBOKuIDDepwhWk7jZC0RTdopnAYKh
  • . – wyszukiwanie od ścieżki w której się znajdujemy
  • type – zdefiniuj typ (w naszym przykładie plik)
  • exec – na wyszukanych plikach wykonaj komende (w naszym przypadku file)
  • grep ASCII – pokaż tylko wiersze zawierające ASCII

Lub też można podejść do problemu inaczej:

bandit4@bandit:~$ ls
inhere
bandit4@bandit:~$ cd inhere/
bandit4@bandit:~/inhere$ ls
-file00 -file01 -file02 -file03 -file04 -file05 -file06 -file07 -file08 -file09
bandit4@bandit:~/inhere$ file ./-file0*
./-file00: data
./-file01: data
./-file02: data
./-file03: data
./-file04: data
./-file05: data
./-file06: data
./-file07: ASCII text
./-file08: data
./-file09: data
bandit4@bandit:~/inhere$ cat ./-file07
koReBOKuIDDepwhWk7jZC0RTdopnAYKh

W tym rozwiązaniu najpierw wszedłem w folder inhere a następnie za pomocą komendy file uzyskałem informacje o typach wszystkich plików w folderze. Odczytałem plik ASCII.

5

Level Goal

The password for the next level is stored in a file somewhere under the inhere directory and has all of the following properties:
human-readable
1033 bytes in size
not executable

Commands you may need to solve this level

ls, cd, cat, file, du, find

Tak jak w poprzednim przykładzie użyłem komendy find uwzględniając zdefiniowane w poleceniu warunki:

bandit5@bandit:~$ ls -l
total 4
drwxr-x--- 22 root bandit5 4096 May 7 20:15 inhere
bandit5@bandit:~$ find ./inhere/ -type f -size 1033c ! -executable -exec file {} + | grep ASCII
./inhere/maybehere07/.file2: ASCII text, with very long lines
bandit5@bandit:~$ cat ./inhere/maybehere07/.file2
DXjZPULLxYr17uwoI01bNLQbtFemEgo7

Tym razem dodałem: -size żeby zdefiniować rozmiar szukanego pliku oraz ! -executable by szukać po plikach niewykonywalnych.

6

Level Goal

The password for the next level is stored somewhere on the server and has all of the following properties:
owned by user bandit7
owned by group bandit6
33 bytes in size

Commands you may need to solve this level

ls, cd, cat, file, du, find, grep

Do rozwiązania tego poziomu ponowanie wykorzystam komendę find:

bandit6@bandit:~$ find / -type f -size 33c -group bandit6 -user bandit7 2>/dev/null
/var/lib/dpkg/info/bandit7.password
bandit6@bandit:~$ cat /var/lib/dpkg/info/bandit7.password
HKBPTKQnIay4Fw76bEy8PVxKEDQRKTzs

Tym razem zdefiniowałem grupę oraz usera do którego należy plik. Z racji mnogości wyników przekierowałem standardowy strumień błędów (stderr) do tzw. “black hole” aby uzyskać klarowny wynik.

7

Level Goal

The password for the next level is stored in the file data.txt next to the word millionth

Commands you may need to solve this level

grep, sort, uniq, strings, base64, tr, tar, gzip, bzip2, xxd

Do rozwiązania tego poziomu użyłem komendy grep, służącej do wypisywania takich wierszy z pliku, które są zgodne z podanym przez nas wyrażeniem:

bandit7@bandit:~$ ls -l
total 4088
-rw-r----- 1 bandit8 bandit7 4184396 May 7 20:15 data.txt
bandit7@bandit:~$ cat data.txt | grep millionth
millionth cvX2JJa4CFALtqS87jk27qwqGhBM9plV

8

Level Goal

The password for the next level is stored in the file data.txt and is the only line of text that occurs only once

Commands you may need to solve this level

grep, sort, uniq, strings, base64, tr, tar, gzip, bzip2, xxd

Do rozwiązania tego poziomu użyłem komend: sort, uniq oraz grep:

bandit8@bandit:~$ sort data.txt | uniq -c | grep -v 10
1 UsvVyFSfZZWbi6wgC7dAFyFuR6jQQUhR

Na początku ułożyłem wiersze z pliku tekstowego w porządku alfabetycznym. Następnie zliczyłem ilość powtarzających się wierszy w pliku. Na końcu odrzuciłem te wiersze, które powtarzały się 10 razy.

9

Level Goal

The password for the next level is stored in the file data.txt in one of the few human-readable strings, preceded by several ‘=’ characters.

Commands you may need to solve this level

grep, sort, uniq, strings, base64, tr, tar, gzip, bzip2, xxd

Rozwiązanie:

bandit9@bandit:~$ ls -l
total 20
-rw-r----- 1 bandit10 bandit9 19379 May 7 20:14 data.txt
bandit9@bandit:~$ file data.txt
data.txt: data
bandit9@bandit:~$ strings data.txt | grep =
========== the*2i"4
=:G e
========== password
<I=zsGi
Z)========== is
A=|t&E
Zdb=
c^ LAh=3G
*SF=s
&========== truKLdjsbJ5g7yyJ2X2R0o3a5HQJFuLk
S=A.H&^

Tym razem nie mieliśmy do czynienia z plikiem ASCII . Użyłem więc komendy strings by wyświetlić drukowalne znaki w pliku.

10

Level Goal

The password for the next level is stored in the file data.txt, which contains base64 encoded data

Commands you may need to solve this level

grep, sort, uniq, strings, base64, tr, tar, gzip, bzip2, xxd

Rozwiązanie:

bandit10@bandit:~$ ls -l
total 4
-rw-r----- 1 bandit11 bandit10 69 May 7 20:14 data.txt
bandit10@bandit:~$ grep == data.txt
VGhlIHBhc3N3b3JkIGlzIElGdWt3S0dzRlc4TU9xM0lSRnFyeEUxaHhUTkViVVBSCg==
bandit10@bandit:~$ grep == data.txt | base64 -d
The password is IFukwKGsFW8MOq3IRFqrxE1hxTNEbUPR

Tym razem hasło mieliśmy zakodowane w base64. Przekierwałem więc wynik pierwszej komendy, następnie wynik ten zdekodowałem używając komendy base64.

Info na zakończenie:

Dalsza częśc rozwiązań zostanie opublikowana wkrótce. Feedback mile widziany w komentarzach 🙂

Pozdrawiam!

1 thought on “[OverTheWire] Bandit 0-10”

Comments are closed.