Skip to main content

Getting Started

SharpWMI uses a consistent command-line syntax with an action parameter to specify the operation:
All remote operations support optional username and password parameters for alternate credentials. If computername is not specified, the action targets localhost.

Basic Syntax

Enumeration Workflows

User Enumeration

Identify logged-on users across the network:
Example Output:

Process Enumeration

List running processes with owner information:
Example Output:

Firewall Enumeration

Enumerate firewall rules and open ports:

Advanced WMI Queries

Enumerates TCP connections similar to netstat.
Lists installed software products.
Enumerates local user accounts.
Lists scheduled tasks.
Enumerates network shares.
Detects installed antivirus products (Windows 7-10).

Execution Workflows

Basic Process Creation

Execute commands on remote systems:

Command Output Retrieval

Capture command output from remote execution:
The result=true option stores command output in a WMI environment variable, retrieves it, and cleans up. This adds execution time but provides valuable feedback.

VBScript Execution

Execute VBScript payloads through WMI event subscriptions:
VBScript execution via WMI event subscriptions creates persistence artifacts that must be cleaned up. SharpWMI automatically removes the event filter, consumer, and binding after execution.

File Operations

File Upload

Upload files to remote systems via WMI:
How it works:
  1. Creates temporary WMI class with file data in property
  2. Executes PowerShell on target to read from WMI class
  3. Writes bytes to disk
  4. Verifies upload success
  5. Removes temporary WMI class
File upload is useful when SMB file shares are blocked or monitored. It operates entirely over WMI/RPC channels.

MSI Installation

Install MSI packages remotely:
The MSI file must be accessible from the target system. Use UNC paths or ensure the file exists locally on the target.

Process Management

Terminate Processes

Kill processes by name or PID:
Process termination finds and kills the first matching process only. For multiple instances, you’ll need to run the command multiple times.

Environment Variable Management

Get Environment Variables

Retrieve environment variable values:

Set Environment Variables

Create or modify environment variables:
Environment variables are set in the user context. Use this for data exfiltration or configuration settings.

Delete Environment Variables

Remove environment variables:

Operational Scenarios

Best Practices

Operational Security

  • Use AMSI evasion for PowerShell/VBScript operations
  • Clean up artifacts (environment variables, WMI classes)
  • Randomize event names for VBScript execution
  • Use result=true sparingly (creates more artifacts)

Credential Management

  • Avoid hardcoding credentials in commands
  • Use domain admin accounts only when necessary
  • Consider using current user context where possible
  • Rotate compromised credentials promptly

Network Operations

  • Test connectivity before mass operations
  • Handle timeouts gracefully
  • Limit concurrent targets to avoid detection
  • Monitor for defensive responses

Error Handling

  • Check for access denied errors
  • Verify WMI service is running on targets
  • Ensure firewall allows RPC/DCOM traffic
  • Validate credentials before mass operations

Common Issues and Solutions

Error: Access denied when connecting to remote systemCauses:
  • Insufficient privileges
  • Wrong credentials
  • WMI permissions not granted
  • UAC filtering (local admin but not elevated)
Solutions:
  • Verify credentials with username and password
  • Use domain admin account
  • Add user to local Administrators group on target
  • Disable UAC remote restrictions (if appropriate)
Error: The RPC server is unavailableCauses:
  • Target system is offline
  • Firewall blocking RPC/DCOM
  • WMI service not running
Solutions:
  • Verify target is online: ping target.domain.com
  • Check firewall rules
  • Ensure Windows Management Instrumentation service is running
  • Test with local WMI query first
Error: Command executes but no results/outputCauses:
  • Insufficient privileges for result retrieval
  • Environment variable creation failed
  • Command didn’t produce output
Solutions:
  • Verify admin access to target
  • Check command syntax
  • Use result=true only with commands that produce output
  • Test command locally first
Error: AMSI still blocks execution despite amsi=disableCauses:
  • Insufficient privileges to modify registry
  • AMSI evasion detected by EDR
  • Registry protection in place
Solutions:
  • Verify admin privileges
  • Use alternative AMSI bypass methods
  • Consider different execution techniques
  • Test AMSI bypass manually first

Next Steps

Action Reference

Explore all available actions in detail

WMI Queries

Advanced WMI query examples

Remote Execution

Process creation techniques

VBScript Execution

VBScript payload delivery