AD Manual Enumeration
Operators to use with Filter
-eq
Equal to-le
Less than or equal to-ge
Greater than or equal to-ne
Not equal to-lt
Less than-gt
Greater than-approx
Approximately equal to-bor
Bitwise OR-band
Bitwise AND-recursivematch
Recursive match-like
Like-notlike
Not like-and
Boolean AND-or
Boolean OR-not
Boolean NOTExample
Basic LDAP Filters
&
and|
or!
not
Example of useful queries
Get-ADGroup -Identity "<GROUP NAME" -Properties *
Get information about an AD groupwhoami /priv
View a user's current rightsGet-WindowsCapability -Name RSAT* -Online \| Select-Object -Property Name, State
Check if RSAT tools are installedGet-WindowsCapability -Name RSAT* -Online \| Add-WindowsCapability –Online
Install all RSAT toolsrunas /netonly /user:htb.local\jackie.may powershell
Run a utility as another userGet-ADObject -LDAPFilter '(objectClass=group)' \| select cn
LDAP query to return all AD groupsGet-ADUser -LDAPFilter '(userAccountControl:1.2.840.113556.1.4.803:=2)' \| select name
List disabled usersGet-ADUser -SearchBase "OU=Employees,DC=DOMAIN-NAME,DC=LOCAL" -Filter *).count
Count all users in an OUget-ciminstance win32_product \| fl
Query for installed softwareget-ciminstance win32_product -Filter "NOT Vendor like '%Microsoft%'" | fl
Query for software that are not microsoftGet-ADComputer -Filter "DNSHostName -like 'SQL*'"
Get hostnames with the word "SQL" in their hostnameGet-ADGroup -Filter "adminCount -eq 1" \| select Name
Get all administrative groupsGet-ADUser -Filter {adminCount -eq '1' -and DoesNotRequirePreAuth -eq 'True'}
Find admin users that don't require Kerberos Pre-AuthGet-ADUser -Filter {adminCount -gt 0} -Properties admincount,useraccountcontrol
Enumerate UAC values for admin usersGet-WmiObject -Class win32_group -Filter "Domain='DOMAIN-NAME'"
Get AD groups using WMI([adsisearcher]"(&(objectClass=Computer))").FindAll()
Use ADSI to search for all computers(Get-ADGroup -Identity "Help Desk" -Properties *).Member.Count
Get number of users in Help Desk Group(Get-ADUser -filter * | select Name).count
Get number of Users in domain(Get-ADComputer -filter * | select Name).count
Get number of Computers in domain(Get-ADGroup -filter * | select Name).count
Get number of groups in domainGet-ADUser -Filter {adminCount -eq '1' -and DoesNotRequirePreAuth -eq 'True'}
Filter Admin users(Get-ADUser -Filter * -SearchBase "OU=IT,OU=Employees,DC=DOMAIN-NAME,DC=LOCAL").count
Find the number of users in the IT OU(Get-ADUser -SearchBase "OU=Employees,DC=DOMAIN-NAME,DC=LOCAL" -Filter *).count
Count all AD UsersGet-ADUser -Properties * -LDAPFilter '(userAccountControl:1.2.840.113556.1.4.803:=524288)' | select Name,memberof,servicePrincipalName,TrustedForDelegation
Find user accounts marked trusted for delegationGet-ADUser -Filter * -SearchBase "OU=Pentest,OU=Employees,DC=DOMAIN-NAME,DC=LOCAL"
| List user in Pentest OUGet-ADGroup -filter * -Properties MemberOf | Where-Object {$_.MemberOf -ne $null} | Select-Object Name,MemberOf
Find all nested groups in the DomainGet-ADDomain | Select-Object NetBIOSName, DNSRoot, InfrastructureMaster
Get-ADForest | Select-Object Domains
Get-ADTrust -Filter * | Select-Object Direction,Source,Target
Other useful native tools or cmd
gpresult /h gpo_report.html
Enumerate infos on Group Policy Objects (collection of policy settings) in htmlgpresult /r /user:first.last
Get GPO for usergpresult /r /S HOST
Get GPO for host
Useful Powershell cmd
Set-ExecutionPolicy Unrestricted
will let you execute any ps1 script, answer A to the promptls -force
is the equivalent ofls -la
Resources
Last updated