githubEdit

WinRM for Lateral Movement

Enable PowerShell Remoting on the target (box needs to be compromised first)

Enable-PSRemoting -force

Check if a given system is listening on WinRM port

Test-NetConnection <IP> -CommonTCPPort WINRM

Trust all hosts

Set-Item WSMan:\localhost\Client\TrustedHosts -Value * -Force

Check what hosts are trusted

Get-Item WSMan:\localhost\Client\TrustedHosts

Execute command on remote host

Invoke-Command <host> -Credential $cred -ScriptBlock {Hostname}

Interactive session with explicit credentials

Enter-PSSession <host> -Credential <domain>\<user>

Interactive session using Kerberos

Upload file to remote session

Download file from remote session

WinRM for Lateral Movement

Execution

Attacker establishing a PSRemoting session from a compromised system 10.0.0.2 to a domain controller dc-mantvydas at 10.0.0.6:

Observations

Note the process ancestry:

On the host that initiated the connection, a 4648 logon attempt is logged, showing what process initiated it, the hostname where it connected to and which account was used:

The below graphic shows that the logon events 4648 annd 4624 are being logged on both the system that initiated the connection (pc-mantvydas - 4648) and the system that it logged on to (dc-mantvydas - 4624):

Additionally, %SystemRoot%\System32\Winevt\Logs\Microsoft-Windows-WinRM%4Operational.evtx on the host that initiated connection to the remote host, logs some interesting data for a task WSMan Session initialize :

...same as above just in the actual screenshot:

Since we entered into a PS Shell on the remote system (Enter-PSSession) , there is another interesting log showing the establishment of a remote shell - note that the ShellID corresponds to the earlier observed Correlation ActivityID:

Additional Useful Commands

Jules Adriaensarrow-up-right reached out to me and suggested to add the following useful commands, so here they are:

References

Last updated