Windows Management Instrumentation () is a technology that was designed to allow administrators to perform local and remote management operations across a network. Since WMI is part of the windows ecosystem which exist since Windows 98 it can be used in almost every network regardless if it is running Windows 10 or Windows XP. Some of the operations that can be performed via WMI are:

  • Execution
  • File Transfer
  • Read Files and Registry keys
  • File System Examination
  • Subscribe to Events

Red teams can exploit the functionality of WMI and the fact that it can be used against various Windows systems in order to perform host recon, execute commands, perform lateral movement and persistence.

The WMI service is using the DCOM (TCP port 135) or the WinRM protocol (SOAP – port 5985).

WMI Port - DCOM  - wmi port dcom - Command and Control – WMI

WMI Ports – DCOM and WinRM

It runs as a SYSTEM and administrator credentials are needed. Since 2014 there are various tools that exist publicly that can be used as a command and via WMI.


WmiShell is a PowerShell script which is part of the WmiSploit and it is based on the WMIShell which was developed in python by Andrei Dumitrescu. This script uses WMI namespaces to execute commands.

Enter-WmiShell -ComputerName desktop-1st179m -UserName netbiosX
WmiShell - Command Execution  - wmishell command execution - Command and Control – WMI

WmiShell – Command Execution

WmiSploit contains also a script which can execute PowerShell commands and scripts on the remote target by using WMI as a communication channel.

Invoke-WmiCommand -ComputerName desktop-1st179m -ScriptBlock {tasklist}
WmiSploit - Executing PowerShell Commands  - wmisploit executing powershell commands - Command and Control – WMI
WmiSploit – Executing PowerShell Commands



Chris Truncer developed WMImplant which is a PowerShell tool that leverages WMI in order to perform offensive operations. It can be used as command and control tool with the benefit that it doesn’t require an agent to be dropped on the target. However administrator credentials are needed.

Import-Module .WMImplant.ps1
WMImplant - Execution  - wmimplant execution - Command and Control – WMI

WMImplant – Execution

The capabilities of WMimplant can be found in the main menu once it is executed. It can perform file transfer operations, lateral movement and host recon.

WMImplant - Main Menu  - wmimplant main menu - Command and Control – WMI

WMImplant – Main Menu

The change_user is required before the execution of any other commands in order to provide the correct credentials for remote connections.

WMImplant - Authentication and Basic Recon  - wmimplant authentication and basic recon - Command and Control – WMI

WMImplant – Authentication and Basic Recon

It is also possible to execute small PowerShell scripts on the target.

WMImplant - Execution of PowerShell Scripts  - wmimplant execution of powershell scripts - Command and Control – WMI

WMImplant – Execution of PowerShell Scripts

Additionally like the WmiShell tool it has a shell functionality which can be triggered with the command_exec as below:

WMImplant - Shell Commands  - wmimplant shell commands - Command and Control – WMI

WMImplant – Shell Commands

File operations can be also performed remotely.

WMImplant - Directory Listing  - wmimplant directory listing - Command and Control – WMI

WMImplant – Directory Listing


Prior to WMImplant Chris Truncer had developed WMIOps which can be used to perform various actions against targets during red team assessments. Some of these actions include:

  • Transferring files
  • Starting processes
  • Killing processes
  • Folder Sharing

Even though the functionality is limited to compare to WMImplant still it implements the idea of executing commands and receiving output via WMI. The Invoke-ExecCommandWMI has the ability to start a process remotely.

WMIOps - Start a Process  - wmiops start a process - Command and Control – WMI

WMIOps – Start a Remote Process

The calculator will start on the target host.

WMIOps - Calculator  - wmiops calculator - Command and Control – WMI

WMIOps – Calculator

Transferring files over WMI can be achieved with the following function. However it needs local administrator credentials for the remote and the local machine.

Invoke-FileTransferOverWMI -RemoteUser victimusername -RemotePass victimpassword -TARGETS -File C:UsersnetbiosXDesktopWMImplant.ps1 -Download C:UsersUserDownloadsWMIWMImplant.ps1 -LocalUser Administrator -LocalPass pentestlab

Retrieving System Drive Information:

WMIOps - System Drive Information  - wmiops system drive information - Command and Control – WMI

WMIOps – System Drive Information


Utilizing WMI for recon hosts and for lateral movement can allow the red team to stay hidden and exfiltrate information. The fact that WMI doesn’t need a binary to be dropped in order to retrieve information and that the majority of blue teams don’t monitor WMI activities can eliminate the risk of being discovered. It is therefore necessary not completely disable WMI and to filter traffic to ports 135 and 5985 if it needed.


Source link


Please enter your comment!
Please enter your name here