Exploiting Unconstrained Delegation
Exploiting Unconstrained Delegation
Listen Share
Will Harmjoy and Co. used this technique to cross the forest boundary in particular
scenarios, but since I’m a little boy we’ll start small and care only about the domain
context.
The Theory
Today we’re going to see how to exploit unconstrained delegation with the objective
of compromising the whole AD domain. But what’s unconstrained delegation?
https://medium.com/@riccardo.ancarani94/exploiting-unconstrained-delegation-a81eabbd6976 1/23
12/27/23, 3:25 PM Exploiting Unconstrained Delegation | by Riccardo Ancarani | Medium
Vanilla Kerberos has no way of telling the first server: “OK you can access resources
of server 2 on client’s behalf”
This is where unconstrained delegation comes into play, when the client sends a
TGS to access the first server with unconstrained delegation they will attach their
TGT in the same request. In this way the first hop server has a TGT for the client’s
account, and can request a TGS to access the second hop server on their behalf.
So what’s the problem with that? Well, if an attacker compromises a server with
unconstrained delegation enabled, they can extract TGTs of the accounts that have
attempted a connection to the first hop server.
How can we force a connection to a server with unconstrained delegation? I’ll give
you a few options:
Responder
ARP Poisoning
Rogue DHCPv6
Phish an adin
SpoolSample
https://medium.com/@riccardo.ancarani94/exploiting-unconstrained-delegation-a81eabbd6976 2/23
12/27/23, 3:25 PM Exploiting Unconstrained Delegation | by Riccardo Ancarani | Medium
Inject the TGT into the current low privileged user context.
https://medium.com/@riccardo.ancarani94/exploiting-unconstrained-delegation-a81eabbd6976 3/23
12/27/23, 3:25 PM Exploiting Unconstrained Delegation | by Riccardo Ancarani | Medium
The computer we’re going to configure with delegation is “HELPDESK”, so let’s right
click on it and go on Properties.
In the Delegation tab you’ll see that the default value for a regular computer is “Do
not trust this computer for delegation”, as shown in the figure below:
https://medium.com/@riccardo.ancarani94/exploiting-unconstrained-delegation-a81eabbd6976 4/23
12/27/23, 3:25 PM Exploiting Unconstrained Delegation | by Riccardo Ancarani | Medium
cool cool cool, but let’s change it to “Trust this computer for delegation to any
service”:
https://medium.com/@riccardo.ancarani94/exploiting-unconstrained-delegation-a81eabbd6976 5/23
12/27/23, 3:25 PM Exploiting Unconstrained Delegation | by Riccardo Ancarani | Medium
and apply.
Congratulations! You just configured unconstrained delegation!
Not let’s shift to the attacker perspective and start smashing this bad boi.
Reconnaissance
For the reconnaissance phase I’m going to use the mighty AD module (
https://github.com/samratashok/ADModule). While I know that nowdays PowerShell
is monitored as hell, this is not a red teaming exercise where we need to stay low.
NOTE: I’m skipping how to import the module, download it and Import-Module
https://medium.com/@riccardo.ancarani94/exploiting-unconstrained-delegation-a81eabbd6976 6/23
12/27/23, 3:25 PM Exploiting Unconstrained Delegation | by Riccardo Ancarani | Medium
The cmdlet we’re going to use is the following, we’re seeking computer objects with
the property TrustedForDelegation set to true:
Exploitation
In order to exploit unconstrained delegation we need to compromise the system
with the delegation enabled, in this post we’ll assume that we already did it.
Some of the ways in which we could have compromised that system are the
following:
https://medium.com/@riccardo.ancarani94/exploiting-unconstrained-delegation-a81eabbd6976 7/23
12/27/23, 3:25 PM Exploiting Unconstrained Delegation | by Riccardo Ancarani | Medium
We could achieve this in multiple ways, but since we’re so cool we’re going to use the
SpoolSample bug to force a domain controller account to connect to us (
https://www.slideshare.net/harmj0y/derbycon-the-unintended-risks-of-trusting-
active-directory)
but before doing that we’re setting up Rubeus on the machine we compromised to
listen for incoming authenticated connections.
In order to monitor for incoming connections with Rubeus we need to run the
following command from an elevated context:
To execute the SpoolSample bug we’re using the tool written by Lee Christensen (
https://github.com/leechristensen/SpoolSample) with the following syntax:
where:
https://medium.com/@riccardo.ancarani94/exploiting-unconstrained-delegation-a81eabbd6976 8/23
12/27/23, 3:25 PM Exploiting Unconstrained Delegation | by Riccardo Ancarani | Medium
that means that the computer object HACKER.LAB\DC01$ connected to the machine we
control, since unconstrained delegation was enabled on that machine we now have
a valid TGT we can use to impersonate the domain controller machine account!
https://medium.com/@riccardo.ancarani94/exploiting-unconstrained-delegation-a81eabbd6976 9/23
12/27/23, 3:25 PM Exploiting Unconstrained Delegation | by Riccardo Ancarani | Medium
Grab the base64 blob you got from Rubeus and run the following command, from a
regular user’s context:
Rubeus.exe ptt
/ticket:doIE+DCCBPSgAwIBBaEDAgEWooIEBjCCBAJhggP+MIID+qADAgEFoQwbCkhB
Q0tFUi5MQUKiHzAdoAMCAQKhFjAUGwZrcmJ0Z3QbCkhBQ0tFUi5MQUKjggPCMIIDvqAD
AgES[SNIP]
https://medium.com/@riccardo.ancarani94/exploiting-unconstrained-delegation-a81eabbd6976 10/23
12/27/23, 3:25 PM Exploiting Unconstrained Delegation | by Riccardo Ancarani | Medium
If everything went well, you should be able to see the TGT of the DC01$ account with
a Rubeus.exe klist :
Search
https://medium.com/@riccardo.ancarani94/exploiting-unconstrained-delegation-a81eabbd6976 11/23
12/27/23, 3:25 PM Exploiting Unconstrained Delegation | by Riccardo Ancarani | Medium
If you’re familiar with BloodHound you can see that the object DC01.HACKER.LAB is
part of the group “Domain Controllers”, which has GetChangesAll over the domain
object HACKER.LAB. Which, as you can guess, means that if we manage to
impersonate the DC01 account we can DCSync and retrieve the NTLM hash of every
user in the domain.
https://medium.com/@riccardo.ancarani94/exploiting-unconstrained-delegation-a81eabbd6976 12/23
12/27/23, 3:25 PM Exploiting Unconstrained Delegation | by Riccardo Ancarani | Medium
Game over, we can now forge golden tickets to do all the greasy dirty stuff we all like
to do.
Just to give this post a proper end, let’s forge a golden ticket with Mimikatz for the
user HACKER\Administrator:
https://medium.com/@riccardo.ancarani94/exploiting-unconstrained-delegation-a81eabbd6976 13/23
12/27/23, 3:25 PM Exploiting Unconstrained Delegation | by Riccardo Ancarani | Medium
We can now PS remote into the domain controller as the user Administrator:
Remedial Actions
The general recommendation would be to use constrained delegation instead of the
unconstrained one.
With constrained delegation you (sysadmin) specify the services that the server with
delegation enabled can access while impersonating another user. However
constrained delegation is not the silver bullet, and in specific cases can be even
more dangerous than unconstrained delegation (you don’t need to force a
connection to the server to trigger S4U and impersonate someone, plus the service
part of the SPN is not validated)
Resources
Rubeus: https://github.com/GhostPack/Rubeus
https://medium.com/@riccardo.ancarani94/exploiting-unconstrained-delegation-a81eabbd6976 14/23
12/27/23, 3:25 PM Exploiting Unconstrained Delegation | by Riccardo Ancarani | Medium
SpoolSample: https://github.com/leechristensen/SpoolSample
AD-Module: https://github.com/samratashok/ADModule
STICKERSSSS: https://www.redbubble.com/people/gentilkiwi/works/32422547-
mimikatz-dcsync-and-dcshadow?p=sticker
Follow
https://medium.com/@riccardo.ancarani94/exploiting-unconstrained-delegation-a81eabbd6976 15/23
12/27/23, 3:25 PM Exploiting Unconstrained Delegation | by Riccardo Ancarani | Medium
Riccardo Ancarani
23
https://medium.com/@riccardo.ancarani94/exploiting-unconstrained-delegation-a81eabbd6976 16/23
12/27/23, 3:25 PM Exploiting Unconstrained Delegation | by Riccardo Ancarani | Medium
Riccardo Ancarani
13
Riccardo Ancarani
100 2
Riccardo Ancarani
11
https://medium.com/@riccardo.ancarani94/exploiting-unconstrained-delegation-a81eabbd6976 18/23
12/27/23, 3:25 PM Exploiting Unconstrained Delegation | by Riccardo Ancarani | Medium
51
https://medium.com/@riccardo.ancarani94/exploiting-unconstrained-delegation-a81eabbd6976 19/23
12/27/23, 3:25 PM Exploiting Unconstrained Delegation | by Riccardo Ancarani | Medium
Lists
Icon Design
33 stories · 186 saves
Productivity
234 stories · 249 saves
Karol Mazurek
https://medium.com/@riccardo.ancarani94/exploiting-unconstrained-delegation-a81eabbd6976 20/23
12/27/23, 3:25 PM Exploiting Unconstrained Delegation | by Riccardo Ancarani | Medium
9 1
Joey Brides
https://medium.com/@riccardo.ancarani94/exploiting-unconstrained-delegation-a81eabbd6976 21/23
12/27/23, 3:25 PM Exploiting Unconstrained Delegation | by Riccardo Ancarani | Medium
Gustav Shen
90
purpleXsec
https://medium.com/@riccardo.ancarani94/exploiting-unconstrained-delegation-a81eabbd6976 22/23
12/27/23, 3:25 PM Exploiting Unconstrained Delegation | by Riccardo Ancarani | Medium
Few weeks ago I passed OSCP with 110/100 after a brain frying 24 hours exam, here’s the
formula I followed along that would hopefully help…
137 1
https://medium.com/@riccardo.ancarani94/exploiting-unconstrained-delegation-a81eabbd6976 23/23