> 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-easy/cap-hackthebox-writeup.md).

# Writeup de Cap en HackTheBox

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

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

* Referencia insegura a objetos de directorio (IDOR)
* Fuga de información
* Abuso de capacidades (Python3.8) (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/c514fe44cf5e084ade9ec6c5990dcc1ab40de066" 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/1ca7024eb9262e5ec4ca4863bc157bfa55ebd4ca" 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.245 -oG allPorts
```

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

**Análisis de puertos abiertos con extractPorts:**

Usa la función extractPorts para mostrar los puertos abiertos en un formato conciso y copiarlos al portapapeles (21,22,80)

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

#### Escaneo de versiones de puertos con Nmap:

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

```bash
nmap -sCV -p21,22,80 10.10.10.245 -oN targeted
```

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

### Puerto 80 - HTTP

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

Accedemos al servicio HTTP y descubrimos una sección llamada **Security Snapshot**. Esta sección permite crear y descargar **pcap** archivos que contienen registros del sistema.

<figure><img src="/files/38fe07e994e287b62fdb7ca7b0829739be31228f" alt=""><figcaption></figcaption></figure>

## Vulnerabilidad IDOR

**Observación inicial**

Tras analizar los **pcap** archivos con Wireshark, no se encontró contenido directamente utilizable.

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

Sin embargo, observamos que cada vez que se descarga un archivo, se crea una **captura** La URL correspondiente contiene un parámetro que indica el identificador de la captura, por ejemplo: `snapshot_data=2`.

<figure><img src="/files/5cc6e8fc7008cccae14272e307b4087eea6824eb" alt=""><figcaption></figcaption></figure>

Al cambiar manualmente el parámetro de la URL para acceder a la captura 0, obtenemos un archivo que contiene información sensible.

### **Análisis con Wireshark**

Al examinar las tramas en el **pcap** archivo, identificamos las credenciales de un usuario:

* usuario: `nathan`
* contraseña: `Buck3tH4TF0RM3!`

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

#### Uso de credenciales

**Acceso FTP**

Usamos las credenciales para conectarnos al servicio FTP:

Conexión exitosa. Recuperamos el **user.txt** archivo que contiene la primera bandera.

<figure><img src="/files/5f227264daafc8407489cf2aeaea239840ce72d5" alt=""><figcaption></figcaption></figure>

**Acceso SSH**

Al probar las mismas credenciales para una conexión SSH, obtenemos acceso completo:

```bash
ssh nathan@10.10.10.245
Buck3tH4TF0RM3!
```

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

## Escalada de privilegios

### Vulnerabilidad de capacidades Python3.8

#### Filtrado **capacidades**:

Si filtramos por capacidades, aparece Python 3.8:

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

<figure><img src="/files/2f13780ec526b7fed5138431ddf2955260f7ce16" alt="" width="554"><figcaption></figcaption></figure>

Utilice [GTFOBins](https://gtfobins.github.io/) como referencia.

```bash
python3.8 -c 'import os; os.setuid(0); os.system("/bin/sh")'
```

<figure><img src="/files/3598db441427fb520962788ef70daec47e0ff766" alt=""><figcaption></figcaption></figure>

### Bandera root.txt :)

<figure><img src="/files/11221575217566c4ac15cad62c1e2599eaa1807c" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="/files/5b5f85f99f77455cae945901f02dd9571131b25f" alt="" width="482"><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-easy/cap-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.
