Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-01-11 10:25 EST
Nmap scan report for spainmerides.dl (172.17.0.2)
Host is up (0.000035s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 9.6p1 Ubuntu 3ubuntu13.4 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 256 7b:98:d4:e7:ec:50:0b:b2:3a:21:76:2c:45:95:23:61 (ECDSA)
|_ 256 5d:15:2b:28:ec:67:7e:78:3c:16:12:65:2f:59:d4:88 (ED25519)
80/tcp open http Werkzeug/3.0.3 Python/3.12.3
|_http-server-header: Werkzeug/3.0.3 Python/3.12.3
| fingerprint-strings:
| GetRequest:
| HTTP/1.1 200 OK
| Server: Werkzeug/3.0.3 Python/3.12.3
| Date: Sat, 11 Jan 2025 15:25:48 GMT
| Content-Type: text/html; charset=utf-8
| Content-Length: 9332
| Connection: close
| <!DOCTYPE html>
| <html>
| <head>
| <meta charset="UTF-8">
| <meta name="viewport" content="width=device-width initial-scale=1.0">
| <link rel="stylesheet" href="/static/css/style.css">
| <title>Cahopos4-4ll</title>
| </head>
| <header>
| <nav>
| <h2><a href="/" id="logo">DockerLabs</a></h2>
| <button class="nav-button fa fa-bars"></button>
| <div>
| <!-- <ul> -->
| <ul>
| <button class="exit-menu fa fa-times"></button>
| <li><a href="#" class="active">welcome</a></li>
| <li><a href="#">menu</a></li>
| <li><a href="#">reservations</a></li>
| <li><a href="#">news</a></li>
| <li><a href="#">contact</a></li>
| </ul>
| <!-- </ul> -->
| </div>
| </nav>
| <div cl
| HTTPOptions:
| HTTP/1.1 200 OK
| Server: Werkzeug/3.0.3 Python/3.12.3
| Date: Sat, 11 Jan 2025 15:25:48 GMT
| Content-Type: text/html; charset=utf-8
| Allow: OPTIONS, HEAD, GET
| Content-Length: 0
| Connection: close
| RTSPRequest:
| <!DOCTYPE HTML>
| <html lang="en">
| <head>
| <meta charset="utf-8">
| <title>Error response</title>
| </head>
| <body>
| <h1>Error response</h1>
| <p>Error code: 400</p>
| <p>Message: Bad request version ('RTSP/1.0').</p>
| <p>Error code explanation: 400 - Bad request syntax or unsupported method.</p>
| </body>
|_ </html>
|_http-title: Cahopos4-4ll
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
SF-Port80-TCP:V=7.94SVN%I=7%D=1/11%Time=67828D7C%P=x86_64-pc-linux-gnu%r(G
SF:etRequest,2523,"HTTP/1\.1\x20200\x20OK\r\nServer:\x20Werkzeug/3\.0\.3\x
SF:20Python/3\.12\.3\r\nDate:\x20Sat,\x2011\x20Jan\x202025\x2015:25:48\x20
SF:GMT\r\nContent-Type:\x20text/html;\x20charset=utf-8\r\nContent-Length:\
SF:x209332\r\nConnection:\x20close\r\n\r\n<!DOCTYPE\x20html>\n<html>\n\x20
SF:\x20<head>\n\x20\x20\x20\x20<meta\x20charset=\"UTF-8\">\n\x20\x20\x20\x
SF:20<meta\x20name=\"viewport\"\x20content=\"width=device-width\x20initial
SF:-scale=1\.0\">\n\x20\x20\x20\x20<link\x20rel=\"stylesheet\"\x20href=\"/
SF:static/css/style\.css\">\n\x20\x20\x20\x20<title>Cahopos4-4ll</title>\n
SF:\x20\x20</head>\n<header>\n\x20\x20<nav>\n\x20\x20\x20\x20<h2><a\x20hre
SF:f=\"/\"\x20id=\"logo\">DockerLabs</a></h2>\n\x20\x20\x20\x20<button\x20
SF:class=\"nav-button\x20fa\x20fa-bars\"></button>\n\x20\x20\x20\x20<div>\
SF:n<!--\x20\x20\x20\x20\x20<ul>\x20-->\n\x20\x20\x20\x20\x20\x20<ul>\n\x2
SF:0\x20\x20\x20\x20\x20\x20\x20<button\x20class=\"exit-menu\x20fa\x20fa-t
SF:imes\"></button>\n\x20\x20\x20\x20\x20\x20\x20\x20<li><a\x20href=\"#\"\
SF:x20class=\"active\">welcome</a></li>\n\x20\x20\x20\x20\x20\x20\x20\x20<
SF:li><a\x20href=\"#\">menu</a></li>\n\x20\x20\x20\x20\x20\x20\x20\x20<li>
SF:<a\x20href=\"#\">reservations</a></li>\n\x20\x20\x20\x20\x20\x20\x20\x2
SF:0<li><a\x20href=\"#\">news</a></li>\n\x20\x20\x20\x20\x20\x20\x20\x20<l
SF:i><a\x20href=\"#\">contact</a></li>\n\x20\x20\x20\x20\x20\x20</ul>\n<!-
SF:-\x20\x20\x20\x20\x20</ul>\x20-->\n\x20\x20\x20\x20</div>\n\x20\x20</na
SF:v>\n\x20\x20<div\x20cl")%r(HTTPOptions,C7,"HTTP/1\.1\x20200\x20OK\r\nSe
SF:rver:\x20Werkzeug/3\.0\.3\x20Python/3\.12\.3\r\nDate:\x20Sat,\x2011\x20
SF:Jan\x202025\x2015:25:48\x20GMT\r\nContent-Type:\x20text/html;\x20charse
SF:t=utf-8\r\nAllow:\x20OPTIONS,\x20HEAD,\x20GET\r\nContent-Length:\x200\r
SF:\nConnection:\x20close\r\n\r\n")%r(RTSPRequest,16C,"<!DOCTYPE\x20HTML>\
SF:n<html\x20lang=\"en\">\n\x20\x20\x20\x20<head>\n\x20\x20\x20\x20\x20\x2
SF:0\x20\x20<meta\x20charset=\"utf-8\">\n\x20\x20\x20\x20\x20\x20\x20\x20<
SF:title>Error\x20response</title>\n\x20\x20\x20\x20</head>\n\x20\x20\x20\
SF:x20<body>\n\x20\x20\x20\x20\x20\x20\x20\x20<h1>Error\x20response</h1>\n
SF:\x20\x20\x20\x20\x20\x20\x20\x20<p>Error\x20code:\x20400</p>\n\x20\x20\
SF:x20\x20\x20\x20\x20\x20<p>Message:\x20Bad\x20request\x20version\x20\('R
SF:TSP/1\.0'\)\.</p>\n\x20\x20\x20\x20\x20\x20\x20\x20<p>Error\x20code\x20
SF:explanation:\x20400\x20-\x20Bad\x20request\x20syntax\x20or\x20unsupport
SF:ed\x20method\.</p>\n\x20\x20\x20\x20</body>\n</html>\n");
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 87.79 seconds
Si entramos en el puerto 80 veremos una pagina normal por fuera, si probamos a interceptar la peticion con BurpSuite enviando esto de la pagina:
Y en BurpSuite veremos lo siguiente:
Vamos a probar si el userInput es vulnerable por alguna injeccion de comandos.
Pero antes lo mandaremos al Repeater y ahi lo testearemos.
Vemos que con un ls nos da un error bastante interesante el cual parece ser que no admite ese comando asi a pelo, pero tampoco nos da otro error de peticion en el sentido de que no signifique nada para el servidor, por lo que probaremos a codificarlo en Base64 para ver si se lo traga.
Vemos que si nos esta haciendo un ls pero codificado en Base64 por lo que haremos lo siguiente:
Primero vemos que usuarios somos:
Vemos que somos el usuario cachopin.
Si listamos los archivos que ha creado dicho usuario, veremos que en la home del usuario hay varios archivos interesantes:
Hydra v9.5 (c) 2023 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 2025-01-11 11:06:45
[WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4
[DATA] max 64 tasks per 1 server, overall 64 tasks, 97 login tries (l:1/p:97), ~2 tries per task
[DATA] attacking ssh://172.17.0.2:22/
[22][ssh] host: 172.17.0.2 login: cachopin password: simple
1 of 1 target successfully completed, 1 valid password found
[WARNING] Writing restore file because 19 final worker threads did not complete until end.
[ERROR] 19 targets did not resolve or could not be connected
[ERROR] 0 target did not complete
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2025-01-11 11:06:46
Vemos que nos descubrio las credenciales del usuario cachopin, por lo que nos conectaremos por SSH.
SSH
ssh cachopin@<IP>
Metemos como contraseña simple y veremos que estamos dentro.
Escalate Privileges
Si vemos el archivo entrypoint.sh:
#!/bin/bash
# Inicia el servicio SSH como root
service ssh start
# Cambia al usuario cachopin para ejecutar la aplicación Flask
exec su - cachopin -c "/home/cachopin/venv/bin/python /home/cachopin/app/app.py"
Vemos que es bastante raro y en el cual posiblemente podremos escalar privilegios por ahi, pero vamos a intentar crackear lo siguiente.
Anteriormente encontramos un listado de hashes los cuales vemos que esta en SHA1 por lo que vamos a intentar decodificarlo con un script de un repositorio de GitHub.