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

# Resolución de HackTheBox LinkVortex

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

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

* Enumeración de subdominios
* Extracción de información del directorio .git (Git-Dumper)
* Fuga de información
* Explotación de LFI (Ghost)
* Abuso de privilegios sudo mediante script (doble enlace simbólico)
  {% 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/5297546f3bade5b19575902728aaba0686a7842b" 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/d1b25cd0de049c2f57966374c365ef43d5aeebbb" alt=""><figcaption></figcaption></figure>

**Configuración del archivo /etc/hosts**

Añadimos la dirección IP del objetivo a nuestro `/etc/hosts` archivo para facilitar las resoluciones DNS locales.

<figure><img src="/files/e7d1056508f6baf404067ae34eb6e4f42e866b28" alt=""><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 linkvortex.htb -oG allPorts
```

<figure><img src="/files/7d2e92757b38464585981995616ab56b796cf45c" 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 (22.80)

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

### **Puerto 80**

<figure><img src="/files/4fc7ca35d407f999b1927f6e2a275f65a34785df" alt=""><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 -p22,80 linkvortex.htb -oN targeted
```

<figure><img src="/files/579ffe47ea24f281e8a2708b480eaf64941a17b6" alt=""><figcaption></figcaption></figure>

### **Enumeración de directorios**

```bash
wfuzz -c -t 100 --hc=404,301 -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt http://linkvortex.htb/FUZZ/
```

<figure><img src="/files/86739fb7b02649773e5b5460d2262f4b89937dc5" alt=""><figcaption></figcaption></figure>

### Panel de administración - Ghost

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

### **Descubrimiento de un subdominio**

Buscamos subdominios asociados con `linkvortex.htb` usando gobuster.

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

Encontramos el subdominio `dev.linkvortex.htb`. Aquí está el comando para realizar esta búsqueda:

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

Una vez encontrado el subdominio, lo añadimos al `/etc/hosts` archivo para facilitar el acceso:

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

<figure><img src="/files/858c28f226441721d4a66883582114d35cf1eeb7" alt=""><figcaption></figcaption></figure>

#### **Búsqueda de directorios en el nuevo subdominio**

Buscamos directorios existentes en el `dev.linkvortex.htb` subdominio usando `gobuster`:

```bash
gobuster dir -u http://dev.linkvortex.htb/ -w /usr/share/SecLists/Discovery/Web-Content/common.txt -t 100
```

Descubrimos el `.git` directorio, lo que podría indicar un repositorio Git expuesto.

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

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

### **Extracción de archivos con Git-Dumper**

Usamos la herramienta `git-dumper` para extraer archivos del `.git` directorio y analizarlos:

```git
git-dumper http://dev.linkvortex.htb/.git .git
```

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

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

Esto nos permite obtener archivos sensibles, incluido un archivo de prueba ubicado en `ghost/core/test/regression/api/admin/authentication.test.js`, donde encontramos una contraseña:

<figure><img src="/files/36b01ecdd3b9d664a21777b72b5903d3ec69d6c9" alt=""><figcaption></figcaption></figure>

**Contraseña encontrada:**

```parser
OctopiFociPilfer45
```

<figure><img src="/files/93a03fb901737da30392292285b35f0ca1672ac6" alt=""><figcaption></figcaption></figure>

### **Iniciar sesión en el panel de administración de Ghost**

Con esta contraseña, intentamos conectarnos al panel de administración de Ghost usando la `dirección de correo admin@linkvortex.htb` :

* **Correo electrónico** : `dirección de correo admin@linkvortex.htb`
* **Contraseña**: `OctopiFociPilfer45`

<figure><img src="/files/20958fa9e968334933b19d9ae519eb7ef46ae07f" alt=""><figcaption></figcaption></figure>

## Vulnerabilidad de Ghost - LFI

{% embed url="<https://github.com/0xyassine/CVE-2023-40028>" %}

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

> Durante el escaneo de puertos, identificamos que la versión de Ghost utilizada (v5.58) es vulnerable a una vulnerabilidad LFI (Local File Inclusion), identificada como CVE-2023-40028. Para explotar esta vulnerabilidad, descargamos el script de explotación y modificamos la URL objetivo para que apunte a nuestra instancia de Ghost.

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

Aquí está el comando para ejecutar el exploit:

```bash
./LFI.sh -u admin@linkvortex.htb -p OctopiFociPilfer45
```

Entonces obtenemos una shell y podemos mostrar archivos, como `/etc/passwd`.

<figure><img src="/files/54f8dad7bc3f98e127e32ebfa8659274b7c585d3" alt=""><figcaption></figcaption></figure>

**Acceso a una ruta interna mediante LFI**

En el `.git` directorio, encontramos un archivo Docker que nos proporciona una ruta interna para acceder a una sesión: `/var/lib/ghost/config.production.json`.

<figure><img src="/files/9000730e7dd64d19c1d5e3bbab07c2f9f8510af1" alt=""><figcaption></figcaption></figure>

Usamos LFI para listar archivos y encontrar las credenciales de un usuario llamado Bob:

<figure><img src="/files/46b0701fc49247e235358f51bb842bc5d1259761" alt=""><figcaption></figcaption></figure>

**Credenciales de Bob:**

* **Usuario**: `bob@linkvortex.htb`
* **Contraseña**: `fibber-talented-worth`

Nos conectamos a la máquina objetivo mediante SSH usando las credenciales de Bob:

### Bandera user.txt :)

Usamos la contraseña `fibber-talented-worth` para iniciar sesión y acceder al archivo `user.txt`, donde encontramos la bandera.

<figure><img src="/files/79705bf29c9690ab0e412c01ba06fc41c39474b3" alt=""><figcaption></figcaption></figure>

## Bandera root.txt :)

### SUDO - Clean/\_synLink.sh

Buscamos una vulnerabilidad que permita la escalada de privilegios. Descubrimos un archivo con permisos SUID.

<figure><img src="/files/83a23494a684845b6bde22c0f0349ee497d4dca5" alt=""><figcaption></figcaption></figure>

#### **Análisis del script de limpieza de enlaces simbólicos**

> Analizamos un script llamado `clean_symlink.sh`, que comprueba si el archivo proporcionado como argumento es un enlace simbólico que apunta a un archivo `.png` . Si el enlace simbólico apunta a un archivo crítico, el script lo elimina. De lo contrario, mueve el enlace simbólico al `/var/quarantined/` directorio. Si la `CHECK_CONTENT` variable de entorno está establecida en `true`, el script intenta leer el contenido del archivo.

Aquí está el comando para crear los enlaces simbólicos necesarios para la explotación:

```bash
ln -s /root/root.txt flag.txt
ln -s /home/bob/flag.txt flag.png
```

Luego ejecutamos el script con el siguiente comando para obtener la bandera de root:

```bash
sudo CHECK_CONTENT=true /usr/bin/bash /opt/ghost/clean_symlink.sh /home/bob/flag.png 
```

Así obtenemos la `root.txt` bandera.

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

<figure><img src="/files/91f1ed848c601bf1b03c60720d93a856b005454e" alt="" width="524"><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/linkvortex-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.
