Skip to main content

Overview

The loggedon action enumerates currently logged-on users on local and remote systems. It queries the Win32_LoggedOnUser WMI class to identify all active user sessions, including interactive, remote desktop, and service sessions.
This is particularly useful for identifying high-value targets during lateral movement or determining if administrators are logged into systems.

Syntax

Parameters

Usage Examples

Basic Usage

Example Output

The output includes system accounts (SYSTEM, LOCAL SERVICE, NETWORK SERVICE) and service accounts. Filter these when looking for interactive user sessions.

Operational Scenarios

Scenario 1: Domain Admin Hunting

Identify which systems have domain administrators logged in:
Look for:
  • Domain Admin accounts
  • Enterprise Admin accounts
  • Service accounts with elevated privileges
  • Administrator workstations

Scenario 2: Lateral Movement Target Selection

Determine the best targets for lateral movement:
Target systems where:
  • Multiple administrators are logged in
  • High-value users are present
  • Service accounts are running (for credential theft)

Scenario 3: Operational Security

Ensure administrators aren’t logged in before conducting operations:

Scenario 4: Network Mapping

Map user activity across the network:

Understanding Session Types

The Win32_LoggedOnUser class returns various types of sessions:
SharpWMI automatically filters out some system accounts (DWM-, UMFD-) but still returns:
  • NT AUTHORITY\SYSTEM
  • NT AUTHORITY\LOCAL SERVICE
  • NT AUTHORITY\NETWORK SERVICE
When analyzing output, focus on domain and local user accounts.

Remote vs Local Usage

When to use:
  • Post-exploitation on compromised system
  • Determining current logged-on users
  • Identifying potential credential theft targets
Advantages:
  • No network traffic
  • Works without admin privileges
  • Immediate results

Detection Considerations

Enumerating logged-on users across multiple systems can generate detectable patterns, especially when done in bulk.
  • WMI queries for Win32_LoggedOnUser class
  • Bulk WMI queries from single source
  • Queries originating from non-administrative systems
  • Rapid sequential WMI connections
  • Queries outside business hours
  • Event ID 4624: Account logon (WMI connection)
  • Event ID 4672: Special privileges assigned to new logon
  • Event ID 5857: WMI activity
  • Sysmon Event ID 19-21: WMI activity
  • Multiple 4624 events from same source IP
  • DCOM traffic on port 135
  • Dynamic RPC connections
  • Multiple WMI connections in short timeframe
  • WMI queries from workstation to servers
  • User account querying multiple systems
  • Queries against high-value targets (DCs, servers)
  • Reconnaissance pattern: loggedon → ps → exec
  • Queries correlating with other suspicious activity

Best Practices

Operational Security

  • Limit query frequency to avoid detection
  • Blend in with legitimate admin activity
  • Use during business hours when WMI traffic is common
  • Don’t query all systems at once

Target Selection

  • Prioritize high-value systems (DCs, app servers)
  • Focus on systems likely to have admin sessions
  • Cross-reference with network shares
  • Use information for lateral movement planning

Credential Management

  • Use current context when possible
  • Rotate credentials between operations
  • Minimize use of domain admin accounts
  • Monitor for account lockouts

Data Handling

  • Parse output to identify high-value accounts
  • Filter system accounts from results
  • Track user session patterns
  • Correlate with other enumeration data

Comparison with Alternatives

Advantages:
  • Native Windows functionality
  • No additional tools required
  • Works over existing RPC/DCOM
Disadvantages:
  • Requires admin privileges
  • Generates WMI event logs
  • Network traffic visible

Troubleshooting

Cause: Insufficient privilegesSolution:
  • Verify you have admin rights on target
  • Use username/password parameters
  • Check UAC remote restrictions
  • Verify WMI permissions: wmimgmt.msc
Cause: Network or firewall issueSolution:
  • Verify target is online
  • Check firewall rules for ports 135, 445
  • Ensure WMI service is running
  • Test with: wmic /node:target computersystem get name
Cause: No active sessions or query issueSolution:
  • Verify users are actually logged in
  • Check if system is a workstation vs server
  • Test locally first: SharpWMI.exe action=loggedon
  • Try manual WMI query: wmic /node:target path Win32_LoggedOnUser get Antecedent
Cause: Multiple sessions for same userSolution:
  • This is expected behavior (console + RDP sessions)
  • Parse output to deduplicate if needed
  • Each session type appears separately

query

Execute custom WMI queries

ps

List processes with owner information

exec

Execute processes remotely

getenv

Get environment variables

Additional Resources