Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.
ADADCSBACKUP OPERATORSESC13GET-WRITEABLEGMSASENSITIVE FILE DISCLOSUREWINDOWS

Kitsune

Challenge Lab (Easy) - by xjr

The following post by 0xb0b is licensed under CC BY 4.0


Scenario

Objective

You have been hired to perform an internal pentest against the client's Domain Controller. Your task is to identify all vulnerabilities and (if possible) fully compromise the Domain.

Initial Access

The client has provided you with VPN access to their environment, but no other information.

Summary

Summary

In Kitsune, we begin with a port scan against a Windows Domain Controller, DC01.kitsune.local, exposing DNS on port 53, Kerberos on 88, LDAP on 389/636, SMB on 139/445, WinRM on 5985, RDP on 3389, and an enterprise CA (kitsune-DC01-CA). SMB allows guest authentication, revealing a readable Files share containing a logins.psafe3 Password Safe database. We extract a hash with pwsafe2john and crack it using john with rockyou.txt, recovering three credential pairs. One of them, ranch, authenticates successfully against SMB.

With the user ranch we enumerate the AD furhter, but the BloodHound enumeration shows no direct privilege escalation paths, but membership in the Certificate Service DCOM Access group prompts AD CS enumeration. Via Certipy we identify the Kitsune-User template as vulnerable to ESC13. Its issuance policy OID is linked to the HelpDesk group, which holds GenericAll over the user schlop. We request a certificate with -key-size 4096 to meet the minimum key length, authenticate with the resulting PFX to obtain a Kerberos ticket granting HelpDesk privileges, and use bloodyAD to reset schlop's password. An evil-winrm session as schlop yields to the user flag at C:\Users\schlop\Desktop\user.txt.

In schlop's Documents folder, a DPAPI-encrypted PSCredential file called networkAuth.cred is found. It is possible to decrypt it in the current session via Import-CliXml, revealing pebble's password. The user pebble is a member of the IT group, which has ReadGMSAPassword over SVC_GMSA$. We retrieve the gMSA NTLM hash with NetExec. Since SVC_GMSA$ is a Backup Operator, we remotely back up the SAM and SYSTEM registry hives using the backup_operator module of NetExec, extract the Administrator’s NTLM hash, and pass it to evil-winrm to obtain a shell as Administrator, recovering the root flag at C:\Users\Administrator\Desktop\root.txt.

Recon

We use rustscan -b 500 -a 10.1.165.166 --top -- -sC -sV -Pn to enumerate all TCP ports on the target machine, piping the discovered results into Nmap which runs default NSE scripts -sC, service and version detection -sV, and treats the host as online without ICMP echo -Pn.

A batch size of 500 trades speed for stability, the default 1500 balances both, while much larger sizes increase throughput but risk missed responses and instability.

The target 10.1.165.166 is a Domain Controller, DC01.kitsune.local, in the kitsune.local domain. DNS is exposed on port 53 and Kerberos on port 88, alongside Kerberos password change on port 464. LDAP and LDAPS services are available on ports 389 and 636, with the Global Catalog on ports 3268 and 3269. SMB is exposed via ports 139 and 445 with message signing enabled and required. Remote management and access are available through RDP on port 3389 and WinRM on port 5985. The host also exposes AD Web Services on port 9389, RPC over HTTP on port 593, and several MSRPC endpoints on ports 135, 49664–49744. The system is running Windows build 10.0.26100 and has an enterprise CA named kitsune-DC01-CA issuing certificates for the domain.

SMB

We'll follow the orange-cyberdefense mindmap. Since we do not have any users yet, we try to authenticate as guest or anonymously agains SMB.

We are able to successfully authenticate as guest and immediately find a share called Files that we are authorized to read from. Furthermore we have read access to the IPC$ share, which allows us to perform a rid brute force to enumerate further users of the domain.

We'll create an entry for our /etc/hosts file...

... and add the following line to our /etc/hosts file.

Access as ranch

We continue by connecting to the share found earlier using smbclient.py and retrieve all documents and files from the share. The PDF documents don't seem to be of interest to us, but the psafe file.

The PSAFE3 file format is a database file format used by Password Safe, an open-source password manager intially designed by Bruce Schneier. It stores encrypted usernames, passwords, and other credentials lie a Keepass file in a single file protected by a master passphrase. This file might contain credentials that we could use for our next steps.

To open the file we need psafe.

In my case, I wasn't able to install psafe properly on my ARM-based Exegol instance, so I tried using psafe installed on a Mac via brew.

But first, we need the password. We can use psafe2john to extract a hash from the file, then attempt to crack it using john with a wordlist. It works similarly like keepass2john or zip2john.

We attempt to crack the hash using john and are successful.

Unfortunately, I couldn't open the file on MacOs using pwsafe, even though I entered what I thought was the correct password. This might have been due to a compatibility issue using an old version for psafe3.

Instead, we can also use the Python package pypwsafev3 in a script to open the file and obtain three credential pairs.

It turns out that we can successfully authenticate as ranch. In addition to read permissions on files, we now also have write permissions. We could use the write permissions, if possible, for an NTLM theft attack. But it did not prove to be effective.

BloodHound Enumeration

Since we are now able to authenticate as a valid user agains the DC we start to enumerate the target using BloodHound.

We see that the user does not have any special permissions or group memberships that would allow us to escalate privileges or move laterally on first sight. But the user is member of the Certificate Service DCOM Access group, which allows interaction with the Active Directory Certificate Services (AD CS). We could enumerate certificate templates to check for potential misconfigurations.

We identify the Administrator account as the Domain Admin.

Shell as schlop

Using bloodyAD's get_writable, we found no additional writable objects for this user. So we continue with enumerating the AD CS for some possible misconfiguration like mentioned before. For this we utilize the latest version of certipy. We filter for vulnerable templates using the -vulnerable flag to identify any misconfigurations that could be exploited for privilege escalation

We inspect the results...

... and see that the Kitsune-User template is vulnerable to ESC13.

ESC13 abuses certificate templates where an issuance policy OID is linked to an AD group. When we request a certificate from that template, the issued certificate effectively grants us the privileges of the linked group... without actually being added as a member.

ESC13 describes a privilege escalation scenario where a certificate template is configured with an "Issuance Policy" that, through an OID configuration in Active Directory, is linked to a specific AD security group. If an attacker can enroll for such a template, the certificate they obtain can effectively grant them the privileges associated with that linked AD group during Kerberos authentication.

In this case by requesting a certificate from the Kitsune-User template would give us the HelpDesk group privileges through the certificate, letting us act as if you were a member of that group.

In our BloodHound data, we see that the HelpDesk group has GenericAll over the user schlop. This allows us to compromise that account by chaning it's password for example.

We see that the user schlop is in the remote management users group, so we could get a remote session on the target. We'll follow the path.

We follow the privilege escalation steps shown in the certipy wiki.

If we haven't already done so, we'll add the CA to our /etc/hosts file.

Next, we request the vulnerable certificate and retrieve the PFX, but we'll receive an error. The public key does not meet the minimum size required.

As a work around we re-request the certificate with -key-size 4096 and retrieve the PFX, granting us the permissions of the template's linked group as ranch.

Next, we authenticate using the resulting certificate file an retrieve the ccache file.

We export KRB5CCNAME=ranch.ccache so the Kerberos libraries know which credential cache to use when authenticating...

... and check again our writeable permissions using bloodyAD.

We see, we have full write permissions the user object schlop.

We reset the password of the schlop account to a known value, allowing us to authenticate as that user.

We test the credentials and are now able to authenticate as schlop.

Next, we try to get a remote session using evil-winrm and are successful. We are able to retrieve the user flag at C:\Users\schlop\Desktop\user.txt.

Access as pebble

We find a PSCredential file called networkAuth.cred in the Documents folder of schlop containing stored credentials for the user pebble. Since we're running as schlop, we can decrypt the password directly using PowerShell's Import-CliXml.

Like mentioned before, the password is DPAPI-encrypted, tied to the schlop user's Windows session. Since we have a shell as schlop, you can decrypt it right there in PowerShell. We retrieve the password of pebbel.

We try to authenticate as pebble with the recovered password and are successful.

Access as SVC_GMSA$

We can see that the user pebble is member of the IT group which has the ReadGMSAPassword permission over the SVC_GMSA$ machine account, which allows us to retrieve its NTLM hash and authenticate as that account.

The SVC_GMSA$ account is a member of the Backup Operators group, which grants SeBackupPrivilege on the domain controller, allowing us to dump the NTDS.dit and extract all domain password hashes.

Backup Operators can backup or restore Active Directory and have logon rights to Domain Controllers 🔥 its members can remotely backup the necessary registry hives to dump SAM & LSA secrets, or backup the NTDS.dit and SYSTEM hive to extract domain credentials offline (Backup Operators do not hold the replication extended rights required for DCSync)

We follow the depicted path from our BloodHound enumeration and retrieve the gMSA NTLM hash using NetExec.

We verify that the hash works.

Shell as Administrator

We follow the same Backup Operators approach as in the Odyssey scenario:

Since SVC_GMSA$ is a member of Backup Operators, we can remotely back up the SAM and SYSTEM registry hives from the domain controller. Note that Backup Operators do not have the replication rights required for DCSync, so we extract credentials offline instead.

Using reg.py with an SMB share tends to time out, so we can alternatively use NetExec's backup_operator module.

We use the backup_operator module and are able to retrieve the Administrators hash.

Finally, we try to get a remote session using evil-winrm as Administrator and retrieve the root flag at C:/Users/Administrator/Desktop/root.txt.

Last updated