@@ -128,7 +128,7 @@ def __init__(self, args, db, host):
128128 self .null_auth = False
129129 self .protocol = "SMB"
130130 self .is_guest = None
131- self .isdc = False
131+ self .isdc = None
132132
133133 connection .__init__ (self , args , db , host )
134134
@@ -167,7 +167,6 @@ def get_os_arch(self):
167167
168168 def enum_host_info (self ):
169169 self .local_ip = self .conn .getSMBServer ().get_socket ().getsockname ()[0 ]
170- self .is_host_dc ()
171170
172171 try :
173172 self .conn .login ("" , "" )
@@ -198,6 +197,7 @@ def enum_host_info(self):
198197 self .targetDomain = self .hostname
199198 else :
200199 try :
200+ self .is_host_dc ()
201201 # If we know the host is a DC we can still get the hostname over LDAP if NTLM is not available
202202 if self .isdc and detect_if_ip (self .host ):
203203 self .hostname , self .domain = LDAPResolution (self .host ).get_resolution ()
@@ -299,6 +299,8 @@ def print_host_info(self):
299299 self .logger .display (f"{ self .server_os } { f' x{ self .os_arch } ' if self .os_arch else '' } (name:{ self .hostname } ) (domain:{ self .targetDomain } ) ({ signing } ) ({ smbv1 } ){ ntlm } { null_auth } { guest } " )
300300
301301 if self .args .generate_hosts_file or self .args .generate_krb5_file :
302+ if self .isdc is None :
303+ self .is_host_dc ()
302304 if self .args .generate_hosts_file :
303305 with open (self .args .generate_hosts_file , "a+" ) as host_file :
304306 dc_part = f" { self .targetDomain } " if self .isdc else ""
@@ -755,6 +757,8 @@ def is_host_dc(self):
755757 self .logger .debug ("Host appears to be a DC (multiple DC ports open)" )
756758 self .isdc = True
757759 return True
760+ self .isdc = False
761+ return False
758762
759763 def _is_port_open (self , port , timeout = 1 ):
760764 """Check if a specific port is open on the target host."""
0 commit comments