Hack The Box - Resolute

December 09, 2023

Resolute

Resolute is a Windows machine running Active Directory. A few different methods can be used to enumerate users on the system and reveal an initial account creation password in a description field. This can be leveraged for a password spray against a list of users, leading to a successful logon for one of the accounts. These credentials can be used to obtain a shell over WinRM. Once on the system, a PowerShell transcript directory can be discovered with a log file that contains another user's credentials which can then be used to move laterally. This user is a member of DnsAdmins, the privileges granted to this group can be exploited to inject a custom DLL into the DNS service, resulting in a system shell.

nmap scan:

nmap scan

Notable open ports:

  • 53 (DNS)
  • 88 (Kerberos)
  • 135, 593 (MSRPC)
  • 139, 445 (SMB)
  • 464 (kpasswd)
  • 389, 3268 (LDAP)
  • 636, 3269 (LDAPS)
  • 5985 (WinRM)

Active Directory:

  • domain: megabank.local
  • hostname: RESOLUTE

An anonymous login over SMB authenticated, but didn't provide access to any shares:

crackmapexec attempt to list shared

Next, I tried to enumerate domain users which was successful. One of the users (marko) had a field containing a default password used for the creation of accounts:

crackmapexec enumerate users

The credentials didn't authenticate when I attempted to use them to list the shares:

marko logon failure

Since the discovered password was used for the creation of new user accounts, this meant that the password could potentially still be in use for another account on the system, and I had a list of users to run a password spray attack.

I copied the crackmapexec output into a file called crackmapexec-users and used awk to extract just the usernames and saved it into a file called users:

awk users list

Running the password against the users list resulted in a successful logon for melanie:

melanie logon success

The credentials granted read access on the SYSVOL share, but I didn't find anything useful there. So next I tried making a connection using evil-winrm and was able to obtain a shell as melanie:

evil-winrm shell as melanie

After looking around on the system, eventually I found a hidden directory, C:\PSTranscripts:

PSTranscripts

PSTranscripts contained a PowerShell transcript:

PowerShell transcript log file

The file contained a recorded PowerShell session for the user ryan and one of the commands revealed a username and password:

cat log file

With the credentials, I was able to use evil-winrm to get a shell as ryan. The user was a member of a non-default group, Contractors:

evil-winrm shell as ryan

I ran whoami /groups and noticed that the user was also a member of DnsAdmins:

whoami groups

This was due to nested group membership since the Contractors group was a member of DnsAdmins:

contractors group membership

The DnsAdmins group has privileges specifically designed for the management and administration of the DNS service. Therefore, a user that is a member of this group can configure the DNS server to load a custom DLL that runs as SYSTEM when the service restarts.

HackTricks provides some more info on this type of attack, including an example of a valid DLL here.

So I started up a Windows VM and cloned the valid DLL repo mentioned above. Then, within DNSAdmin-DLL.cpp I modified the DnsPluginInitialize function to add a new user to Domain Admins:

DNSAdmin-DLL

After building the solution, DNSAdmin-DLL.dll was generated. I then transferred it to my Kali machine and started an SMB server:

start smb server

From the target machine, I ran dnscmd.exe to configure the DNS server to load DNSAdmin-DLL.dll from the remote UNC path:

dnscmd

Then, I restarted the DNS service:

stop dns

start dns

The SMB server showed an incoming connection:

smb server connection

Once the service restarted, a new user (mike) was added to the system as a Domain Admin:

net user mike

With administrative access, I was able to use psexec.py to get a shell as nt authority\system:

system shell


CTF Writeups | InfoSec Topics

Written by Mike Garrity

Email RSS