Add samruser function with kerberos

main
mpgn 2023-02-02 14:43:04 -05:00
parent bdab59472b
commit 1ddddd5f47
1 changed files with 4 additions and 3 deletions

View File

@ -19,7 +19,7 @@ class UserSamrDump:
def __init__(self, connection): def __init__(self, connection):
self.logger = connection.logger self.logger = connection.logger
self.addr = connection.host self.addr = connection.host if not connection.kerberos else connection.hostname
self.protocol = connection.args.port self.protocol = connection.args.port
self.username = connection.username self.username = connection.username
self.password = connection.password self.password = connection.password
@ -28,7 +28,7 @@ class UserSamrDump:
self.lmhash = '' self.lmhash = ''
self.nthash = '' self.nthash = ''
self.aesKey = None self.aesKey = None
self.doKerberos = False self.doKerberos = connection.kerberos
self.protocols = UserSamrDump.KNOWN_PROTOCOLS.keys() self.protocols = UserSamrDump.KNOWN_PROTOCOLS.keys()
self.users = [] self.users = []
@ -48,13 +48,14 @@ class UserSamrDump:
try: try:
protodef = UserSamrDump.KNOWN_PROTOCOLS[protocol] protodef = UserSamrDump.KNOWN_PROTOCOLS[protocol]
port = protodef[1] port = protodef[1]
except KeyError: except KeyError as e:
logging.debug("Invalid Protocol '{}'".format(protocol)) logging.debug("Invalid Protocol '{}'".format(protocol))
logging.debug("Trying protocol {}".format(protocol)) logging.debug("Trying protocol {}".format(protocol))
rpctransport = transport.SMBTransport(self.addr, port, r'\samr', self.username, self.password, self.domain, rpctransport = transport.SMBTransport(self.addr, port, r'\samr', self.username, self.password, self.domain,
self.lmhash, self.nthash, self.aesKey, doKerberos = self.doKerberos) self.lmhash, self.nthash, self.aesKey, doKerberos = self.doKerberos)
try: try:
self.fetchList(rpctransport) self.fetchList(rpctransport)
break
except Exception as e: except Exception as e:
logging.debug('Protocol failed: {}'.format(e)) logging.debug('Protocol failed: {}'.format(e))
return self.users return self.users