Users, Computer, Groups
Users Enumeration
## Users Enumeration
Get-NetUserGet user in a Domain
Get-NetUser *admin* -Domain grey.wargrey.monGet Admins in a Domain
Get-NetUser -AdminCount
Get-NetUser -AdminCount -Domain wargrey.monFilter by username
Get-DomainUser -Domain wargrey.mon | ?{$_.name -match "Grey Mon"}Grab the cn (common-name) from the list of users
cn (common-name) from the list of usersGet-NetUser | select cnGet actively logged users on a computer (needs local admin rights on the target)
Get-NetLoggedon -ComputerName <servername>List all properties
Get-UserPropertyDisplay when the passwords were set last time
Get-UserProperty -Properties pwdlastsetDisplay when the accounts were created
Get-UserProperty -Properties whencreatedGet the list of users
Get-ADUser -Filter *Get the list of users with properties
Get-ADUser -Filter * -Properties *List samaccountname and description for users
samaccountname and description for usersGet-ADUser -Filter * -Properties * | select Samaccountname, DescriptionGet the list of users from cn common-name
cn common-nameGet-ADUser -Filter * -Properties * | select cnGet the list of users from name
Get-ADUser -Filter * -Properties * | select nameDisplays when the password was set
Get-ADUser -Filter * -Properties * | select name,@{expression={[datetime]::fromFileTime($_.pwdlastset)}}List samaccountname, lastlogon, pwdlastset
samaccountname, lastlogon, pwdlastsetGet-NetUser | select samaccountname, lastlogon, pwdlastset
Get-NetUser | select samaccountname, lastlogon, pwdlastset | Sort-Object -Property lastlogonGet list of usernames and their groups
Get-NetUser | select samaccountname, memberofGet description field from the user
Find-UserField -SearchField Description -SearchTerm "built"
Get-netuser | Select-Object samaccountname, descriptionGet SID for users
WMIC.exe useraccount get name, sidBasic user enabled info
Get-NetUser -UACFilter NOT_ACCOUNTDISABLE | select samaccountname, description, pwdlastset, logoncount, badpwdcountFind users with sidHistory set
sidHistory setGet-NetUser -LDAPFilter '(sidHistory=*)'Find local admin access on domain machines
Find all machines on the current domain where the current user has local admin access
Find-LocalAdminAccess -VerboseThis can also be done with remote administration tools like WMI and PowerShell remoting.
Useful when ports (RPC and SMB) used by
Find-LocalAdminAccessare blocked.
Find-WMILocalAdminAccess.ps1
Find-PSRemotingLocalAdminAccess.ps1Kerberoasting Enumeration
ASREPRoastable users
Get-NetUser -PreauthNotRequiredKerberoastable users
Get-NetUser -SPN
Get-NetComputer -SPNKerberospolicy
(Get-DomainPolicyData).kerberospolicyGroups Information
List groups and their details
Get-NetGroup | select samaccountname, admincount, descriptionGet AdminSDHolders
Get-DomainObjectAcl -SearchBase 'CN=AdminSDHolder,CN=System,DC=wargrey,DC=mon' | %{ $_.SecurityIdentifier } | Convert-SidToNameComputer Enumeration
Basic computer enumeration
Get-NetComputer
Get-ADComputer -Filter *Get Computer name and OS
Get-NetComputer | select samaccountname, operatingsystem
Get-NetComputer -Domain wargrey.mon | select samaccountname, operatingsystemGet computers with specific OS
Get-NetComputer -OperatingSystem "*Server 2016*"DCs appear but aren't useful for privilege escalation
Get-NetComputer -Unconstrained | select samaccountnameFind computers with Constrained Delegation
Get-NetComputer -TrustedToAuth | select samaccountnameFind machine accounts in privileged groups
Get-DomainGroup -AdminCount | Get-DomainGroupMember -Recurse | ?{$_.MemberName -like '*'}
Get-NetGroupMember -Identity "Domain Admins" -Recurse | select MemberNameList all the local groups on a machine (needs admin privileges on non-DC machines)
Get-NetlocalGroup -Computername <computername> -ListGroupsGet members of all the local groups on a machine (needs admin privileges on non-DC machines)
Get-NetlocalGroup -Computername <computername> -RecurseGet actively logged users on a computer (needs local admin privileges)
Get-NetLoggedon -Computername <computername>Get locally logged users on a computer (needs remote registry rights on the target)
Get-LoggedonLocal -Computername <computername>Get the last logged users on a computer (needs admin rights and remote registry on the target)
Get-LastLoggedOn -ComputerName <computername>Get computer operating system and other important info
Get-ADComputer -Filter * -Property PrimaryGroupID
Get-ADComputer -Filter {PrimaryGroupID -eq "<number>"} -Properties OperatingSystem, OperatingSystemVersion, OperatingSystemServicePack, PasswordLastSet, LastLogonDate, ServicePrincipalName, TrustedForDelegation, TrustedtoAuthForDelegationFind computers where a domain admin (or specified user/group) has sessions
Find-DomainUserLocation -Verbose
Find-DomainUserLocation -UserGroupIdentity “RDPUsers”Find computers where a domain admin session is available and current user has admin access
Uses
Test-AdminAccess.
#Find-DomainUserLocation -CheckAccessFind computers (File Servers and Distributed File servers) where a domain admin session is available
#Find-DomainUserLocation -StealthShares Enumeration
Search readable shares
Find-DomainShare -CheckShareAccessGroups and Members Enumeration
Basic group enumeration
Get-NetGroup
Get-NetLocalGroupGet all groups containing "admin" in the group name
Get-NetGroup *Admin*
Get-NetGroupMember 'Domain Admins' -Recurse
Get-NetGroupMember 'Administrator' -Recurse
Get-NetGroupMember 'Remote Desktop Users' -Recurse
Get-NetGroupMember 'Remote Desktop' -RecurseGet all members of the "Domain Admins" group
Get-NetGroupMember -GroupName "Domain Admins" -RecurseQuery the root domain for "Enterprise Admins"
Get-NetGroupMember -GroupName "Enterprise Admins" –Domain wargrey.monGet group membership for user "grey"
Get-NetGroup -UserName "grey"List all group members in the "Users" group with full data
Get-NetGroup -GroupName "Users" -FulldataGet all groups that contain "admin" in the group name
Get-ADGroup -Filter 'Name -like "*admin*"' | select NameGet all members of the "Domain Admins" group
Get-ADGroupMember -Identity "Domain Admins" -RecursiveGet group membership for "grey"
Get-ADPrincipalGroupMembership -Identity greyGet computers and their Operating Systems
Get-ADComputer -Filter * | select Name
Get-ADComputer -Filter 'OperatingSystem -like "*Server 2016*"' -Properties OperatingSystem | select Name, OperatingSystemTest connectivity for each computer in the domain
Get-ADComputer -Filter * -Properties DNSHostName | %{Test-Connection -Count 1 -ComputerName $_.DNSHostName}Enumerate Domain Groups
#Get all the groups in the current domain
Get-DomainGroup | select Name
Get-DomainGroup –Domain <targetdomain>
Get-ADGroup -Filter * | select Name
Get-ADGroup -Filter * -Properties *
#Get all groups containing the word "admin" in group name
Get-DomainGroup *admin*
Get-ADGroup -Filter 'Name -like "*admin*"' | select Name
#Get all the members of the Domain Admins group
Get-DomainGroupMember -Identity "Domain Admins" -Recurse
Get-ADGroupMember -Identity "Domain Admins" -Recursive
#Get the group membership for a user:
Get-DomainGroup –UserName "grey"
Get-ADPrincipalGroupMembership -Identity grey
#Get Group admins
Get-NetGroup "*admins*" | Get-NetGroupMember -Recurse | ?{$_.MemberName -Like "*.*"}
#Get Clients on Host Domain
Get-NetGroup -ComputerName PDC
Get-NetGroup -ComputerName dc02Last updated