Niveau 21

Niveau 21

Level Goal

There is a setuid binary in the homedirectory that does the following: it makes a connection to localhost on the port you specify as a commandline argument. It then reads a line of text from the connection and compares it to the password in the previous level (bandit20). If the password is correct, it will transmit the password for the next level (bandit21).

NOTE: Try connecting to your own network daemon to see if it works as you think

Commands you may need to solve this level

ssh, nc, cat, bash, screen, tmux, `Unix ‘job control’ (bg, fg, jobs, &, CTRL-Z, …)

Une fois connecté en tant que bandit20 on peut lister les fichiers présents dans le répertoire home :

bandit20@bandit:~$ ls
suconnect

Le but de ce niveau va être d'exposer un service sur un port donné qui renvoi le mot de passe, puis de passer ce port en paramètre de l'exécutable.

Pour exposer un service on peut utiliser netcat avec l'argument l (et plus précisément dans notre cas lvp pour écouter les connexion TCP) :

bandit20@bandit:~$ echo -e "GbKksEFF4yrVs6il55v6gwY5aVje5f0j" | nc -lvp 1234
listening on [any] 1234 ...

Si on se connecte via une nouvelle session SSH et qu'on lance l'exécutable en spécifiant le port 1234 on obtient :

bandit20@bandit:~$ ./suconnect 1234
Read: GbKksEFF4yrVs6il55v6gwY5aVje5f0j
Password matches, sending next password

Si l'on retourne sur la session de notre serveur on peut trouver le mot de passe du niveau suivant :

bandit20@bandit:~$ echo -e "GbKksEFF4yrVs6il55v6gwY5aVje5f0j" | nc -lvp 1234
listening on [any] 1234 ...
connect to [127.0.0.1] from localhost [127.0.0.1] 58422
gE269g2h3mw3pwgrj0Ha9Uoqen1c9DGr