Summary
Enumerates domain controllers from the current or specified domain usingDomainController.FindAll(). Retrieves detailed information including IP addresses, OS versions, and Global Catalog status.
- Needs Admin: False
- Version: 2
- Author: @djhohnstein
Arguments
- domain (Optional String) - Target domain name (defaults to current domain)
Usage
Detailed Summary
Agent Execution Flow
1. Directory Context Creation
- Creates
DirectoryContextfor domain controller enumeration - Uses current domain context if no domain specified
- Targets specific domain if parameter provided
2. Domain Controller Discovery
- Uses
DomainController.FindAll()to discover all domain controllers - Returns collection of domain controller objects
- Queries Active Directory for controller information
3. Domain Controller Information Extraction
- Iterates through each discovered domain controller
- Extracts computer name, domain, forest, and OS information
- Determines Global Catalog server status
4. IP Address Resolution
- Attempts DNS resolution for each domain controller
- Concatenates multiple IP addresses with comma separation
- Falls back to
dc.IPAddressif DNS resolution fails - Handles cases where domain controllers have multiple IPs
5. Response Serialization
- Serializes domain controller array to JSON
- Returns structured data for browser interface processing
Data Structures
NetDomainController
Browser Interface Integration
The JavaScript processes the JSON response into an interactive table with:- Shares Button: Launches
net_sharescommand for each DC - Copy Icons: Allows copying computer names and IP addresses
- Global Catalog Indicator: Database icon for Global Catalog servers
- Sortable Columns: Name, domain, forest, IP, and OS version
Domain Controller Properties
- Computer Name: Fully qualified domain name of the DC
- IP Address: All network interfaces (IPv4/IPv6)
- Domain: The domain the DC serves
- Forest: The forest the domain belongs to
- OS Version: Windows Server version and build
- Global Catalog: Whether DC hosts Global Catalog database
Active Directory Integration
Uses .NET Framework’sSystem.DirectoryServices.ActiveDirectory namespace:
- DirectoryContext: Establishes connection context
- DomainController.FindAll(): Discovers all domain controllers
- DomainController Properties: Accesses DC metadata
- DNS Resolution: Resolves hostnames to IP addresses
APIs Used
| API | Purpose | Namespace |
|---|---|---|
DirectoryContext constructor | Create AD connection context | System.DirectoryServices.ActiveDirectory |
DomainController.FindAll() | Discover domain controllers | System.DirectoryServices.ActiveDirectory |
DomainController.IsGlobalCatalog() | Check Global Catalog status | System.DirectoryServices.ActiveDirectory |
Dns.GetHostAddresses() | Resolve hostname to IPs | System.Net |
MITRE ATT&CK Mapping
- T1590 - Gather Victim Network Information
- T1590.002 - DNS
Security Considerations
- Information Disclosure: Reveals critical AD infrastructure details
- Network Reconnaissance: Provides IP addresses and hostnames
- Attack Planning: Enables targeting of high-value domain controllers
- Detection Vectors: AD queries may be logged and monitored
Limitations
- Requires domain-joined context or valid credentials
- May fail if current user lacks domain query permissions
- DNS resolution dependent on network connectivity
- Cross-domain queries may require trust relationships
- Some DC properties may be restricted based on permissions
Error Conditions
- Access Denied: Insufficient permissions to query domain
- Domain Not Found: Specified domain doesn’t exist or isn’t reachable
- Network Unreachable: Cannot connect to domain controllers
- DNS Resolution Failure: Cannot resolve DC hostnames to IPs
- Trust Relationship: Cross-domain queries fail due to trust issues