TExcelTAD
Home › Windows & Active Directory Security › Windows & AD Security Exercises

Windows & AD Security Exercises

These exercises cover the whole course. Each one names the lessons it practises; try it before opening the answer. The runnable one builds its own synthetic data, so it is safe to run here. Everything you practise applies only to directories you own or are authorised to assess (Authorization, Scope and Rules of Engagement).

Exercise 1: read a token

A 4627 event for bob lists the groups Domain Users, IT-Helpdesk, Server-Ops and the SID S-1-5-21-1111111111-2222222222-3333333333-512. Bob is not listed in Domain Admins. Give two ways this can happen and the event that would have recorded each. Lessons: SIDs and tokens.

Answer

RID 512 is Domain Admins. Either nesting (Server-Ops or IT-Helpdesk is a member of Domain Admins; the change was a 4728/4756 on that group) or SID history (the SID was written into bob's sIDHistory; 4765, and 5136 on sIDHistory). Expand group nesting and check sIDHistory to tell them apart.

Exercise 2: services and the Registry

On SQL01 a review finds: service ReportSync running as CORP\adm-reports from C:\Tools\reportsync.exe, WDigest\UseLogonCredential = 1 and LocalAccountTokenFilterPolicy = 1. Rank the three by domain risk and give the fix for each. Lessons: services, registry settings.

Answer
  1. The service: anyone who can write C:\Tools runs code as a domain admin, and the password is in LSA secrets. Fix: gMSA without admin rights, program under C:\Program Files. 2. WDigest: every logon to SQL01 leaves a cleartext password in LSASS; also a possible sign of compromise. Set 0, investigate who set it, reset passwords of recent logons. 3. Token filter policy: shared local admin passwords work remotely. Set 0 and deploy Windows LAPS.

Exercise 3: decode the fields

Run the program and explain each line in one sentence. Lessons: LDAP and userAccountControl, encryption types, Kerberos.

python · try it yourself
UAC = {0x2: "ACCOUNTDISABLE", 0x20: "PASSWD_NOTREQD", 0x200: "NORMAL_ACCOUNT", 0x10000: "DONT_EXPIRE_PASSWORD",
       0x80000: "TRUSTED_FOR_DELEGATION", 0x100000: "NOT_DELEGATED", 0x400000: "DONT_REQ_PREAUTH",
       0x1000000: "TRUSTED_TO_AUTH_FOR_DELEGATION", 0x1000: "WORKSTATION_TRUST_ACCOUNT"}
ETYPE = {0x11: "aes128-cts-hmac-sha1-96", 0x12: "aes256-cts-hmac-sha1-96", 0x17: "rc4-hmac"}
SET = {0x4: "RC4", 0x8: "AES128", 0x10: "AES256"}

for name, uac in [("svc-legacy", 0x410200), ("WEB01
quot;, 0x1001000), ("adm0-alice", 0x100200)]: print(f"{name:11} uac=0x{uac:x}: " + ", ".join(v for k, v in UAC.items() if uac & k)) for etype in (0x17, 0x12): print(f"4769 Ticket Encryption Type 0x{etype:x} = {ETYPE[etype]}") mask = 0x1C print(f"msDS-SupportedEncryptionTypes 0x{mask:x} = " + " + ".join(v for k, v in SET.items() if mask & k))
svc-legacy  uac=0x410200: NORMAL_ACCOUNT, DONT_EXPIRE_PASSWORD, DONT_REQ_PREAUTH
WEB01$      uac=0x1001000: TRUSTED_TO_AUTH_FOR_DELEGATION, WORKSTATION_TRUST_ACCOUNT
adm0-alice  uac=0x100200: NORMAL_ACCOUNT, NOT_DELEGATED
4769 Ticket Encryption Type 0x17 = rc4-hmac
4769 Ticket Encryption Type 0x12 = aes256-cts-hmac-sha1-96
msDS-SupportedEncryptionTypes 0x1c = RC4 + AES128 + AES256
Answer

svc-legacy is AS-REP roastable with a password that never expires: turn pre-authentication on, long random password. WEB01$ is a computer with constrained delegation and protocol transition (TRUSTED_TO_AUTH_FOR_DELEGATION), so it can impersonate any non-protected user to its listed SPNs. adm0-alice is marked sensitive, so no service can delegate her. 0x17 is an RC4 ticket (Kerberoasting signal in an AES domain), 0x12 AES256. 0x1C still allows RC4: set 0x18.

Exercise 4: where is the forest boundary?

The subsidiary eu.corp.lab.test wants its own Domain Admins "so that if they are hacked, corp is safe". What do you answer, and what design gives them the isolation they want? Lesson: forests and trusts.

Answer

A child domain is not a security boundary: its admins control DCs that the whole forest trusts and can forge tickets with forest-root SIDs. Real isolation is a separate forest with a forest trust, SID filtering on and selective authentication, or simply delegated OUs in one domain if isolation isn't actually needed.

Exercise 5: NTLM on the wire

A 4624 on FS01: account alice, logon type 3, package NTLM V2, workstation WS01, source 10.10.0.66; FS01 doesn't require SMB signing. What happened, which two settings would have prevented it, and which earlier events would you look for? Lessons: NTLM, relay, AD DNS.

Answer

A relay: the NTLM message came from WS01 but arrived from another host. SMB signing required on FS01 would have blocked the session; LLMNR/NBT-NS off (or no coercion path) would have denied the relay its victim. Look for LLMNR/NBT-NS answers from 10.10.0.66 to WS01 shortly before, or coercion RPC calls (5145 on \spoolss, \efsrpc).

Exercise 6: one ticket, many keys

For each artefact, name the key that protects it and the attack that targets it: (a) the AS-REP's encrypted part; (b) a TGT; (c) a service ticket for MSSQLSvc/sql01.corp.lab.test:1433; (d) the PAC's KDC signature. Lessons: Kerberos, PAC, roasting, forged tickets.

Answer

(a) the user's key: AS-REP roasting when pre-authentication is off. (b) krbtgt's key: golden tickets. (c) the service account's key (svc-sql): Kerberoasting, and silver tickets if the key is stolen. (d) krbtgt's key: it is what stops a holder of only the service key from forging a PAC that the KDC accepts.

Exercise 7: delegation review

Findings: PRINT01$ has unconstrained delegation; APP01$ has constrained delegation with protocol transition to cifs/fs01; FS01$ lists WEB02$ in msDS-AllowedToActOnBehalfOfOtherIdentity; ms-DS-MachineAccountQuota is 10; no admin is in Protected Users. Order the fixes. Lesson: delegation.

Answer
  1. Remove unconstrained delegation from PRINT01 (with coercion it yields DC TGTs) and disable its Spooler exposure to DCs. 2. Put Tier 0 and Tier 1 admins in Protected Users and mark them sensitive (closes every delegation path to them). 3. Set the machine account quota to 0. 4. Review APP01's protocol transition need. 5. Confirm WEB02 → FS01 is intended and that writes to that attribute are restricted and monitored (5136).

Exercise 8: spray or not?

Between 02:00 and 02:20, DC01 logs 4771 code 0x18 for 300 different accounts, one each, all from 10.10.0.5, then 4768 success for svc-test from the same address. 10.10.0.5 is kali.lab.test. What do you do first? Lesson: password spraying.

Answer

Check the authorization: is a test with password guessing in scope tonight, from this host? If yes, record the finding (svc-test has a sprayable password) and tell the client contact as the rules of engagement require. If not, it is an incident: treat svc-test as compromised, reset it, investigate the tester's machine and the account's activity.

Exercise 9: the cheapest cut

In an attack graph, 40 users reach Domain Admins. All paths pass through either SQL01 -HasSession-> da-erin or Exchange-Perms -WriteDacl-> domain. A colleague proposes removing everyone's local admin rights on 200 workstations first. Argue for a different order. Lesson: attack paths.

Answer

The two edges are a minimum cut: removing them (no domain admin sessions on servers, removing the legacy WriteDacl) closes every path today, at low cost. The workstation clean-up is still worth doing, but as hygiene after the cut, because it removes only some paths and takes months.

Exercise 10: AD CS

The template VPN-Users lets Domain Users enroll, has the Client Authentication EKU and the flag "Supply in the request". Which ESC is it, which CA event and field show abuse, and what is the fix? Lesson: AD CS.

Answer

ESC1. Event 4887 (issued) with requester CORP\<user> and a SAN/UPN naming a different, often privileged, account. Fix: subject built from AD (remove "Supply in the request") or require CA manager approval, and restrict enrollment to the VPN group; revoke certificates issued with mismatched SANs.

Exercise 11: DCSync rule

Write in words the detection rule for DCSync, including its allow-list, and say which audit settings it needs. Lessons: DCSync, audit policy, detection pipeline.

Answer

On every DC: event 4662 whose Properties contain 1131f6ad-9c07-11d1-f79f-00c04fc2dcd2 and whose subject is not a DC computer account using its own address, and not the documented sync account from the sync server's address. Needs Directory Service Access auditing (Success) and the default SACL on the domain root, forwarded from all DCs.

Exercise 12: recovery

After a confirmed golden ticket, the team resets krbtgt once and closes the incident. List what is missing. Lessons: forged tickets, backup and recovery.

Answer

The second krbtgt reset after the maximum ticket lifetime; finding and removing how the key was obtained (DCSync rights, a DC or backup compromise); resets of Tier 0 and service accounts and affected computer accounts; checking for directory persistence (admins, ACEs, SID history, GPOs, AD CS); and verifying that backups from before the compromise exist and are protected.

Test yourself

Which pair of facts makes Kerberoasting possible?

  1. SMB1 and LLMNR
  2. Any user can get a service ticket for any SPN, and it is encrypted with the service account's (possibly weak) key
  3. RC4 and NTLM relay
  4. DNS and DHCP

Which setting most directly stops NTLM relay to a file server?

  1. SMB signing required
  2. A longer lockout duration
  3. RC4 disabled
  4. Credential Guard

Which event is a single-event incident in most domains?

  1. 4624 type 3
  2. 4662 with the Get-Changes-All GUID by a non-DC account
  3. 4769 with AES
  4. 4634

What does tiered administration remove from the attack graph?

  1. MemberOf edges
  2. Sessions of higher-tier accounts on lower-tier machines
  3. All ACLs
  4. DNS records