Local
Gather domain DC and other information
Copy wmic NTDOMAIN Get DomainControllerAddress,DomainName,Roles
List all Users
Copy wmic /NAMESPACE:\\root\directory\ldap PATH ds_user GET ds_samaccountname
Get all groups
Copy wmic /NAMESPACE:\\root\directory\ldap PATH ds_group GET ds_samaccountname
Get members of the domain admin group
Copy wmic path win32_groupuser where (groupcomponent="win32_group.name='domain admins',domain="DOMAIN'")
list all computers
Copy wmic /NAMESPACE:\\root\directory\ldap PATH ds_computer GET ds_samaccountname
Computer information
Copy wmic computersystem list full
Available volumes
Copy wmic volume list brief
find AV
Copy wmic /namespace:\\root\securitycenter2 path antivirusproduct GET displayName, productState, pathToSignedProductExe
find updates
find files with password in the name
Copy wmic DATAFILE where "drive='C:' AND Name like '%password%'" GET Name,readable,size /VALUE
get local use raccounts
Copy wmic useraccount list
WMI classes or information can also be accessed via Get-WmiObject in PowerShell. Some useful queries:
AV products
Copy Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct
VM detection
Copy [Bool](Get-WmiObject -Class Win32_ComputerSystem -Filter "NumberOfLogicalProcessors < 2 OR TotalPhysicalMemory < 2147483648")
find MSI not from MS
Copy Get-WmiObject -Query "select * from Win32_Product" | ?{$_.Vendor - notmatch 'Microsoft’}
Logged on users
Copy Get-WmiObject -Query "select * from Win32_LoggedOnUser" | ?{$_.LogonType -notmatch '(Service|Network|System)’}
VMWARE detection
Copy $VMAdapter=Get-WmiObject Win32_NetworkAdapter -Filter
'Manufacturer LIKE "%VMware%" OR Name LIKE "%VMware%"'
$VMBios=Get-WmiObject Win32_BIOS -Filter 'SerialNumber LIKE
"%VMware%"'
$VMToolsRunning=Get-WmiObject Win32_Process -Filter
'Name="vmtoolsd.exe"'
[Bool]($VMAdapter -or $VMBios -or $VMToolsRunning)Gather domain DC and information
AD
We can enumerate remotely by adding /NODE:"<SERVER_NAME>"
enumerating under other user context can be done adding /USER:"<DOMAIN>\<USER>" /PASSWORD:"<password>"
ex:
Copy wmic /NODE:"DOMAIN" /Namespace:\\root\SecurityCenter2 Path AntiVirusProduct Get *
enumerate groups:
Copy Get-CimInstance –ClassName Win32_Group -Filter "DOMAIN = '<DOMAIN>'"
user accounts
Copy Get-WMIObject –Class Win32_UserAccount -Filter "DOMAIN = '<DOMAIN>'"
Group user memberships
Copy Get-CimInstance -ClassName Win32_Group -Filter "Domain = <DOMAIN>' AND Name='<GROUP_NAME>'"
Domain info
Copy wmic NTDOMAIN GET DomainControllerAddress,DomainName,Roles /VALUE
LDAP
Copy wmic /NAMESPACE:\\root\directory\ldap PATH ds_user GET ds_samaccountname
wmic /NAMESPACE:\\root\directory\ldap PATH ds_group GET ds_samaccountname
wmic /NAMESPACE:\\root\directory\ldap PATH ds_group where "ds_samaccountname='Domain Admins'" Get ds_member /Value
wmic /NAMESPACE:\\root\directory\ldap PATH ds_group where "ds_samaccountname='<GROUP_NAME>'" Get ds_member /Value
wmic /NAMESPACE:\\root\directory\ldap PATH ds_computer GET ds_dnshostname