WinRM (Windows Remote Management) is the Microsoft implementation of WS-Management Protocol. A standard SOAP based protocol that allows hardware and operating systems from different vendors to inter-operate. Microsoft included it in their Operating Systems in order to make life easier to system administrators.
This program can be used on any Microsoft Windows Servers with this feature enabled (usually at port 5985), of course only if you have credentials and permissions to use it. So we can say that it could be used in a post-exploitation hacking/pentesting phase. The purpose of this program is to provide nice and easy-to-use features for hacking. It can be used with legitimate purposes by system administrators as well but the most of its features are focused on hacking/pentesting stuff.
- Command History
- WinRM command completion
- Local files completion
- Upload and download files
- List remote machine services
- FullLanguage Powershell language mode
- Load Powershell scripts
- Load in memory dll files bypassing some AVs
- Load in memory C# (C Sharp) compiled exe files bypassing some AVs
- Colorization on output messages (can be disabled optionally)
Usage: evil-winrm -i IP -u USER -s SCRIPTS_PATH -e EXES_PATH [-P PORT] [-p PASS] [-U URL] -i, --ip IP Remote host IP or hostname (required) -P, --port PORT Remote host port (default 5985) -u, --user USER Username (required) -p, --password PASS Password -s, --scripts PS_SCRIPTS_PATH Powershell scripts path (required) -e, --executables EXES_PATH C# executables path (required) -U, --url URL Remote url endpoint (default /wsman) -V, --version Show version -h, --help Display this help message
Ruby 2.3 or higher is needed. Some ruby gems are needed as well:
stringio >=0.0.2 and
~$ sudo gem install winrm winrm-fs colorize stringio
Installation & Quick Start
- Step 1. Clone the repo:
git clone https://github.com/Hackplayers/evil-winrm.git
- Step 2. Ready. Just launch it!
~$ cd evil-winrm && ruby evil-winrm.rb -i 192.168.1.100 -u Administrator -p 'MySuperSecr3tPass123!' -s '/home/foo/ps1_scripts/' -e '/home/foo/exe_files/'
If you don’t want to put the password in clear text, you can optionally avoid to set
-p argument and the password will be prompted preventing to be shown.
To use IPv6, the address must be added to /etc/hosts.
Alternative installation method as ruby gem
- Step 1. Install it:
gem install evil-winrm
- Step 2. Ready. Just launch it!
~$ evil-winrm -i 192.168.1.100 -u Administrator -p 'MySuperSecr3tPass123!' -s '/home/foo/ps1_scripts/' -e '/home/foo/exe_files/'
- upload: local files can be auto-completed using tab key. It is not needed to put a remote_path if the local file is in the same directory as evil-winrm.rb file.
upload local_path remote_path
- download: it is not needed to set local_path if the remote file is in the current directory.
download remote_path local_path
- services: list all services. No administrator permissions needed.
- menu: load the
l04d3r-LoadDllfunctions that we will explain below. When a ps1 is loaded all its functions will be shown up.
Load powershell scripts
- To load a ps1 file you just have to type the name (auto-completion usnig tab allowed). The scripts must be in the path set at
-sargument. Type menu again and see the loaded functions.
- Invoke-Binary: allows exes compiled from c# to be executed in memory. The name can be auto-completed using tab key and allows up to 3 parameters. The executables must be in the path set at
- l04d3r-LoadDll: allows loading dll libraries in memory, it is equivalent to:
The dll file can be hosted by smb, http or locally. Once it is loaded type
menu, then it is possible to autocomplete all functions.
- To disable colors just modify on code this variable
$colors_enabled. Set it to false:
$colors_enabled = false