Evil-WinRM
The ultimate WinRM shell for hacking/pentesting
Description & Purpose
This shell is the ultimate WinRM shell for hacking/pentesting.
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 interoperate. 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.
It is based mainly in the WinRM Ruby library which changed its way to work since its version 2.0. Now instead of using WinRM protocol, it is using PSRP (Powershell Remoting Protocol) for initializing runspace pools as well as creating and processing pipelines.
Features
Compatible to Linux and Windows client systems
Load in memory Powershell scripts
Load in memory dll files bypassing some AVs
Load in memory C# (C Sharp) assemblies bypassing some AVs
Load x64 payloads generated with awesome donut technique
Dynamic AMSI Bypass to avoid AV signatures
Pass-the-hash support
Kerberos auth support
SSL and certificates support
Upload and download files showing progress bar
List remote machine services without privileges
Command History
WinRM command completion
Local files/directories completion
Remote path (files/directories) completion (can be disabled optionally)
Colorization on prompt and output messages (can be disabled optionally)
Optional logging feature
Docker support (prebuilt images available at Dockerhub)
Trap capturing to avoid accidental shell exit on Ctrl+C
Help
Requirements
Ruby 2.3 or higher is needed. Some ruby gems are needed as well: winrm >=2.3.2, winrm-fs >=1.3.2, stringio >=0.0.2, logger >= 1.4.3, fileutils >= 0.7.2. Depending of your installation method (4 availables) the installation of them could be required to be done manually.
Another important requirement only used for Kerberos auth is to install the Kerberos package used for network authentication. For some Linux like Debian based (Kali, Parrot, etc.) it is called krb5-user. For BlackArch it is called krb5 and probably it could be called in a different way for other Linux distributions.
The remote path completion feature will work only if your ruby was compiled enabling the --with-readline-dir flag. This is enabled by default in ruby included on some Linux distributions but not in all. Check the section below for more info.
Installation & Quick Start (4 methods)
Method 1. Installation directly as ruby gem (dependencies will be installed automatically on your system)
Step 1. Install it (it will install automatically dependencies):
gem install evil-winrmStep 2. Ready. Just launch it!
Method 2. Git clone and install dependencies on your system manually
Step 1. Install dependencies manually:
sudo gem install winrm winrm-fs stringio logger fileutilsStep 2. Clone the repo:
git clone https://github.com/Hackplayers/evil-winrm.gitStep 3. Ready. Just launch it!
Method 3. Using bundler (dependencies will not be installed on your system, just to use evil-winrm)
Step 1. Install bundler:
gem install bundlerStep 2. Clone the repo:
git clone https://github.com/Hackplayers/evil-winrm.gitStep 3. Install dependencies with bundler:
cd evil-winrm && bundle install --path vendor/bundleStep 4. Launch it with bundler:
Method 4. Using Docker
Step 1. Launch docker container based on already built image:
Documentation
Clear text password
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.
Ipv6
To use IPv6, the address must be added to /etc/hosts. Just put the already set name of the host after -i argument instead of an IP address.
Basic commands
upload: local files can be auto-completed using tab key.
usage:
upload local_filenameorupload local_filename destination_filename
download:
usage:
download remote_filenameordownload remote_filename destination_filename
Notes about paths (upload/download): Relative paths are not allowed to use on download/upload. Use filenames on current directory or absolute path. If you are using Evil-WinRM in a docker environment, bear in mind that all local paths should be at /data and be pretty sure that you mapped it as a volume in order to be able to access to downloaded files or to be able to upload files from your local host O.S.
services: list all services showing if there your account has permissions over each one. No administrator permissions needed to use this feature.
menu: load the
Invoke-Binary,Dll-LoaderandDonut-Loaderfunctions 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 using tab allowed). The scripts must be in the path set at
-sargument. Type menu again and see the loaded functions. Very large files can take a long time to be loaded.
Advanced commands
Invoke-Binary: allows .Net assemblies to be executed in memory. The name can be auto-completed using tab key. Arguments for the exe file can be passed comma separated. Example:
Invoke-Binary /opt/csharp/Binary.exe 'param1, param2, param3'. The executables must be in the path set at-eargument.
Dll-Loader: allows loading dll libraries in memory, it is equivalent to:
[Reflection.Assembly]::Load([IO.File]::ReadAllBytes("pwn.dll"))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.
Donut-Loader: allows to inject x64 payloads generated with awesome donut technique. No need to encode the payload.bin, just generate and inject!
You can use this donut-maker to generate the payload.bin if you don't use Windows. This script use a python module written by Marcello Salvati (byt3bl33d3r). It could be installed using pip: pip3 install donut-shellcode
Bypass-4MSI: patchs AMSI protection.
Kerberos
First you have to sync date with the DC:
rdate -n <dc_ip>To generate ticket there are many ways:
Using ticketer.py from impacket
If you get a kirbi ticket using Rubeus or Mimikatz you have to convert to ccache using ticket_converter.py
Add ccache ticket. There are 2 ways:
export KRB5CCNAME=/foo/var/ticket.ccachecp ticket.ccache /tmp/krb5cc_0Add realm to
/etc/krb5.conf(for linux). Use of this format is important:Check Kerberos tickets with
klistTo remove ticket use:
kdestroyFor more information about Kerberos check this cheatsheet
Remote path completion
This feature could be not available depending of the ruby you are using. It must be compiled with readline support. Otherwise, this feature will not work (a warning will be shown).
Method 1 (compile the needed extension)
Using this method you'll compile ruby with the needed readline feature but to use only the library without changing the default ruby version on your system. Because of this, is the most recommended method.
Let's suppose that you have in your Debian based system ruby 2.7.3:
Method 2 (Install ruby to use it only for evil-winrm using rbenv)
Let's suppose that you want ruby 2.7.1 on a Debian based Linux and you are using zsh. This script will automatize it. You'll need to launch it from the same dir where evil-winrm.rb and Gemfile is located (the evil-winrm created dir after a git clone for example):
Then you can safely launch evil-winrm using the new installed ruby with the required readline support from any location.
Method 3 (compile entire ruby)
If you want to compile it yourself, you can follow these steps. Let's suppose that you want ruby 2.7.3:
Depending of your system it will be installed at /opt/rubies/ruby-2.7.3 or maybe at ~/.rubies/ruby-2.7.3.
Now just need to install evil-winrm dependencies for that new installed ruby version. The easiest way is to launch command /opt/rubies/ruby-2.7.3/bin/gem install evil-winrm. The gem command used must be belonging to the new ruby installation.
After that, you can launch safely your new installed ruby to use it on evil-winrm: /opt/rubies/ruby-2.7.3/bin/ruby ./evil-winrm.rb -h
It is recommended to use this new installed ruby only to launch evil-winrm. If you set it up as your default ruby for your system, bear in mind that it has no dependency gems installed. Some ruby based software like Metasploit or others could not start correctly due dependencies problems.
Logging
This feature will create files on your $HOME dir saving commands and the outputs of the WinRM sessions
Changelog:
Changelog and project changes can be checked here: CHANGELOG.md
Credits:
Staff:
Cybervaca, (founder). Twitter: @CyberVaca_
OscarAkaElvis, Twitter: @OscarAkaElvis
Hat tip to:
Vis0r for his personal support.
Alamot for his original code.
3v4Si0N for his awesome dll loader.
WinRb All contributors of ruby library.
TheWover for his awesome donut tool.
byt3bl33d3r for his python library to create donut payloads.
Sh11td0wn for inspiration about new features.
Borch for his help adding logging feature.
Hackplayers for giving a shelter on their github to this software.
Disclaimer & License
This script is licensed under LGPLv3+. Direct link to License.
Evil-WinRM should be used for authorized penetration testing and/or nonprofit educational purposes only. Any misuse of this software will not be the responsibility of the author or of any other collaborator. Use it at your own servers and/or with the server owner's permission.
Last updated
