-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
config.py
271 lines (212 loc) · 8.18 KB
/
config.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
# Impacket - Collection of Python classes for working with network protocols.
#
# Copyright (C) 2022 Fortra. All rights reserved.
#
# This software is provided under a slightly modified version
# of the Apache Software License. See the accompanying LICENSE file
# for more information.
#
# Description:
# Config utilities
#
# Configuration class which holds the config specified on the
# command line, this can be passed to the tools' servers and clients
#
# Author:
# Dirk-jan Mollema / Fox-IT (https://www.fox-it.com)
#
from impacket.examples.utils import parse_credentials
class NTLMRelayxConfig:
def __init__(self):
self.daemon = True
# Set the value of the interface ip address
self.interfaceIp = None
self.listeningPort = None
self.domainIp = None
self.machineAccount = None
self.machineHashes = None
self.target = None
self.mode = None
self.redirecthost = None
self.outputFile = None
self.attacks = None
self.lootdir = None
self.randomtargets = False
self.encoding = None
self.ipv6 = False
self.remove_mic = False
self.disableMulti = False
self.command = None
# WPAD options
self.serve_wpad = False
self.wpad_host = None
self.wpad_auth_num = 0
self.smb2support = False
# SMB options
self.exeFile = None
self.interactive = False
self.enumLocalAdmins = False
self.SMBServerChallenge = None
# RPC options
self.rpc_mode = None
self.rpc_use_smb = False
self.auth_smb = ''
self.smblmhash = None
self.smbnthash = None
self.port_smb = 445
# LDAP options
self.dumpdomain = True
self.addda = True
self.aclattack = True
self.validateprivs = True
self.escalateuser = None
# MSSQL options
self.queries = []
# Registered protocol clients
self.protocolClients = {}
# SOCKS options
self.runSocks = False
self.socksServer = None
# HTTP options
self.remove_target = False
# WebDAV options
self.serve_image = False
# AD CS attack options
self.isADCSAttack = False
self.template = None
self.altName = None
# Shadow Credentials attack options
self.IsShadowCredentialsAttack = False
self.ShadowCredentialsPFXPassword = None
self.ShadowCredentialsExportType = None
self.ShadowCredentialsOutfilePath = None
# Admin service attack
self.isADMINAttack = False
self.sccmAdminToken = None # internal storage var; not a CLI flag option
self.logonname = None
self.displayname = None
self.objectsid = None
def setSMBChallenge(self, value):
self.SMBServerChallenge = value
def setSMB2Support(self, value):
self.smb2support = value
def setProtocolClients(self, clients):
self.protocolClients = clients
def setInterfaceIp(self, ip):
self.interfaceIp = ip
def setListeningPort(self, port):
self.listeningPort = port
def setRunSocks(self, socks, server):
self.runSocks = socks
self.socksServer = server
def setOutputFile(self, outputFile):
self.outputFile = outputFile
def setTargets(self, target):
self.target = target
def setExeFile(self, filename):
self.exeFile = filename
def setCommand(self, command):
self.command = command
def setEnumLocalAdmins(self, enumLocalAdmins):
self.enumLocalAdmins = enumLocalAdmins
def setDisableMulti(self, disableMulti):
self.disableMulti = disableMulti
def setEncoding(self, encoding):
self.encoding = encoding
def setMode(self, mode):
self.mode = mode
def setAttacks(self, attacks):
self.attacks = attacks
def setLootdir(self, lootdir):
self.lootdir = lootdir
def setRedirectHost(self, redirecthost):
self.redirecthost = redirecthost
def setDomainAccount(self, machineAccount, machineHashes, domainIp):
# Don't set this if we're not exploiting it
if not self.remove_target:
return
if machineAccount is None or machineHashes is None or domainIp is None:
raise Exception("You must specify machine-account/hashes/domain all together!")
self.machineAccount = machineAccount
self.machineHashes = machineHashes
self.domainIp = domainIp
def setRandomTargets(self, randomtargets):
self.randomtargets = randomtargets
def setLDAPOptions(self, dumpdomain, addda, aclattack, validateprivs, escalateuser, addcomputer, delegateaccess, dumplaps, dumpgmsa, dumpadcs, sid, adddnsrecord):
self.dumpdomain = dumpdomain
self.addda = addda
self.aclattack = aclattack
self.validateprivs = validateprivs
self.escalateuser = escalateuser
self.addcomputer = addcomputer
self.delegateaccess = delegateaccess
self.dumplaps = dumplaps
self.dumpgmsa = dumpgmsa
self.dumpadcs = dumpadcs
self.sid = sid
self.adddnsrecord = adddnsrecord
def setMSSQLOptions(self, queries):
self.queries = queries
def setRPCOptions(self, rpc_mode, rpc_use_smb, auth_smb, hashes_smb, rpc_smb_port):
self.rpc_mode = rpc_mode
self.rpc_use_smb = rpc_use_smb
self.smbdomain, self.smbuser, self.smbpass = parse_credentials(auth_smb)
if hashes_smb is not None:
self.smblmhash, self.smbnthash = hashes_smb.split(':')
else:
self.smblmhash = ''
self.smbnthash = ''
self.rpc_smb_port = rpc_smb_port
def setInteractive(self, interactive):
self.interactive = interactive
def setIMAPOptions(self, keyword, mailbox, dump_all, dump_max):
self.keyword = keyword
self.mailbox = mailbox
self.dump_all = dump_all
self.dump_max = dump_max
def setIPv6(self, use_ipv6):
self.ipv6 = use_ipv6
def setWpadOptions(self, wpad_host, wpad_auth_num):
if wpad_host is not None:
self.serve_wpad = True
self.wpad_host = wpad_host
self.wpad_auth_num = wpad_auth_num
def setExploitOptions(self, remove_mic, remove_target):
self.remove_mic = remove_mic
self.remove_target = remove_target
def setWebDAVOptions(self, serve_image):
self.serve_image = serve_image
def setADCSOptions(self, template):
self.template = template
def setIsADCSAttack(self, isADCSAttack):
self.isADCSAttack = isADCSAttack
def setIsShadowCredentialsAttack(self, IsShadowCredentialsAttack):
self.IsShadowCredentialsAttack = IsShadowCredentialsAttack
def setShadowCredentialsOptions(self, ShadowCredentialsTarget, ShadowCredentialsPFXPassword, ShadowCredentialsExportType, ShadowCredentialsOutfilePath):
self.ShadowCredentialsTarget = ShadowCredentialsTarget
self.ShadowCredentialsPFXPassword = ShadowCredentialsPFXPassword
self.ShadowCredentialsExportType = ShadowCredentialsExportType
self.ShadowCredentialsOutfilePath = ShadowCredentialsOutfilePath
def setAltName(self, altName):
self.altName = altName
def setisADMINAttack(self, isADMINAttack, logonname, displayname, objectsid):
self.isADMINAttack = isADMINAttack
self.logonname = logonname
self.displayname = displayname
self.objectsid = objectsid
def setSCCMAdminToken(self, token):
self.sccmAdminToken = token
def parse_listening_ports(value):
ports = set()
for entry in value.split(","):
items = entry.split("-")
if len(items) > 2:
raise ValueError
if len(items) == 1:
ports.add(int(items[0])) # Can raise ValueError if casted value not an Int, will be caught by calling method
continue
item1, item2 = map(int, items) # Can raise ValueError if casted values not an Int, will be caught by calling method
if item2 < item1:
raise ValueError("Upper bound in port range smaller than lower bound")
ports.update(range(item1, item2 + 1))
return ports