Join our Newsletter — 33% off our NHI Course

How do you detect host and user discovery commands such as whoami on Windows?

Detect host and user discovery commands by alerting on reconnaissance activity such as identity, group, system, and domain enumeration from non-administrative workstations or new processes. Look for short bursts of basic discovery commands followed by lateral movement, credential access, or remote administration tools. Context matters: repeated enumeration from the same user or host is a stronger signal than a single benign lookup.

Why Windows discovery commands are a useful detection signal

Commands like whoami are rarely dangerous by themselves, but they often appear during early-stage reconnaissance. On Windows, the useful signal is not the single command name, it is the pattern: discovery from a workstation that does not normally administer systems, a newly spawned process, or a user session that suddenly begins enumerating the host, domain, and local privileges.

That pattern is why discovery belongs in a detection story rather than a simple command-blocking story. A one-off lookup can be legitimate, especially during troubleshooting. Repeated checks for identity, local groups, domain membership, logged-on users, system details, and nearby hosts become much more interesting when they come from the same account or machine in a short window.

Discovery activity is also useful because it tends to sit at the start of a sequence. If you see a burst of enumeration followed by remote administration, credential access, script execution, or lateral movement, the earlier commands become evidence of intent rather than isolated admin hygiene. The question is therefore not “did someone run whoami,” but “what did they do next, and does the surrounding context fit normal work?”

What to look for besides whoami

Watch for command-line and process combinations that reveal host, user, and domain context. Common examples include identity and group enumeration, local system inspection, domain and trust queries, nearby host discovery, and account or session listing. These commands are often executed through cmd.exe, PowerShell, or management tooling, so the process tree and parent process matter as much as the command text.

The strongest detections usually combine multiple weak indicators rather than relying on one command. A single whoami from an endpoint user is low confidence. A sequence that includes whoami, net group, systeminfo, nltest, net view, tasklist, ipconfig, or similar commands from a non-admin user on an unusual host is more suspicious, especially if it is followed by remote execution or credential-related activity.

For defenders, this is a visibility problem as much as a malicious-command problem. Attackers often use built-in tools because they blend into normal Windows administration. Living off the Land Guide is useful here because it shows how dual-use binaries and scriptable admin tools appear in real telemetry, including command-line auditing and common proxy-execution paths.

How to tune detection so it is useful, not noisy

Good detection depends on context. Start by identifying which hosts, users, and process chains are normal for administrative discovery. Then treat deviations from that baseline as higher value, such as discovery from a standard user workstation, discovery immediately after logon, discovery from a process that was not launched by a management tool, or repeated enumeration from the same source within a short period.

It also helps to separate benign administration from suspicious reconnaissance by looking at scope and timing. Discovery across many hosts, repeated failures, or enumeration that precedes a move to remote access and privilege-sensitive actions is more concerning than a single lookup during help desk work. If your environment has known admin jump hosts, the same commands on those systems should be handled differently than on general user endpoints.

At the telemetry level, command-line logging, parent-child process relationships, and identity context are all important. A detection rule that only matches whoami will miss the broader pattern. A rule that correlates discovery with host role, user role, and follow-on behaviour is much more resilient. MITRE ATT&CK Enterprise Matrix is a useful reference for mapping these observations to reconnaissance, credential access, lateral movement, and related techniques.

Risk and Threat Considerations

Discovery commands matter because they help an attacker answer basic questions quickly: who am I, what privileges do I have, what domain am I in, and what other systems are visible. That information reduces uncertainty and helps the attacker choose the next step, especially when they are trying to move quietly inside a Windows environment.

Failure mechanism: Short bursts of legitimate-looking enumeration can blend into ordinary admin activity unless you correlate command sequence, process ancestry, and the user or workstation that initiated it. If the environment does not distinguish normal administrative discovery from unexpected reconnaissance, the attacker gains a low-friction way to map the target before escalation or lateral movement.

Impact: Missed discovery activity can delay detection of the intrusion chain, giving the adversary time to identify high-value accounts, reachable systems, and privileged tooling. That increases the chance of credential theft, lateral movement, and broader compromise before defenders recognise the pattern.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

MITRE ATT&CK addresses the attack and risk surface, while NIST CSF 2.0 sets the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
MITRE ATT&CK T1082 — System Information Discovery Covers host and user enumeration patterns on Windows.
T1033 — System Owner/User Discovery Directly covers whoami-style identity and user context discovery.
T1018 — Remote System Discovery Covers system and domain-adjacent enumeration that often follows initial access.
Recommendation — Map discovery telemetry to T1082 and correlate it with follow-on movement or credential activity. Detect user-context discovery commands and investigate unusual repetition or new process origins. Alert on remote system discovery from non-admin endpoints and tie it to the broader attack chain.
NIST CSF 2.0 DE.AE-01 — Anomalies and Events are Detected Supports detecting suspicious command sequences and behavioural deviations.
Recommendation — Tune detections for anomalous discovery bursts and unusual process context.

Practitioner Guidance

What to verify: Confirm whether the source host, user role, and process lineage fit a known administrative pattern before treating a discovery command as benign. A lookup from a standard workstation or a brand-new process deserves more attention than the same command from a managed admin path.

Decision rule: If discovery commands are clustered in time and followed by remote administration, credential-related activity, or host-to-host movement, treat the sequence as reconnaissance in progress rather than isolated user behaviour. If the same user or host repeats enumeration across multiple systems, raise the severity even when each individual command looks ordinary.

Practitioner takeaway: The best detections do not hunt for whoami alone, they hunt for discovery as an opening move in a larger intrusion sequence, with the strongest evidence coming from context, repetition, and what happens next.