Windows & AD Security: Introduction and Scope
Almost every organisation that runs Windows desks also runs Active Directory (AD): one directory that knows every user, every computer and every group, one set of domain controllers that decides who may sign in where, and one policy engine that pushes settings to every machine. That design is why a help-desk technician can reset any password from one console and why a new laptop is ready ten minutes after it joins the domain. It is also why incident reports of ransomware attacks read so alike: a phished workstation, a few hours of moving sideways, then Domain Admin, and from there every machine at once.
This course teaches Windows and AD the way a defender and an authorised tester need to know them: how each mechanism works, how it is misused, which events reveal the misuse, and which setting or design change removes it. The survey course Cybersecurity and the Security Foundations lessons on accounts and tokens and the Registry and Event Log are the on-ramp; the protocols on the wire are in LDAP and Kerberos and SMB, NFS and RDP; the methodology of a test is in Ethical Hacking & Penetration Testing. This course builds on all of them.
Before anything else: authorization and scope
This is an offensive-leaning course. You will learn how attackers move through a Windows domain, because the people who defend one can't close paths they can't see. That knowledge comes with a rule without exceptions:
Only assess directories and machines you own, or that you have written permission to test, and only within the agreed scope.
Querying someone else's directory, requesting tickets for their service accounts or relaying their authentication is not "just looking": in most countries it is unauthorised access even when nothing breaks, and an AD is usually the most sensitive system an organisation has. Before you test anything outside this course, read the law lessons of Security Foundations:
- Authorization, Scope and Rules of Engagement: what a written authorization contains, scope, test windows, stop conditions. For AD add: which accounts the tester may use, whether password guessing is allowed at all (it can lock real users out), and who is called when a domain admin credential is found.
- US Law: the CFAA, UK and EU Law and Vietnamese Law: what "unauthorised access" means where you live.
- Responsible Disclosure: what to do when you find a weakness in a product.
How this course keeps every example harmless
The track's safety line applies to every lesson:
- Mechanism → detection → fix. No lesson ends at the attack. Each weakness is followed by the event IDs and log fields that reveal it, a detection rule you can run, and the hardening that removes it.
- Models, not tools. The runnable parts are models you can read in full: Kerberos and NTLM computed in Python with toy keys the example makes itself, an AD object graph in NetworkX, event-log analysis in pandas on synthetic Security events, and PowerShell 7 working on synthetic exports (CSV and JSON shaped like what
Get-ADUserorGet-WinEventproduce). PowerShell here runs on Linux, so it has no AD module and no Windows APIs, which is exactly why every example brings its own data. - Named tools, no recipes. BloodHound, Impacket, Rubeus, Mimikatz, Certipy and the Sysinternals suite are named and described: what each does, what it touches, and how a defender sees it. You won't find command lines that dump real credentials, relay real authentication or request roastable tickets with working options; the transcripts that appear are labelled lab sessions with defender-side queries.
The lab domain
All transcripts and synthetic data use one isolated lab, an extension of the address plan in Lab Machines and Vulnerable Apps. The AD domain is corp.lab.test (NetBIOS name CORP), a child zone of the lab's lab.test names, which can never collide with a real site (RFC 6761).
| Host | Address | Role |
|---|---|---|
DC01.corp.lab.test |
10.10.0.20 | domain controller, DNS, KDC, PDC emulator |
WS01.corp.lab.test |
10.10.0.21 | Windows 11 workstation |
WS02.corp.lab.test |
10.10.0.22 | Windows 11 workstation |
FS01.corp.lab.test |
10.10.0.23 | file server |
CA01.corp.lab.test |
10.10.0.24 | AD Certificate Services |
SQL01.corp.lab.test |
10.10.0.25 | database server with a service account |
DC02.corp.lab.test |
10.10.0.26 | second domain controller (used in a few examples) |
SYNC01.corp.lab.test |
10.10.0.27 | Microsoft Entra Connect sync server |
kali.lab.test |
10.10.0.5 | the tester's workstation |
Scope for every lab session in this course: 10.10.0.0/24 and *.corp.lab.test, test accounts only, synthetic data only.
Why AD is the crown jewel
A domain controller holds the password-derived keys of every account, and the groups that administer it (Domain Admins, Enterprise Admins, Administrators of the domain and a few others) can change anything anywhere in the domain. So the question an attacker asks after the first foothold is not "what is on this laptop?" but "from here, how many steps to Domain Admins?". Defenders should ask the same question first. The model below is a tiny version of the attack-path analysis the course develops in Weak ACLs and Attack Paths as a Graph: each edge says "whoever controls the source can take over the target", for example because an admin's credentials are cached on a machine, or because a group may reset a password.
import networkx as nx
g = nx.DiGraph()
edges = [
("WS01", "helpdesk", "helpdesk signed in here: its credentials are in memory"),
("helpdesk", "WS02", "helpdesk is local admin on every workstation"),
("WS02", "srv-admin", "srv-admin signed in to WS02 last week"),
("srv-admin", "SQL01", "srv-admin administers the servers"),
("SQL01", "svc-sql", "the SQL service runs as svc-sql"),
("svc-sql", "Domain Admins", "svc-sql was added to Domain Admins 'temporarily'"),
("Domain Admins", "DC01", "admins of every domain controller"),
]
for a, b, why in edges:
g.add_edge(a, b, why=why)
start = "WS01"
reach = nx.descendants(g, start)
print(f"from a phished {start}: {len(reach)} of {g.number_of_nodes() - 1} other nodes reachable")
path = nx.shortest_path(g, start, "DC01")
print("shortest path:", " -> ".join(path), f"({len(path) - 1} steps)")
for a, b in zip(path, path[1:]):
print(f" {a} -> {b}: {g.edges[a, b]['why']}")
g.remove_edge("svc-sql", "Domain Admins") # fix: the service account leaves Domain Admins
print("after removing svc-sql from Domain Admins:", nx.has_path(g, start, "DC01"))from a phished WS01: 7 of 7 other nodes reachable
shortest path: WS01 -> helpdesk -> WS02 -> srv-admin -> SQL01 -> svc-sql -> Domain Admins -> DC01 (7 steps)
WS01 -> helpdesk: helpdesk signed in here: its credentials are in memory
helpdesk -> WS02: helpdesk is local admin on every workstation
WS02 -> srv-admin: srv-admin signed in to WS02 last week
srv-admin -> SQL01: srv-admin administers the servers
SQL01 -> svc-sql: the SQL service runs as svc-sql
svc-sql -> Domain Admins: svc-sql was added to Domain Admins 'temporarily'
Domain Admins -> DC01: admins of every domain controller
after removing svc-sql from Domain Admins: False
None of the seven edges is a software vulnerability. Each is a normal administrative habit: a technician signing in to fix a laptop, one admin account for all workstations, a service account with too many rights. That is the central lesson of AD security: most domain compromises use configuration, not exploits, so most of the defence is configuration too, and it can be checked.
The map
| Section | What you learn |
|---|---|
| Windows internals for defenders | SIDs and well-known groups, tokens, privileges and integrity levels, services and their accounts, the security-relevant Registry settings, LSASS and Credential Guard, event channels and the advanced audit policy, PowerShell logging, AMSI, Constrained Language Mode and JEA |
| Active Directory architecture | forests, domains, OUs and trusts, domain controllers, multi-master replication and FSMO roles, LDAP queries and userAccountControl, AD-integrated DNS and LLMNR poisoning, Group Policy processing and security filtering |
| Authentication | NTLM computed step by step, Kerberos AS/TGS/AP with toy keys, the PAC and encryption types (and why RC4 is going away), the three kinds of delegation |
| Common AD weaknesses | password spraying, Kerberoasting and AS-REP roasting, ACL attack paths, NTLM relay and coercion, AD CS ESC1–ESC8, DCSync, golden and silver tickets, GPO abuse, stale and privileged accounts: each with detection and fix |
| Detection | the key event IDs with Sysmon, a detection pipeline in pandas on synthetic 4624/4625/4662/4768/4769/5136 events, honeytokens |
| Hardening | tiered administration and PAWs, Windows LAPS and gMSA, Protected Users and removing NTLM, auditing ACLs and AD CS, backup and forest recovery |
| Practice | exercises and the mini project: a full security review of a synthetic domain |
How examples run here
```python runruns Python 3.13 in your browser with NetworkX, pandas,hashlib,hmacandcryptography. Every key, nonce and timestamp in a protocol model is fixed so the output is reproducible; real implementations draw them at random, and the text says so each time.```powershell runis recorded with PowerShell 7.6 on Linux: the language is the same as on Windows, the data comes from here-strings.```bash runblocks are sandbox sessions with real tools (dnsmasq, dig, OpenSSL) and no network.```consoleblocks are lab sessions on the machines above: sample output, abbreviated, not run here.
Practice
1. A colleague wants to "quickly check" which service accounts in a customer's domain have SPNs before the contract is signed. What do you answer?
Not before the authorization is signed and the scope names the domain and the accounts the tester may use. Enumerating a directory is access to a computer system; without permission it is unauthorised whatever the intent.
2. In the model, which single edge removal breaks the only path from WS01 to DC01, and why does any edge on the path work in this case?
The model removes svc-sql -> Domain Admins. Because the graph is a single chain, removing any of its seven edges breaks the path; in a real directory there are many parallel paths, and the attack-path lesson finds the edges that cut all of them.
3. Why does the course run PowerShell on synthetic exports instead of against a domain?
The runner is PowerShell 7 on Linux with no AD module and no Windows APIs, and the safety line forbids touching real systems. Exported CSV and JSON have the same shape as real Get-ADUser or Get-WinEvent output, so the analysis code is the same you would run on a real export in your own lab.
Test yourself
What must exist before you query a customer's Active Directory as a tester?
- A domain user account found on the Internet
- A written authorization with the scope, the test accounts and the allowed techniques
- Only verbal agreement from any employee
- Nothing; LDAP queries are read-only
Why do most AD compromises not need a software exploit?
- AD has no vulnerabilities
- Normal configuration (cached admin credentials, shared local admin passwords, over-privileged accounts and ACLs) chains into a path to Domain Admins
- Attackers always use zero-days
- Domain controllers have no passwords
Which address and name may a lab transcript in this course use?
- A customer's real DC
DC01.corp.lab.testat 10.10.0.20- Any public IP that answers on port 88
- The domain of a well-known company
Every attack lesson in this course follows which order?
- Exploit, then cover tracks
- Mechanism, detection, fix
- Tool options, then output
- Fix only