Overview
Theloggedon 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.
Syntax
- Local Query
- Remote Query
Parameters
| Parameter | Required | Description |
|---|---|---|
action | Yes | Must be loggedon |
computername | No | Target host(s), comma-separated. Defaults to localhost |
username | No | Username for authentication (requires password) |
password | No | Password for authentication (requires username) |
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:- 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:- 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
TheWin32_LoggedOnUser class returns various types of sessions:
| Session Type | Description | Indicator |
|---|---|---|
| Interactive | Console login | Physical or VM access |
| RemoteInteractive | RDP/Terminal Services | Remote desktop session |
| Network | File share/network access | SMB connections |
| Service | Service account sessions | Running services |
| Batch | Scheduled tasks | Task Scheduler |
Filtering System Accounts
Filtering System Accounts
SharpWMI automatically filters out some system accounts (DWM-, UMFD-) but still returns:
NT AUTHORITY\SYSTEMNT AUTHORITY\LOCAL SERVICENT AUTHORITY\NETWORK SERVICE
Remote vs Local Usage
- Local Enumeration
- Remote Enumeration
When to use:
- Post-exploitation on compromised system
- Determining current logged-on users
- Identifying potential credential theft targets
- No network traffic
- Works without admin privileges
- Immediate results
Detection Considerations
Detection Indicators
Detection Indicators
- 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 Log Indicators
Event Log Indicators
- 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
Network Detection
Network Detection
- DCOM traffic on port 135
- Dynamic RPC connections
- Multiple WMI connections in short timeframe
- WMI queries from workstation to servers
Behavioral Detection
Behavioral Detection
- 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
- WMI (SharpWMI)
- NetSessionEnum API
- Registry Query
- PowerShell Invoke-Command
Advantages:
- Native Windows functionality
- No additional tools required
- Works over existing RPC/DCOM
- Requires admin privileges
- Generates WMI event logs
- Network traffic visible
Troubleshooting
Access Denied
Access Denied
Cause: Insufficient privilegesSolution:
- Verify you have admin rights on target
- Use username/password parameters
- Check UAC remote restrictions
- Verify WMI permissions:
wmimgmt.msc
RPC Server Unavailable
RPC Server Unavailable
No Users Returned
No Users Returned
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
Duplicate User Entries
Duplicate User Entries
Cause: Multiple sessions for same userSolution:
- This is expected behavior (console + RDP sessions)
- Parse output to deduplicate if needed
- Each session type appears separately
Related Actions
query
Execute custom WMI queries
ps
List processes with owner information
exec
Execute processes remotely
getenv
Get environment variables
Additional Resources
Manual WMI Equivalent
Manual WMI Equivalent
PowerShell Alternative
PowerShell Alternative