The following recipe shows how to abuse S4U2self for Local Privilege Escalation, or for stealthier alternative to Silver Ticket. There are also other tricks based on S4U2self, using u2u (user-to-user) as well: S4U2self + U2U.
Kerberos delegations allow services to access other services on behalf of domain users.
The "Kerberos" authentication protocol features delegation capabilities explained here. Kerberos delegations can be abused by attackers to obtain access to valuable assets and sometimes even escalate to domain admin privileges. Regarding constrained delegations and rbcd, those types of delegation rely on Kerberos extensions called S4U2Self and S4U2Proxy.
Simply put, Service for User to Self (S4U2self) allows a service to obtain a Service Ticket, on behalf of a user (called "principal"), to itself.
Last but not least, S4U2self can be used to produce a Service Ticket to oneself on behalf of another domain user, even if that user is "sensitive for delegation" or member of the Protected Users group. Consequently, this allows attackers, in very specific scenarios, to escalate their privileges or perform lateral movements.
Since machine accounts have their own set of SPNs by default at their creation, S4U2self can be used by any machine account, without any supplementary configuration. If an attacker manages to execute code as
NT AUTHORITY\NETWORK SERVICEor as any other "Microsoft Virtual Account" (e.g.
mssqlservice) he will be able to escalate his privileges by abusing S4U2self. This happens because this kind of accounts all act on the network as the machine itself.
The S4U2self abuse is not only a great way to perform Local Privilege Escalation or a lateral move, it's also an way more stealthier alternative to Silver Tickets when an attacker has knowledge of a machine account's Kerberos keys. While a Silver Ticket is a Service Ticket featuring a forged PAC, the Service Ticket issued after an S4U2self request will be legitimate and will feature a valid PAC.
In order to obtain local admin rights on a target machine, the attackers must be able to execute code on the machine and conduct two major steps: obtain a TGT for the machine account, and use that TGT to make a S4U2self request in order to obtain a Service Ticket as domain admin for the machine.
Rubeus.exe tgtdeleg /nowrap
Rubeus.exe tgtdeleg /nowrap
Alternatively, if the machine account credentials are known, a TGT can be requested commonly.
getTGT.py -dc-ip "domaincontroller" -hashes :"NThash" "domain"/"machine$"
From Windows machines, Rubeus (C#) can be used for that purpose. Howerver, this step is optional if Rubeus is to be used later on for the S4U2sel requestf. In this case, with the appropriate arguments, Rubeus will request a TGT automatically.
Rubeus.exe asktgt /nowrap /domain:"domain" /user:"computer$" /rc4:"NThash"
The TGT can then be used along with S4U2self to obtain a Service Ticket impersonating another domain user on the machine.
getST.py -self -impersonate "DomainAdmin" -altservice "cifs/machine.domain.local" -k -no-pass -dc-ip "DomainController" "domain.local"/'machine$'