Enumeration from Outside AD
When you have network access to a target Active Directory environment but are NOT domain-joined and may have no credentials, you can still gather significant intelligence. This chapter covers all external enumeration techniques.
1. Scenario Overview
Your Position:
═════════════
┌─────────────────────────────────────────────┐
│ External Network (Your Attack Machine) │
│ │
│ ┌──────────┐ ┌──────────┐ │
│ │ Kali │ │ Tools │ │
│ │ Linux │───>│ nmap, │ │
│ │ │ │ dig, │ │
│ │ │ │ rpcclient│ │
│ └──────────┘ │ ldapsearch│ │
│ └──────────┘ │
│ │ │
│ │ Network Access │
│ ▼ │
│ ┌──────────────────────────────────────┐ │
│ │ Target Network │ │
│ │ │ │
│ │ ┌─────────┐ ┌─────────┐ │ │
│ │ │ DC01 │ │ DC02 │ │ │
│ │ │ LDAP │ │ LDAP │ │ │
│ │ │ SMB │ │ SMB │ │ │
│ │ │ DNS │ │ DNS │ │ │
│ │ └─────────┘ └─────────┘ │ │
│ └──────────────────────────────────────┘ │
└─────────────────────────────────────────────┘
What You Have:
├── Network access to the target
├── IP addresses (at least the DC)
├── NO domain credentials (initially)
├── Possible null session / anonymous access
└── Possible DNS zone transfer access
What You Want:
├── Domain name
├── User accounts
├── Group names
├── Computer names
├── Share names
├── Service information
└── Password policy
2. DNS Zone Transfers (AXFR)
DNS is often the first and most informative enumeration technique. Active Directory-integrated DNS stores records for every domain-joined object.
Why DNS is Critical for AD
| Reason | Detail |
|---|---|
| SRV Records | Reveal DC locations, Kerberos KDCs, Global Catalog servers |
| A Records | Reveal IP addresses of all domain-joined machines |
| Domain Name | The DNS zone name IS the domain name |
| Service Discovery | Mail servers, web servers, application servers |
| No Authentication Needed | Zone transfers often work without authentication |
Zone Transfer Commands
# Method 1: dig (most common)
dig AXFR @DC_IP target.com
# Method 2: nslookup
nslookup
> server DC_IP
> ls -l target.com
# Method 3: dnsenum
dnsenum -f nameservers.txt target.com
# Method 4: Python dnspython
python3 -c "
import dns.resolver
resolver = dns.resolver.Resolver()
resolver.nameservers = ['DC_IP']
answer = resolver.resolve('target.com', 'AXFR')
for rdata in answer:
print(rdata)
"
# Method 5: host command
host -l target.com DC_IP
DNS Record Types and What They Reveal
| Record Type | Information Revealed | Example | Attack Relevance |
|---|---|---|---|
| A | IPv4 address of a host | DC01 A 10.0.0.10 |
Identify targets for further attacks |
| AAAA | IPv6 address of a host | DC01 AAAA fe80::1 |
IPv6 targets |
| CNAME | Alias for a host | mail CNAME exch01 |
Service discovery |
| SRV | Service location (CRITICAL) | _ldap._tcp.dc._msdcs |
Identify DCs, GCs, Kerberos servers |
| MX | Mail server | MX 10 mail.corp.local |
Mail server targeting |
| NS | Name server | NS dc01.corp.local |
DNS infrastructure |
| TXT | Text records | TXT "v=spf1 ..." |
SPF records, verification |
| PTR | Reverse DNS | 10.0.0.10 PTR dc01.corp.local |
Hostname discovery |
SRV Records — The Most Important for AD
SRV records tell you exactly where AD services are running:
| SRV Record | Service Revealed | Format |
|---|---|---|
_ldap._tcp.dc._msdcs.target.com |
Domain Controllers | _service._protocol._msdcs.domain |
_kerberos._tcp.target.com |
Kerberos KDCs | _kerberos._tcp.domain |
_kerberos._udp.target.com |
Kerberos KDCs (UDP) | _kerberos._udp.domain |
_kpasswd._tcp.target.com |
Kerberos password change | _kpasswd._tcp.domain |
_gc._tcp.target.com |
Global Catalog servers | _gc._tcp.domain |
_ldap._tcp.pdc._msdcs.target.com |
PDC Emulator | _ldap._tcp.pdc._msdcs.domain |
_ldap._tcp.gc._msdcs.target.com |
GC in configuration partition | _ldap._tcp.gc._msdcs.domain |
Example Zone Transfer Output
$ dig AXFR @10.0.0.10 corp.local
corp.local. 900 IN SOA dc01.corp.local. admin.corp.local. 1 900 600 86400 900
corp.local. 900 IN NS dc01.corp.local.
dc01.corp.local. 900 IN A 10.0.0.10
dc02.corp.local. 900 IN A 10.0.0.11
file01.corp.local. 900 IN A 10.0.0.20
web01.corp.local. 900 IN A 10.0.0.30
ws01.corp.local. 900 IN A 10.0.0.100
ws02.corp.local. 900 IN A 10.0.0.101
_mail._tcp.corp.local. 900 IN SRV 0 100 25 mail.corp.local.
_ldap._tcp.dc._msdcs.corp.local. 900 IN SRV 0 100 389 dc01.corp.local.
_kerberos._tcp.corp.local. 900 IN SRV 0 100 88 dc01.corp.local.
_gc._tcp.corp.local. 900 IN SRV 0 100 3268 dc01.corp.local.
3. SMB Enumeration
SMB (Server Message Block) is the primary file sharing protocol in Windows environments. It can reveal users, groups, shares, and password policy.
Null Session Access
A null session is an unauthenticated SMB connection. If enabled, it allows anonymous enumeration of users, groups, and shares.
# Method 1: rpcclient (null session)
rpcclient -U "" DC_IP
# Method 2: smbclient (list shares)
smbclient -L \\\\DC_IP -U%
# Method 3: CrackMapExec
crackmapexec smb DC_IP -u '' -p ''
# Method 4: NetExec (newer CME)
netexec smb DC_IP -u '' -p ''
# Method 5: enum4linux
enum4linux -a DC_IP
What Null Sessions Reveal
| Information | Command | Example Output |
|---|---|---|
| Users | enumdomusers (in rpcclient) |
user:[jsmith] rid:[0x456] |
| Groups | enumdomgroups (in rpcclient) |
group:[Domain Users] rid:[0x201] |
| Shares | smbclient -L |
Shares: ADMIN$, C$, IPC$, SYSVOL |
| Password Policy | getdompwinfo (in rpcclient) |
min_pwd_length: 8, pwd_history: 24 |
| Domain Info | getdominfo (in rpcclient) |
domain:CORP, server:DC01 |
rpcclient Interactive Commands
# Connect with null session
rpcclient -U "" DC_IP
# Inside rpcclient:
rpcclient> enumdomusers # List all domain users
rpcclient> queryuser 0x1F4 # Get details for RID 0x1F4 (500 = Administrator)
rpcclient> enumdomgroups # List all domain groups
rpcclient> querygroup 0x200 # Get details for group RID 0x200
rpcclient> queryusergroups 0x1F4 # Get groups for user RID 0x1F4
rpcclient> getdompwinfo # Get domain password policy
rpcclient> getusrdompwinfo jsmith # Get user's password status
rpcclient> enumalsusers # List alias users
rpcclient> enumprivs # List privileges
rpcclient> quit
SMB Signing Check
SMB signing is critical for determining if NTLM relay attacks are feasible:
# Check SMB signing status
crackmapexec smb DC_IP -u '' -p ''
# Output example:
# [!] SMB Signing is NOT required on 10.0.0.10
# → NTLM relay attacks ARE possible
# If signing IS required:
# [+] SMB Signing is required on 10.0.0.10
# → NTLM relay attacks are NOT possible (without additional tricks)
4. RID Cycling
RID (Relative Identifier) Cycling is a technique to enumerate all user and group accounts by iterating through RID values.
How RIDs Work
SID Structure:
═════════════
S-1-5-21-1234567890-1234567890-1234567890-RID
│ │ │ │ │ │
│ │ │ │ │ └── Relative Identifier (unique per object)
│ │ │ │ └── Sub-authority 3
│ │ │ └── Sub-authority 2
│ │ └── Sub-authority 1
│ └── Identifier authority (5 = NT)
└── Security identifier revision (1)
Well-Known RIDs:
════════════════
RID 500 = Administrator (built-in admin account)
RID 501 = Guest
RID 512 = Domain Admins
RID 513 = Domain Users
RID 514 = Domain Guests
RID 515 = Domain Computers
RID 516 = Domain Controllers
RID 517 = Cert Publishers
RID 518 = Schema Admins
RID 519 = Enterprise Admins
RID 520 = Group Policy Creator Owners
RID 521 = Key Admins
RID 522 = Enterprise Key Admins
RID 526 = Read-only Domain Controllers (RODCs)
RID 528 = Cloneable Domain Controllers
RID 571 = Protected Users
Regular users typically start at RID 1000 and increment.
RID Cycling Commands
# Using Impacket lookupsid.py (automatic RID cycling)
lookupsid.py -no-pass DOMAIN/DC_IP
# Output example:
# [+] Enumering users with RPC protocols
# [+] Host: 10.0.0.10
# 2011: CORP\jsmith
# 2012: CORP\jdoe
# 2013: CORP\asmith
# ...
# Using rpcclient (manual RID cycling)
rpcclient -U "" DC_IP
rpcclient> queryuser 500 # Administrator
rpcclient> queryuser 501 # Guest
rpcclient> queryuser 1000 # First regular user
rpcclient> queryuser 1001 # Next user
# ... continue until you get "NT_STATUS_NO_SUCH_USER"
Why RID Cycling Works
- The SAMR (Security Account Manager Remote) API allows querying user/group information by RID.
- If null sessions are enabled, anyone can query any RID.
- By iterating through RID values (typically 500-50000), you can enumerate all accounts.
- This works even when LDAP is firewalled, as long as RPC (port 135/445) is accessible.
5. LDAP Queries (Anonymous/Null Session)
LDAP is the most powerful enumeration protocol for AD. Even anonymous or null session LDAP binds can reveal extensive information.
Anonymous LDAP Bind
# Basic anonymous query (no credentials)
ldapsearch -x -h DC_IP -b "DC=target,DC=com" "(objectClass=*)"
# Query users only
ldapsearch -x -h DC_IP -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)"
# Query OUs
ldapsearch -x -h DC_IP -b "DC=target,DC=com" "(objectClass=organizationalUnit)"
Null Session LDAP
# Null session (empty bind DN and password)
ldapsearch -x -h DC_IP -D "" -w "" -b "DC=target,DC=com" "(objectClass=user)"
# Query all attributes for users
ldapsearch -x -h DC_IP -D "" -w "" -b "DC=target,DC=com" \
"(objectClass=user)" sAMAccountName userPrincipalName description \
servicePrincipalName pwdLastSet lastLogonTimestamp userAccountControl
What Anonymous LDAP Can Reveal
| Object Type | Attributes Available | Attack Value |
|---|---|---|
| Users | sAMAccountName, displayName, mail, description, title, department | Account list, social engineering targets, password hints in descriptions |
| Groups | cn, member, description | Group structure, privileged group membership |
| Computers | cn, dnsHostName, operatingSystem, whenCreated | Target list, OS versions for exploit selection |
| OUs | ou, description | Organizational structure, GPO targeting |
| Domain | dc, description, whenCreated | Domain name, creation date |
6. enum4linux
enum4linux is a comprehensive Linux-based enumeration tool for Windows/SMB targets.
# Full enumeration (all checks)
enum4linux -a DC_IP
# Specific checks
enum4linux -U DC_IP # Users only
enum4linux -G DC_IP # Groups only
enum4linux -S DC_IP # Shares only
enum4linux -P DC_IP # Password policy only
enum4linux -O DC_IP # OS info only
enum4linux -d DC_IP # Domain info only
enum4linux -w DC_IP # Windows info only
enum4linux -M DC_IP # Connected shares (mountable)
# With credentials
enum4linux -a -u username -p password DC_IP
# Against a range of IPs
enum4linux-ng -U 10.0.0.0/24
What enum4linux Reveals
| Check | Information |
|---|---|
| -U (Users) | All domain user accounts with RIDs |
| -G (Groups) | All domain groups with members |
| -S (Shares) | All SMB shares and their permissions |
| -P (Password Policy) | Minimum length, complexity, history, lockout threshold |
| -O (OS Info) | Windows version, domain name, forest name |
| -d (Domain) | Domain name, SID, primary domain |
| -w (Windows) | LAN manager level, server string |
7. Port Scanning
Before enumerating, identify which services are running:
# Quick scan of common AD ports
nmap -sS -p 53,88,135,139,389,445,464,636,3268,3269 DC_IP
# Detailed scan with service detection
nmap -sS -sV -p 53,88,135,139,389,445,464,636,3268,3269 DC_IP
# Full scan (slower but thorough)
nmap -sS -sV -sC -p- DC_IP
# OS detection
nmap -O -sV DC_IP
# Network discovery (find all live hosts)
nmap -sn 10.0.0.0/24
Key AD Ports
| Port | Service | Protocol | Enumeration Value |
|---|---|---|---|
| 53 | DNS | TCP/UDP | Zone transfers, SRV records |
| 88 | Kerberos | TCP/UDP | AS-REP Roasting, Kerberos enumeration |
| 135 | RPC | TCP | RID cycling, SAMR API |
| 139 | NetBIOS | TCP | Legacy SMB, null sessions |
| 389 | LDAP | TCP | Directory enumeration (primary) |
| 445 | SMB | TCP | Shares, null sessions, signing check |
| 464 | kpasswd | TCP/UDP | Password change service |
| 636 | LDAPS | TCP | Encrypted LDAP |
| 3268 | GC LDAP | TCP | Global Catalog (forest-wide) |
| 3269 | GC LDAPS | TCP | Encrypted Global Catalog |
8. Outside Enumeration Checklist
| Technique | Tool | What You Get | Priority |
|---|---|---|---|
| DNS Zone Transfer | dig AXFR, dnsenum |
Hostnames, IPs, SRV records, domain name | P0 — Always try first |
| SMB Null Session | rpcclient, smbclient |
Users, groups, shares, password policy | P0 — If available, goldmine |
| LDAP Anonymous | ldapsearch |
Users, groups, computers, OUs, attributes | P0 — Most comprehensive |
| RID Cycling | lookupsid.py |
All user accounts (even if LDAP blocked) | P1 — Fallback for user enum |
| SMB Signing Check | crackmapexec |
Relay attack feasibility | P1 — Determines relay strategy |
| Port Scan | nmap |
Open services, OS detection, version info | P0 — Always do first |
| Share Access | smbclient |
Readable files, scripts, GPP passwords | P1 — If shares accessible |
| enum4linux | enum4linux -a |
Comprehensive SMB enumeration | P1 — All-in-one tool |
OSCP Exam Checklist: Outside Enumeration
Must-Know Techniques
- DNS zone transfer is the first thing to try — it reveals the entire network
- SRV records identify DCs, GCs, and Kerberos servers
- Null sessions can reveal users, groups, shares, and password policy
- RID cycling enumerates all accounts via SAMR API (ports 135/445)
- Anonymous LDAP can reveal users, groups, computers, and their attributes
- SMB signing status determines if NTLM relay attacks are possible
- Well-known RIDs: 500=Admin, 512=Domain Admins, 513=Domain Users, 515=Domain Computers
- Key AD ports: 53 (DNS), 88 (Kerberos), 389 (LDAP), 445 (SMB), 3268 (GC)
Must-Remember Commands
# DNS zone transfer
dig AXFR @DC_IP target.com
# SMB null session
rpcclient -U "" DC_IP
crackmapexec smb DC_IP -u '' -p ''
# RID cycling
lookupsid.py -no-pass DOMAIN/DC_IP
# Anonymous LDAP
ldapsearch -x -h DC_IP -b "DC=target,DC=com" "(objectClass=user)" sAMAccountName description servicePrincipalName
# Port scan
nmap -sS -sV -p 53,88,135,139,389,445,464,636,3268,3269 DC_IP
# Full enum4linux
enum4linux -a DC_IP