---
description: 'ID: T1047 Tactic: Execution'
---

# Windows Management Instrumentation (WMI)

Windows Management Instrumentation(WMI) is a Windows Administration feature that provides a uniform environment for local and remote access to Windows System components. It relies on the WMI service for local and remote access and the server message block (SMB) and Remote Procedure Call Service (RPCS) for remote access. RPCS operate over port 135.

An adversary can use WMI to interact with local and remote systems and use it as a means  to perform many tactic functions, such as gathering information for Discovery  and Remote Execution of files as part of Lateral Movement.

Very awesome things we can do with wmic(Command-Line), in a local and/or remote way.

Let's enumerate locally we can grab valuable info such as Name,Manufacturer,Model,Domain and a Description.

![](https://244509215-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lx2b2zLkTKHrsGfxMoR%2F-LxZVE-JR_8ORAkK-Xil%2F-LxZkDmJvStByU3EDs_0%2Fimage.png?alt=media\&token=838d0c83-6b02-424b-b7a3-ed5ee4531853)

Let's get more in detailed and grab more information.

`wmic environment list`

![](https://244509215-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lx2b2zLkTKHrsGfxMoR%2F-LxZVE-JR_8ORAkK-Xil%2F-LxZnJ10MT5Koy9pLIDu%2Fimage.png?alt=media\&token=31f5730f-fb04-4c3e-ad41-8aa1c6e0e58d)

Great, what about users?,Groups?

![](https://244509215-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lx2b2zLkTKHrsGfxMoR%2F-LxZVE-JR_8ORAkK-Xil%2F-LxZnem5VyMIfX9aVHf2%2Fimage.png?alt=media\&token=b4213929-2b18-4033-a3f1-99fb3d8e5e0c)

Any missing Patches?

![](https://244509215-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lx2b2zLkTKHrsGfxMoR%2F-LxZVE-JR_8ORAkK-Xil%2F-LxZo3_SHEUmaWqeEfY_%2Fimage.png?alt=media\&token=f7bdea44-f4dd-4a43-84ad-764752b4e5d6)

Let's grab a shell with Linux, we can use wmiexec.py from the tool packages from `Impacket`

![](https://244509215-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lx2b2zLkTKHrsGfxMoR%2F-LxZoAQi9vI7w3yul12w%2F-LxZpTz_ZERXI2lAxX-A%2Fimage.png?alt=media\&token=a4418208-a054-490c-a7eb-e0ee90e4c4b3)

Let's see how it looks grabbing the same info we can still enumerate with wmic using wmicexec this is just a shell on cmd and it should still be the same when grabbing info.

![](https://244509215-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lx2b2zLkTKHrsGfxMoR%2F-LxZoAQi9vI7w3yul12w%2F-LxZq1MtUirHsU3U--5M%2Fimage.png?alt=media\&token=347c1be1-db8f-4083-919e-1f7bc1aba61a)

Let's try and execute code, here wmic executes XSL files the great thing about this is that with wmic, not like other's we don't need to add the extension into our file's when calling it. With this example file we can tell that it is using the JScript language to call "calc.exe" we can change this to our liking to execute other commands.

&#x20;Example file:

```
<?xml version='1.0'?>
<stylesheet
xmlns="http://www.w3.org/1999/XSL/Transform" xmlns:ms="urn:schemas-microsoft-com:xslt"
xmlns:user="placeholder"
version="1.0">
<output method="text"/>
	<ms:script implements-prefix="user" language="JScript">
	<![CDATA[
	var r = new ActiveXObject("WScript.Shell").Run("calc.exe");
	]]> </ms:script>
</stylesheet>
```

Let's try executing locally first it should be a simple command such as calc.exe

![](https://244509215-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lx2b2zLkTKHrsGfxMoR%2F-LxbM3HJvM5_ekdRfzqS%2F-LxbhTU3kl-UWNVpxTnY%2Fwmic-calc-xsl.gif?alt=media\&token=a10ad32a-0970-4bbf-84ff-7d945c376ecd)

What about calling it remotely?, Yeah the syntax would be closely the same we just need to add our URL with the xsl payload

![](https://244509215-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lx2b2zLkTKHrsGfxMoR%2F-LxbhV5hbra7DBikERRi%2F-LxbjJOWB0vXpHU8Logv%2Fwmic-remote-calc-xsl.gif?alt=media\&token=59cfb4e5-cca5-44c6-ad8f-8c807992b672)

We can see here that our payload is being called and executed from our Remote Host, this is a great way to execute file's without having them saved to Disk. These examples are very basic and be aware that they will get caught by AV's some great way to avoid this is adding some obfuscation to these files.

