> For the complete documentation index, see [llms.txt](https://hacking-3.gitbook.io/barre/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-3.gitbook.io/barre/write-up/dockerlabs/medio/cachopo.md).

# Cachopo

## Maquina

<figure><img src="/files/cvg43YzqDxzk3qQ8UBE0" alt=""><figcaption></figcaption></figure>

## Reconocimiento

### Nmap

```bash
sudo nmap -p- --open -sSCV --min-rate 5000 -vvv -Pn 172.17.0.2 -oN nmap.txt
```

```
PORT   STATE SERVICE REASON         VERSION
22/tcp open  ssh     syn-ack ttl 64 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)
| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEjW7OFr3vBvcqYorxu8cbiAsLnl1KxEId5AjI88T+pHcpP1tlFZROjtLlMTl6/qbg3SvyDoh75cLiLq/nG5d1U=
|   256 5d:15:2b:28:ec:67:7e:78:3c:16:12:65:2f:59:d4:88 (ED25519)
|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKiE4JB9YEGU2mtWJP7VMmr5R60+RXwvThaYJ//r0T9h
80/tcp open  http    syn-ack ttl 64 Werkzeug/3.0.3 Python/3.12.3
| http-methods: 
|_  Supported Methods: OPTIONS GET HEAD
|_http-title: Cahopos4-4ll
|_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: Thu, 22 Aug 2024 16:23:50 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: Thu, 22 Aug 2024 16:23:50 GMT
|     Content-Type: text/html; charset=utf-8
|     Allow: OPTIONS, GET, HEAD
|     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>
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=8/22%Time=66C76616%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:\x20Thu,\x2022\x20Aug\x202024\x2016:23:50\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:\x20Thu,\x2022\x20
SF:Aug\x202024\x2016:23:50\x20GMT\r\nContent-Type:\x20text/html;\x20charse
SF:t=utf-8\r\nAllow:\x20OPTIONS,\x20GET,\x20HEAD\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
```

### Web

{% hint style="warning" %}
No hay más directorios, es una única página.
{% endhint %}

<figure><img src="/files/w0ZKuCNJyWGgTuo5Yd9a" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/bcbJ0cDG9yIbhgrD0zFO" alt=""><figcaption></figcaption></figure>

En esta pagina no nos dice nada muy relevante, lo único útil que tenemos en un panel de reservas, vamos a ver que es lo que manda.

## Explotación

### Burpsuite

<figure><img src="/files/v0aQnyqxCw6GPUdGhjh9" alt=""><figcaption></figcaption></figure>

Nos da un error, por lo que probamos a convertir esta misma palabra a base64

<figure><img src="/files/dbDw2OKqoafHLbii2K0u" alt=""><figcaption></figcaption></figure>

Ahora el error ha cambiado, probemos a ejecutar algún comando de shell codificado en base64

<figure><img src="/files/kMBYq9c8n4HKP03Fy3u7" alt=""><figcaption><p>El comando es: cat /etc/passwd</p></figcaption></figure>

Ahora tenemos el usuario `cachopin`, por lo que podemos probar a hacer un ataque de fuerza bruta con hydra.

```bash
hydra -l cachopin -P /usr/share/wordlists/rockyou.txt 172.17.0.2 ssh -t 64
```

<figure><img src="/files/uZUFYOC9RLjnMjPW2BMQ" alt=""><figcaption></figcaption></figure>

## Escalado de privilegios

Miramos permisos de este usuario

<figure><img src="/files/9GoYj47SjwzFk4rBk2fh" alt=""><figcaption></figcaption></figure>

Miramos que tiene esta maquina dentro

<figure><img src="/files/hJ3ttCD8mFUQt2DdBEWc" alt=""><figcaption></figcaption></figure>

Lo que más llama la atención es `entrypoint.sh`

<figure><img src="/files/oXqq3GKfhBXIT3mgbC2c" alt=""><figcaption></figcaption></figure>

Vemos que ejecuta un archivo de nombre `app.py`, el cual nos explica como funciona la vulnerabilidad que hemos explotado antes con burpsuite

<figure><img src="/files/m5lHlsw0neoIRxX4zW3L" alt=""><figcaption></figcaption></figure>

Si seguimos mirando daremos con una lista de hashes generados en SHA1

<figure><img src="/files/MA4ChjkWvxd0M1O7SvAJ" alt=""><figcaption></figcaption></figure>

Parece que estos hashes están modificados en base64, si le preguntamos a ChatGPT no dice:

<figure><img src="/files/1wAFgjDAmQi1A6DE62HI" alt=""><figcaption></figcaption></figure>

Tras hacer varias pruebas con estos hashes no saco nada por lo que sigo buscando pero imposible, la única forma de descifrar estos hashes es con la herramienta del creador de la maquina [@PatxaSec](https://github.com/PatxaSec/SHA_Decrypt)

<figure><img src="/files/vsnEpfVU3olqguhWAdhQ" alt=""><figcaption></figcaption></figure>

Si usamos esta herramienta sacaremos 2 posibles contraseñas

```bash
python3 /opt/SHA_Decrypt/sha2text.py 'd' '$SHA1$d$BjkVArB9RcGUs3sgVKyAvxzH0eA=' '/usr/share/w
```

<figure><img src="/files/v3f9gSO9nDhpQ5i3yHWg" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/0weINBcdTFyL5ynlvyp0" alt=""><figcaption></figcaption></figure>

&#x20;Si las probamos en el usuario de root una de ellas sera la buena y ya seremos root

<figure><img src="/files/6k1w1vrgrxURLHzsuyKN" alt=""><figcaption></figcaption></figure>

## Conclusión

Es una maquina muy entretenida, lo único malo que le saco a esta maquina  es el uso de la herramienta del propio creador, creo que es muy difícil de encontrar si no miras quien es el creador de la maquina o algún write up de alguien que la haya hecho, en mi caso mire varios write up y en todos se usaba esta herramienta, creo que no hay otra forma de completarla y eso me parece que empeora la experiencia de esta máquina.

No todo es malo, tan solo la ultima parte del escalado de privilegios, creo que el uso de [burpsuite ](/barre/apuntes/red-team/tools/burp-suite.md)esta muy bien implementado, la web esta muy currada y el nombre me encanta *cachopo*.
