Overview
impacket-wmiexec executes commands on a remote host using Windows Management Instrumentation (WMI) over DCOM (port 135 + dynamic high ports). It provides a semi-interactive shell without uploading any binary or creating a service. Output is retrieved by writing to a temp file on a writable share.
Authentication Methods
| Method | Flag | Example |
|---|---|---|
| Password | (default) | domain/user:password@target |
| NTLM hash | -hashes | -hashes :NT_HASH |
| Kerberos | -k -no-pass | -k -no-pass -dc-ip DC_IP |
| AES key | -aesKey | -aesKey AES256_KEY |
Basic Usage — Interactive Shell
Execute Specific Command
How It Works
- Authenticates to the target via DCOM/RPC (port 135).
- Negotiates a dynamic high port for WMI communication.
- Creates a
Win32_Processvia WMI to executecmd.exe /Q /c <command>. - Command output is redirected to a temp file at the root of the
ADMIN$share (e.g.,C:\Windows\__<timestamp>, sinceADMIN$maps toC:\Windows) — not under\Temp. - Reads the output file over SMB (port 445) and returns it to the attacker.
- Deletes the temp output file after reading.
OPSEC Considerations
| Indicator | Detail |
|---|---|
| Service creation | None — no service is installed |
| Binary on disk | None — no executable uploaded |
| Temp files | Writes output to ADMIN$ share (short-lived) |
| Event logs | Process creation (4688), WMI activity (5857, 5860, 5861) |
| Detection | Stealthier than psexec — no service artifacts |
| Noise level | Medium — temp file writes and DCOM activity are detectable |
- Security Event ID 4624 (network logon type 3)
- Security Event ID 4688 (process creation for
cmd.exe) - WMI Operational Event IDs 5857, 5860, 5861
- Temp files briefly written to the root of the share (default
ADMIN$→C:\Windows\__<timestamp>)
Pass-the-Hash
Kerberos Authentication
Requires a valid ccache file or keytab.Specify Output Share
By default, output goes toADMIN$. Use a different share:
ADMIN$ is restricted):
Common Errors and Fixes
| Error | Cause | Fix |
|---|---|---|
DCOM connection failed | Port 135 or dynamic high ports blocked | Check firewall rules for RPC/DCOM |
STATUS_ACCESS_DENIED | User lacks WMI/DCOM permissions | Verify DCOM Launch and Access permissions |
rpc_s_access_denied | Restricted RPC access | User needs local admin or explicit WMI permissions |
| No output returned | ADMIN$ share not accessible | Try -share C$ or another writable share |
KDC_ERR_PREAUTH_FAILED | Wrong password or expired ticket | Verify creds, regenerate ccache |
SessionError: STATUS_LOGON_FAILURE | Incorrect credentials | Double-check password/hash |
| Timeout / hangs | Dynamic RPC port negotiation blocked | Ensure high ports (49152-65535) are reachable |