> 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/obsession.md).

# Obsession

### 🔍 **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/dWGF7azn9kW36kMapkWm" alt=""><figcaption></figcaption></figure>

A continuación, se realiza el comando:

```bash
nmap -p- --open -sT --min-rate 5000 -vvv -n -Pn 172.17.0.2 -oG allPorts
```

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

![](/files/Usukvf28VFPEh4LfeaLE)

Como podemos observar durante el escaneo que el **puerto 21** perteneciente al **servicio FTP**, 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 -p21,22,80 -v 172.17.0.2
```

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

<figure><img src="/files/57X23M1OFPiEOaEfgpuN" alt=""><figcaption></figcaption></figure>

Observamos que el puerto **21** tiene dos archivos que podrían contener información relevante, y que la conexión es permitida con el usuario **anonymous** y sin contraseña, por lo que nos conectaremos a través de **FTP**. Esto lo sabemos ya que la versión es vulnerable a esas credenciales.

![](/files/Uh2ALrD4hU8en5rhywkf)

Tras entrar, debemos listar y descargar los archivos que se mostraban anteriormente a través de los comandos:

```bash
ls
get chat-gonza.txt
get pendientes.txt
```

![](/files/TsnDtQ2mbshzYbtGNIvN)

Ahora mostramos el contenido de esos archivos con:

```bash
cat chat-gonza.txt
cat pendientes.txt
```

![](/files/ZxURynwxQPotJJKNjnMk)

Con esto, descubrimos información de algunos de los usuarios e información de los permisos, lo que nos proporciona datos relevantes.

Seguimos indagando más sobre los puertos y ahora investigamos el servicio **HTTP**. Se ingresó la dirección IP en el navegador, lo que llevó a que la página web nos muestre un blog de entrenamiento personal.

![](/files/8fdgvbdqy65hk0rkM21w)

Ahora buscaremos directorios con la herramienta **Gobuster** a través de:

```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/cacPKlh2fLr0d1SOMP1E" alt=""><figcaption></figcaption></figure>

Descubrimos dos directorios que son `/backup/` y `/important/`, por lo que los revisamos y su contenido a continuación.

![](/files/IyN1NT4h0QyOgl3xxZv5)

![](/files/SwxYtSDik2Nz82eVQSIl)

Con esto, descubrimos que el usuario es **russoski**. Continuamos con el siguiente directorio.

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

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

Parece ser que esto último no tiene nada relevante, por lo que nos centramos en lo que hemos descubierto anteriormente, que es el usuario.

### 🚀 **EXPLOTACIÓN**

Con la información obtenida anteriormente, realizamos el comando:

```bash
hydra -l russoski -P /usr/share/wordlists/rockyou.txt ssh://172.17.0.2 -t 5
```

que utiliza la herramienta **Hydra** para realizar un ataque de fuerza bruta contra el servicio **SSH** de una máquina con la IP **172.17.0.2**.

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

Al realizar el ataque de fuerza bruta, hemos descubierto la contraseña de **russoski**. Sabiendo esto, nos conectamos a través de **SSH** al usuario con el comando:

```bash
ssh russoski@172.17.0.2
```

![](/files/Eb40WN4DB0CEdesEFy0E)

### 🔐 **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.

![](/files/8lrAm5g2JjMzb3tvHadd)

Observamos que podemos escalar privilegios con **vim** usando el comando:

```bash
sudo vim -c ':!/bin/sh'
```

Tras eso, ponemos:

```bash
id
```

y ya somos **root**.

<figure><img src="/files/UYTX4WcQ4GWPjlMz5l7B" 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/obsession.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.
