Domain Enumeration
Comprehensive Active Directory reconnaissance to map domain structure, users, groups, trusts, and attack paths.
Methodology
- 1Enumerate domain users and groups
- 2Identify computers and services
- 3Map Group Policy Objects
- 4Analyze ACLs for privilege escalation paths
- 5Identify trust relationships
- 6Use BloodHound for attack path analysis
Detailed Steps
PowerView (PowerSploit):
powershell
# Import PowerView
Import-Module .\PowerView.ps1
# Get current domain
Get-Domain
# Get domain SID
Get-DomainSID
# Get domain policy
Get-DomainPolicy
(Get-DomainPolicy)."system access"
(Get-DomainPolicy)."kerberos policy"
# Get domain controllers
Get-DomainController
# List all users
Get-DomainUser
Get-DomainUser -Identity student1
# List user properties
Get-DomainUser -Properties samaccountname,logoncount
# Search for specific user attributes
Get-DomainUser -LDAPFilter "Description=*password*" | Select name,DescriptionAD Module (Microsoft):
powershell
# Get domain info
Get-ADDomain
# Get domain controllers
Get-ADDomainController
# Get all users
Get-ADUser -Filter *
Get-ADUser -Identity student1 -Properties *
# Get specific properties
Get-ADUser -Filter * -Properties Description | Where {$_.Description -like "*pass*"}Enumerate groups:
powershell
# PowerView
Get-DomainGroup
Get-DomainGroup -Identity "Domain Admins"
Get-DomainGroup *admin*
# Get members of specific group
Get-DomainGroupMember -Identity "Domain Admins"
Get-DomainGroupMember -Identity "Enterprise Admins" -Recurse
# Get groups a user is member of
Get-DomainGroup -UserName student1
# AD Module
Get-ADGroup -Filter *
Get-ADGroup -Identity "Domain Admins"
Get-ADGroupMember -Identity "Domain Admins"
Get-ADPrincipalGroupMembership -Identity student1Local admin enumeration:
powershell
# Find machines where current user has local admin
Find-LocalAdminAccess
# Find local admins on all machines (noisy!)
Invoke-EnumerateLocalAdmin
# Find computers where Domain Admin has session
Invoke-UserHunter
Invoke-UserHunter -GroupName "RDPUsers"powershell
# PowerView
Get-DomainComputer
Get-DomainComputer -OperatingSystem "*Server 2019*"
Get-DomainComputer -Ping
# Get computer properties
Get-DomainComputer -Properties dnshostname,operatingsystem,operatingsystemversion
# AD Module
Get-ADComputer -Filter *
Get-ADComputer -Filter 'OperatingSystem -like "*Server 2019*"' -Properties *File share enumeration:
powershell
# Find shares
Invoke-ShareFinder
# Find sensitive files
Invoke-FileFinder
# Find specific file types
Invoke-FileFinder -Terms "pass,cred,secret" -OutFile results.txtGroup Policy Objects:
powershell
# PowerView
Get-DomainGPO
Get-DomainGPO -ComputerIdentity dcorp-student1
# Get GPO applied to a computer
Get-DomainGPO -ComputerName dcorp-dc.dollarcorp.moneycorp.local
# Get OUs
Get-DomainOU
Get-DomainOU -GPLink "{GUID}"
# AD Module
Get-GPO -All
Get-GPResultantSetOfPolicy -ReportType Html -Path C:\report.htmlCheck for interesting GPO settings:
powershell
# Find GPOs that modify local group memberships
Get-DomainGPOLocalGroup
# Find computers where user is local admin via GPO
Get-DomainGPOUserLocalGroupMapping -LocalGroup Administrators
# Find users that are local admin via GPO
Get-DomainGPOComputerLocalGroupMapping -ComputerName dcorp-student1Access Control Lists:
powershell
# Get ACLs for a specific object
Get-DomainObjectAcl -Identity student1
# Search for interesting ACLs
Get-DomainObjectAcl -ResolveGUIDs | ? {$_.ActiveDirectoryRights -match "GenericAll"}
# Get ACLs for a group
Get-DomainObjectAcl -Identity "Domain Admins" -ResolveGUIDs
# Find interesting ACLs for current user
Find-InterestingDomainAcl -ResolveGUIDs
# Get ACLs where specific user has rights
Get-DomainObjectAcl -Identity "Domain Admins" -ResolveGUIDs | ? {$_.SecurityIdentifier -match "S-1-5-21-.*-1103"}
# AD Module
(Get-Acl "AD:\CN=Domain Admins,CN=Users,DC=dollarcorp,DC=moneycorp,DC=local").AccessDomain trusts:
powershell
# PowerView
Get-DomainTrust
Get-DomainTrust -Domain us.dollarcorp.moneycorp.local
# Get forest trusts
Get-ForestDomain
Get-ForestTrust
# Map all trusts
Get-DomainTrustMapping
# AD Module
Get-ADTrust -Filter *
Get-ADForest
Get-ADTrust -Identity dollarcorp.moneycorp.localExternal trust enumeration:
powershell
# Check if external forest is reachable
Get-DomainUser -Domain external.localCollection:
powershell
# SharpHound (C# version)
.\SharpHound.exe -c All
.\SharpHound.exe -c All,GPOLocalGroup
# SharpHound with specific domain
.\SharpHound.exe -c All -d dollarcorp.moneycorp.local
# PowerShell version
Import-Module .\SharpHound.ps1
Invoke-BloodHound -CollectionMethod All
# Remote collection (from non-domain joined machine)
.\SharpHound.exe -c All --Domain dollarcorp.moneycorp.local --LdapUsername user --LdapPassword passAnalysis with BloodHound:
- Start neo4j database:
neo4j console - Start BloodHound:
bloodhound - Upload collected JSON files
- Run queries:
- Find shortest path to Domain Admin
- Find computers where Domain Users are local admin
- Find AS-REP Roastable users
- Find Kerberoastable users
- Unconstrained delegation users/computers
- Computers with unsupported OS
Tools
PowerViewBloodHoundSharpHoundAD ModuleADRecon