Evil-WinRM: Remote Administration and Shell Access Over WinRM

evil-winrm: Remote administration tool for Windows

Windows Remote Management (WinRM) is enabled by default on a huge number of enterprise Windows Server deployments — it’s how admins run PowerShell remoting across the network. Evil-WinRM takes that same legitimate protocol and turns it into a proper interactive shell for authorized penetration testing, with features a plain Enter-PSSession doesn’t give you: file upload/download, in-memory .NET assembly loading, Kerberos ticket support, and AMSI bypass helpers for lab-based EDR evasion research.

I reach for Evil-WinRM constantly in Active Directory labs once I’ve got valid credentials or a hash — it’s usually a cleaner, more stable shell than trying to pivot through other means when port 5985/5986 is open.

How Evil-WinRM Works

Evil-WinRM is a Ruby tool built on the WinRM gem, which implements Microsoft’s WS-Management protocol over HTTP (port 5985) or HTTPS (port 5986). Once authenticated, it opens a remote PowerShell runspace on the target and streams commands/output back over that channel, functionally equivalent to an interactive PowerShell remoting session — but wrapped with pentest-friendly conveniences (colorized output, upload/download commands, in-memory script/DLL loading, command history, tab completion).

Installation

Pre-installed on Kali. Elsewhere, via RubyGems:

gem install evil-winrm

From source:

git clone https://github.com/Hackplayers/evil-winrm.git
cd evil-winrm
bundle install
ruby evil-winrm.rb --help

Verify:

evil-winrm --help

Syntax and Key Flags

evil-winrm -i <target-ip> -u <username> -p <password> [options]
FlagPurpose
-i, --ipTarget IP or hostname
-u, --userUsername
-p, --passwordPassword
-H, --hashNTLM hash (pass-the-hash)
-s, --scriptsLocal directory of PowerShell scripts to load
-e, --executablesLocal directory of .exe/.dll files for upload
-P, --portCustom WinRM port (default 5985)
-S, --sslUse HTTPS/WinRM over SSL (port 5986)
-r, --realmKerberos realm
-k, --kerberosUse Kerberos authentication (requires a valid ticket)
--no-colorsDisable colored output

Practical Examples (Authorized Lab Target)

1. Basic authenticated connection:

evil-winrm -i 192.168.56.20 -u labadmin -p 'LabPass123!'

Sample output:

Evil-WinRM shell v3.5

Info: Establishing connection to remote endpoint
*Evil-WinRM* PS C:\Users\labadmin\Documents>

2. Pass-the-hash authentication:

evil-winrm -i 192.168.56.20 -u labadmin -H a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4

3. Load local PowerShell scripts for in-session use (e.g., a PowerView copy for authorized AD enumeration):

evil-winrm -i 192.168.56.20 -u labadmin -p 'LabPass123!' -s /home/kali/scripts/

Inside the shell:

*Evil-WinRM* PS C:\Users\labadmin\Documents> menu

4. Upload and download files directly within the session:

*Evil-WinRM* PS C:\Users\labadmin\Documents> upload /home/kali/tools/tool.exe C:\Temp\tool.exe
*Evil-WinRM* PS C:\Users\labadmin\Documents> download C:\Temp\loot.txt /home/kali/loot.txt

5. Connect over WinRM/SSL (port 5986):

evil-winrm -i 192.168.56.20 -u labadmin -p 'LabPass123!' -S

6. Kerberos authentication (after obtaining a valid TGT with a tool like getTGT.py from Impacket, in an authorized AD lab):

evil-winrm -i dc01.labcorp.local -r labcorp.local -k

Real-World Workflow (Authorized Engagement Only)

# Step 1: Confirm WinRM is open and credentials are valid
crackmapexec winrm 192.168.56.20 -u labadmin -p 'LabPass123!'

# Step 2: Establish an interactive shell
evil-winrm -i 192.168.56.20 -u labadmin -p 'LabPass123!'

# Step 3: Inside the session, enumerate the host for authorized privilege escalation testing
*Evil-WinRM* PS C:\> whoami /priv
*Evil-WinRM* PS C:\> Get-LocalGroupMember Administrators

This is a standard pattern in internal AD assessments: validate access with CrackMapExec first (cheap, low-noise), then move to Evil-WinRM for a full interactive session once you know it’ll work.

Integration With Other Tools

Troubleshooting

Best Practices

Common Mistakes

FAQ

Is Evil-WinRM the same as PowerShell Remoting (Enter-PSSession)? They use the same underlying WinRM protocol, but Evil-WinRM adds pentest-specific conveniences: pass-the-hash support, file transfer commands, colorized output, and in-memory script/DLL loading that native PowerShell remoting doesn’t provide out of the box.

Does Evil-WinRM require WinRM to already be enabled on the target? Yes — it doesn’t enable WinRM itself. The target must already have the WinRM service listening (common on Windows Server by default, less common on workstation editions unless configured).

Can Evil-WinRM be detected by EDR/monitoring tools? Yes — WinRM connections and PowerShell command execution generate standard Windows Event Log entries (Event ID 4103/4104 for PowerShell, plus WinRM-specific logs), so it’s fully visible to a properly configured blue team.

Summary

Evil-WinRM is the practical bridge between “I have valid Windows credentials” and “I have a full interactive shell,” built specifically for how penetration testers actually work — file transfers, script loading, and flexible authentication all built in. In any authorized Active Directory assessment where port 5985/5986 is open, it’s usually the fastest, most stable way to get real command execution once access is confirmed.

References

Exit mobile version