Fix wrongly displayed domain when using domain trust in mssql

main
Alexander Neff 2024-03-24 18:07:48 +01:00
parent 63f9f3507e
commit 04b0b3aa6b
1 changed files with 5 additions and 8 deletions

View File

@ -31,7 +31,8 @@ from impacket.tds import (
class mssql(connection): class mssql(connection):
def __init__(self, args, db, host): def __init__(self, args, db, host):
self.mssql_instances = [] self.mssql_instances = []
self.domain = None self.domain = ""
self.targetDomain = ""
self.server_os = None self.server_os = None
self.hash = None self.hash = None
self.os_arch = None self.os_arch = None
@ -122,23 +123,19 @@ class mssql(connection):
return False return False
else: else:
ntlm_info = parse_challenge(challenge) ntlm_info = parse_challenge(challenge)
self.domain = ntlm_info["domain"] self.targetDomain = self.domain = ntlm_info["domain"]
self.hostname = ntlm_info["hostname"] self.hostname = ntlm_info["hostname"]
self.server_os = ntlm_info["os_version"] self.server_os = ntlm_info["os_version"]
self.logger.extra["hostname"] = self.hostname self.logger.extra["hostname"] = self.hostname
self.db.add_host(self.host, self.hostname, self.domain, self.server_os, len(self.mssql_instances),) self.db.add_host(self.host, self.hostname, self.targetDomain, self.server_os, len(self.mssql_instances),)
if self.args.domain: if self.args.domain:
self.domain = self.args.domain self.domain = self.args.domain
if self.args.local_auth: if self.args.local_auth:
self.domain = self.hostname self.domain = self.hostname
if self.domain is None:
self.domain = ""
def print_host_info(self): def print_host_info(self):
self.logger.display(f"{self.server_os} (name:{self.hostname}) (domain:{self.domain})") self.logger.display(f"{self.server_os} (name:{self.hostname}) (domain:{self.targetDomain})")
return True return True
@reconnect_mssql @reconnect_mssql