-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreporter.py
284 lines (265 loc) · 15.4 KB
/
reporter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Made by papi
# Created on: Wen 25 Oct 2023
# reporter.py
# Description:
# A havoc extention to provide examples for different vulnerabilities that can
# be tested on the infected networks and on the infected machines.
# Usage:
# To use this script save it on your machine and add it to the script manager of Havoc
# inside of: Scripts > Scripts Manager > Load Script
import havocui
import webbrowser
import os, sys, html, json
config = {
"install_path": ""
}
# if no config file found create one
if not os.path.exists(os.path.expanduser("~/") + ".config/havoc-reporter/config.json"):
if not os.path.exists(os.path.expanduser("~/") + ".config/havoc-reporter/"):
os.mkdir(os.path.expanduser("~/") + ".config/havoc-reporter")
with open(os.path.expanduser("~/") + ".config/havoc-reporter/config.json", "w") as outfile:
json.dump(config, outfile)
else: # use config file
with open(os.path.expanduser("~/") + ".config/havoc-reporter/config.json") as outfile:
config = json.load(outfile)
# specify here the path of the install script...
while not os.path.exists(config["install_path"]):
new_path = havocui.inputdialog("specify the path of the install", "The path of where this script is installed is wrong please provide with the correct path:")
config["install_path"] = new_path.decode('utf-8')
with open(os.path.expanduser("~/") + ".config/havoc-reporter/config.json", "w") as outfile:
json.dump(config, outfile)
sys.path.append(config["install_path"])
from html_source.mitre import html_panel_mitre
from html_source.vulnerabilities import html_panel_vulns
from mitre.tactics import *
from vulns.network_vulnerabilities import network_vulns
from vulns.active_directory import active_directory_vulns
from vulns.windows_privesc import windows_privesc_vulns
tree_display_vulns = None
tree_display_mitre = None
settings_widget = None
net_titles = [item["title"] for item in network_vulns]
ad_titles = [item["title"] for item in active_directory_vulns]
winpriv_titles = [item["title"] for item in windows_privesc_vulns]
# MITRE ATT&CK techniques
reconnaissance_titles = [item["technique"] for item in reconnaissance]
resource_development_titles = [item["technique"] for item in resource_development]
initial_access_titles = [item["technique"] for item in initial_access]
execution_titles = [item["technique"] for item in execution]
persistence_titles = [item["technique"] for item in persistence]
privilege_escalation_titles = [item["technique"] for item in privilege_escalation]
defense_evasion_titles = [item["technique"] for item in defense_evasion]
credential_access_titles = [item["technique"] for item in credential_access]
discovery_titles = [item["technique"] for item in discovery]
lateral_movement_titles = [item["technique"] for item in lateral_movement]
collection_titles = [item["technique"] for item in collection]
command_and_control_titles = [item["technique"] for item in command_and_control]
exfiltration_titles = [item["technique"] for item in exfiltration]
impact_titles = [item["technique"] for item in impact]
# Function to set the HTML of the page
def select_tree_vulns(data):
global tree_display_vulns
title = ""
desc = ""
image = ""
mitre = ""
external = []
command = ""
if data in net_titles:
title = network_vulns[net_titles.index(data)]["title"]
desc = network_vulns[net_titles.index(data)]["desc"]
image = network_vulns[net_titles.index(data)]["image"]
mitre = network_vulns[net_titles.index(data)]["mitre"]
external = network_vulns[net_titles.index(data)]["external"]
command = network_vulns[net_titles.index(data)]["command"]
elif data in ad_titles:
title = active_directory_vulns[ad_titles.index(data)]["title"]
desc = active_directory_vulns[ad_titles.index(data)]["desc"]
image = active_directory_vulns[ad_titles.index(data)]["image"]
mitre = active_directory_vulns[ad_titles.index(data)]["mitre"]
external = active_directory_vulns[ad_titles.index(data)]["external"]
command = active_directory_vulns[ad_titles.index(data)]["command"]
elif data in winpriv_titles:
title = windows_privesc_vulns[winpriv_titles.index(data)]["title"]
desc = windows_privesc_vulns[winpriv_titles.index(data)]["desc"]
image = windows_privesc_vulns[winpriv_titles.index(data)]["image"]
mitre = windows_privesc_vulns[winpriv_titles.index(data)]["mitre"]
external = windows_privesc_vulns[winpriv_titles.index(data)]["external"]
command = windows_privesc_vulns[winpriv_titles.index(data)]["command"]
if title != "":
external_data = ""
for obj in external:
external_data = external_data + "<li><a style=\"color:#e100ff\" href=\"%s\">%s</a></li>" % (obj["link"], obj["title"])
tree_display_vulns.setPanel(html_panel_vulns % (title, image, mitre, desc, html.escape(command), external_data))
tree_display_vulns = havocui.Tree("Vulnerabilities", select_tree_vulns, True)
tree_display_vulns.addRow("General Network", *net_titles)
tree_display_vulns.addRow("Active Directory", *ad_titles)
tree_display_vulns.addRow("Windows Privilege Escalation", *winpriv_titles)
def select_tree_mitre(data):
global tree_display_mitre
title = ""
mitreid = ""
desc = ""
image = ""
sub_tech = []
mitigations = []
if data in reconnaissance_titles:
image = ""
title = reconnaissance[reconnaissance_titles.index(data)]["technique"]
mitreid= reconnaissance[reconnaissance_titles.index(data)]["id"]
desc = reconnaissance[reconnaissance_titles.index(data)]["description"]
sub_tech = reconnaissance[reconnaissance_titles.index(data)]["sub-techniques"]
mitigations = reconnaissance[reconnaissance_titles.index(data)]["mitigations"]
if data in resource_development_titles:
image = ""
title = resource_development[resource_development_titles.index(data)]["technique"]
mitreid= resource_development[resource_development_titles.index(data)]["id"]
desc = resource_development[resource_development_titles.index(data)]["description"]
sub_tech = resource_development[resource_development_titles.index(data)]["sub-techniques"]
mitigations = resource_development[resource_development_titles.index(data)]["mitigations"]
if data in initial_access_titles:
image = ""
title = initial_access[initial_access_titles.index(data)]["technique"]
mitreid= initial_access[initial_access_titles.index(data)]["id"]
desc = initial_access[initial_access_titles.index(data)]["description"]
sub_tech = initial_access[initial_access_titles.index(data)]["sub-techniques"]
mitigations = initial_access[initial_access_titles.index(data)]["mitigations"]
if data in execution_titles:
image = ""
title = execution[execution_titles.index(data)]["technique"]
mitreid= execution[execution_titles.index(data)]["id"]
desc = execution[execution_titles.index(data)]["description"]
sub_tech = execution[execution_titles.index(data)]["sub-techniques"]
mitigations = execution[execution_titles.index(data)]["mitigations"]
if data in persistence_titles:
image = ""
title = persistence[persistence_titles.index(data)]["technique"]
mitreid= persistence[persistence_titles.index(data)]["id"]
desc = persistence[persistence_titles.index(data)]["description"]
sub_tech = persistence[persistence_titles.index(data)]["sub-techniques"]
mitigations = persistence[persistence_titles.index(data)]["mitigations"]
if data in privilege_escalation_titles:
image = ""
title = privilege_escalation[privilege_escalation_titles.index(data)]["technique"]
mitreid= privilege_escalation[privilege_escalation_titles.index(data)]["id"]
desc = privilege_escalation[privilege_escalation_titles.index(data)]["description"]
sub_tech = privilege_escalation[privilege_escalation_titles.index(data)]["sub-techniques"]
mitigations = privilege_escalation[privilege_escalation_titles.index(data)]["mitigations"]
if data in defense_evasion_titles:
image = ""
title = defense_evasion[defense_evasion_titles.index(data)]["technique"]
mitreid= defense_evasion[defense_evasion_titles.index(data)]["id"]
desc = defense_evasion[defense_evasion_titles.index(data)]["description"]
sub_tech = defense_evasion[defense_evasion_titles.index(data)]["sub-techniques"]
mitigations = defense_evasion[defense_evasion_titles.index(data)]["mitigations"]
if data in credential_access_titles:
image = ""
title = credential_access[credential_access_titles.index(data)]["technique"]
mitreid= credential_access[credential_access_titles.index(data)]["id"]
desc = credential_access[credential_access_titles.index(data)]["description"]
sub_tech = credential_access[credential_access_titles.index(data)]["sub-techniques"]
mitigations = credential_access[credential_access_titles.index(data)]["mitigations"]
if data in discovery_titles:
image = ""
title = discovery[discovery_titles.index(data)]["technique"]
mitreid= discovery[discovery_titles.index(data)]["id"]
desc = discovery[discovery_titles.index(data)]["description"]
sub_tech = discovery[discovery_titles.index(data)]["sub-techniques"]
mitigations = discovery[discovery_titles.index(data)]["mitigations"]
if data in lateral_movement_titles:
image = ""
title = lateral_movement[lateral_movement_titles.index(data)]["technique"]
mitreid= lateral_movement[lateral_movement_titles.index(data)]["id"]
desc = lateral_movement[lateral_movement_titles.index(data)]["description"]
sub_tech = lateral_movement[lateral_movement_titles.index(data)]["sub-techniques"]
mitigations = lateral_movement[lateral_movement_titles.index(data)]["mitigations"]
if data in collection_titles:
image = ""
title = collection[collection_titles.index(data)]["technique"]
mitreid= collection[collection_titles.index(data)]["id"]
desc = collection[collection_titles.index(data)]["description"]
sub_tech = collection[collection_titles.index(data)]["sub-techniques"]
mitigations = collection[collection_titles.index(data)]["mitigations"]
if data in command_and_control_titles:
image = ""
title = command_and_control[command_and_control_titles.index(data)]["technique"]
mitreid= command_and_control[command_and_control_titles.index(data)]["id"]
desc = command_and_control[command_and_control_titles.index(data)]["description"]
sub_tech = command_and_control[command_and_control_titles.index(data)]["sub-techniques"]
mitigations = command_and_control[command_and_control_titles.index(data)]["mitigations"]
if data in exfiltration_titles:
image = ""
title = exfiltration[exfiltration_titles.index(data)]["technique"]
mitreid= exfiltration[exfiltration_titles.index(data)]["id"]
desc = exfiltration[exfiltration_titles.index(data)]["description"]
sub_tech = exfiltration[exfiltration_titles.index(data)]["sub-techniques"]
mitigations = exfiltration[exfiltration_titles.index(data)]["mitigations"]
if data in impact_titles:
image = ""
title = impact[impact_titles.index(data)]["technique"]
mitreid= impact[impact_titles.index(data)]["id"]
desc = impact[impact_titles.index(data)]["description"]
sub_tech = impact[impact_titles.index(data)]["sub-techniques"]
mitigations = impact[impact_titles.index(data)]["mitigations"]
subtech_data = ""
mitigation_data = ""
if title != "":
if len(sub_tech) > 0:
subtech_data = "<h3 style=\"color:#71e0cb\">Sub-techniques:</h3><ul>"
for obj in sub_tech:
subtech_data = subtech_data + "<li><a style=\"color:#e100ff\" href=\"%s\">%s: %s</a></li>" % (obj["link"], obj["id"], obj["sub-technique"])
subtech_data = subtech_data + "</ul>"
if len(mitigations) > 0:
mitigation_data = "<h3 style=\"color:#71e0cb\">Mitigations:</h3><table>"
for obj in mitigations:
mitigation_data = mitigation_data + "<tr><th><a style=\"color:#e100ff\" href=\"%s\">%s</a></th><th>%s</th></tr>" % (obj["link"], obj["mitigation"], obj["description"])
tree_display_mitre.setPanel(html_panel_mitre % (title, image, mitreid, desc, subtech_data, mitigation_data))
tree_display_mitre = havocui.Tree("MITRE ATTACK", select_tree_mitre, True)
tree_display_mitre.addRow("Reconnaissance", *reconnaissance_titles)
tree_display_mitre.addRow("Resource Development", *resource_development_titles)
tree_display_mitre.addRow("Initial Access", *initial_access_titles)
tree_display_mitre.addRow("Execution", *execution_titles)
tree_display_mitre.addRow("Persistence", *persistence_titles)
tree_display_mitre.addRow("Privilege Escalation", *privilege_escalation_titles)
tree_display_mitre.addRow("Defense Evasion", *defense_evasion_titles)
tree_display_mitre.addRow("Credential Access", *credential_access_titles)
tree_display_mitre.addRow("Discovery", *discovery_titles)
tree_display_mitre.addRow("Lateral Movement", *lateral_movement_titles)
tree_display_mitre.addRow("Collection", *collection_titles)
tree_display_mitre.addRow("Command and Control", *command_and_control_titles)
tree_display_mitre.addRow("Exfiltration", *exfiltration_titles)
tree_display_mitre.addRow("Impact", *impact_titles)
def change_config_path():
global config
tmp = config["install_path"]
config["install_path"] = ""
while not os.path.exists(config["install_path"]):
new_path = havocui.inputdialog("specify the path of the install", "The path of where this script is installed is wrong please provide with the correct path:")
config["install_path"] = new_path.decode('utf-8')
with open(os.path.expanduser("~/") + ".config/havoc-reporter/config.json", "w") as outfile:
json.dump(config, outfile)
settings_widget.replaceLabel(tmp, config["install_path"])
def open_config_html_vuln():
webbrowser.open(config["install_path"] + "/html_source/vulnerabilities.py")
def open_config_html_mitre():
webbrowser.open(config["install_path"] + "/html_source/mitre.py")
# define settings widget
settings_widget = havocui.Widget("Reporter Settings", True)
settings_widget.addLabel("<h1 style='color:#bd93f9'>Reporter Settings</h1>")
settings_widget.addLabel("<h2 style='color:#71e0cb'>Install path:</h2>")
settings_widget.addLabel(config["install_path"])
settings_widget.addButton("Change path", change_config_path)
settings_widget.addLabel("<h2 style='color:#71e0cb'>Open HTML template:</h2>")
settings_widget.addButton("Open Vulnerabilities", open_config_html_vuln)
settings_widget.addButton("Open MITRE", open_config_html_mitre)
def open_vulns():
tree_display_vulns.setBottomTab()
def open_mitre():
tree_display_mitre.setBottomTab()
def open_settings():
settings_widget.setSmallTab()
def color_pick():
print(havocui.colordialog())
havocui.createtab("Reporter", "Vulnerabilities", open_vulns, "MITRE ATTACK", open_mitre, "Settings", open_settings,"Color", color_pick)