> For the complete documentation index, see [llms.txt](https://beafn28.gitbook.io/beafn28/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://beafn28.gitbook.io/beafn28/writeups/dockerlabs/aguademayo.md).

# AguaDeMayo

### 🔍 **RECONOCIMIENTO**

En primer lugar, tras conectarnos a la máquina, utilizamos el comando:

```bash
ping -c 1 172.17.0.2
```

para verificar la conectividad de red.

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

A continuación, realizamos el comando:

```bash
nmap -sVC -p- -n --min-rate 5000 172.17.0.2
```

para realizar un escaneo de puertos y servicios detallado en la dirección IP.

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

Como podemos observar durante el escaneo que el **puerto 22** perteneciente al **servicio SSH** y el **puerto 80** perteneciente al **servicio HTTP** están abiertos por lo que a continuación se indagará más.

### 🔎 **EXPLORACIÓN**

Se utiliza el comando:

```bash
sudo nmap -sCV -p22,80 -v 172.17.0.2
```

para obtener más información sobre esos puertos específicamente.

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

Seguimos indagando más sobre los puertos y ahora indagamos sobre el **servicio HTTP**. Se ingresó la **dirección IP** en el navegador lo que llevó a que la página web por defecto del Apache.

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

Inspeccionando el código fuente descubrimos que hay algo comentado que al parecer es un tipo de código que pertenece a **Brainfuck** por lo que a través de esta página lo decodificamos a código **ASCII** [enlace](https://www.dcode.fr/brainfuck-language).

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

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

Al decodificarlo, obtenemos un valor que no sabemos si es un usuario o una contraseña. Hacemos **Fuzzing Web** para ver si podemos averiguar algo con el comando:

```bash
gobuster dir -u http://172.17.0.2/ -w /usr/share/wordlists/dirbuster/directory-list-lowercase-2.3-medium.txt
```

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

Vemos que hay un directorio llamado **/images**, por lo que indagamos qué hay en él.

<figure><img src="/files/4O0rtv8vEf0QegTbCJd5" alt=""><figcaption></figcaption></figure>

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

Para descargar la imagen y ver si hay información oculta, utilizamos el comando:

```bash
wget http://172.17.0.2/images/agua_ssh.jpg
```

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

Con el comando:

```bash
steghide extract -sf agua_ssh.jpg
```

intentamos extraer datos ocultos del archivo de imagen llamado **agua\_ssh.jpg** usando la herramienta **Steghide**, pero no tenemos suerte.

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

Con el comando:

```bash
exiftool agua_ssh.jpg
```

extraemos y mostramos los metadatos incrustados en la imagen, pero no encontramos información relevante.

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

Como ninguna de las herramientas de esteganografía tuvo éxito, intentamos usar **agua** como nombre de usuario para conectarnos a través de **SSH** con la contraseña que decodificamos anteriormente.

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

### 🔐 **PRIVILEGIOS**

Al estar dentro y ejecutar:

```bash
whoami
```

aún no somos **root**, por lo que hacemos:

```bash
sudo -l
```

para ver si hay algo para explotar.

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

Ejecutamos el binario para obtener una especie de shell con el comando:

```bash
sudo -u root /usr/bin/bettercap
```

Una vez dentro, ejecutamos:

```bash
!chmod u+s /bin/bash
```

ya que esto nos permite ejecutar una **shell** con permisos elevados. Verificamos y confirmamos que ahora tenemos los máximos privilegios.

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://beafn28.gitbook.io/beafn28/writeups/dockerlabs/aguademayo.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
