@@ -313,10 +313,6 @@ def enum_host_info(self):
313313 self .kdcHost = result ["host" ] if result else None
314314 self .logger .info (f"Resolved domain: { self .domain } with dns, kdcHost: { self .kdcHost } " )
315315
316- # If we want to authenticate we should create another connection object, because we already logged in
317- if self .args .username or self .args .cred_id or self .kerberos or self .args .use_kcache :
318- self .create_conn_obj ()
319-
320316 def print_host_info (self ):
321317 signing = colored (f"signing:{ self .signing } " , host_info_colors [0 ], attrs = ["bold" ]) if self .signing else colored (f"signing:{ self .signing } " , host_info_colors [1 ], attrs = ["bold" ])
322318 smbv1 = colored (f"SMBv1:{ self .smbv1 } " , host_info_colors [2 ], attrs = ["bold" ]) if self .smbv1 else colored (f"SMBv1:{ self .smbv1 } " , host_info_colors [3 ], attrs = ["bold" ])
@@ -362,6 +358,8 @@ def print_host_info(self):
362358
363359 def kerberos_login (self , domain , username , password = "" , ntlm_hash = "" , aesKey = "" , kdcHost = "" , useCache = False ):
364360 self .logger .debug (f"KDC set to: { kdcHost } " )
361+ # Re-connect since we logged off
362+ self .create_conn_obj ()
365363 lmhash = ""
366364 nthash = ""
367365
@@ -419,7 +417,6 @@ def kerberos_login(self, domain, username, password="", ntlm_hash="", aesKey="",
419417 if self .args .continue_on_success and self .signing :
420418 with contextlib .suppress (Exception ):
421419 self .conn .logoff ()
422- self .create_conn_obj ()
423420 return True
424421 except SessionKeyDecryptionError :
425422 # success for now, since it's a vulnerability - previously was an error
@@ -452,6 +449,7 @@ def kerberos_login(self, domain, username, password="", ntlm_hash="", aesKey="",
452449
453450 def plaintext_login (self , domain , username , password ):
454451 # Re-connect since we logged off
452+ self .create_conn_obj ()
455453 try :
456454 self .password = password
457455 self .username = username
@@ -484,7 +482,6 @@ def plaintext_login(self, domain, username, password):
484482 if self .args .continue_on_success and self .signing :
485483 with contextlib .suppress (Exception ):
486484 self .conn .logoff ()
487- self .create_conn_obj ()
488485 return True
489486 except SessionError as e :
490487 error , desc = e .getErrorString ()
@@ -497,15 +494,14 @@ def plaintext_login(self, domain, username, password):
497494 return False
498495 except (ConnectionResetError , NetBIOSTimeout , NetBIOSError ) as e :
499496 self .logger .fail (f"Connection Error: { e } " )
500- self .create_conn_obj ()
501497 return False
502498 except BrokenPipeError :
503499 self .logger .fail ("Broken Pipe Error while attempting to login" )
504- self .create_conn_obj ()
505500 return False
506501
507502 def hash_login (self , domain , username , ntlm_hash ):
508503 # Re-connect since we logged off
504+ self .create_conn_obj ()
509505 lmhash = ""
510506 nthash = ""
511507 try :
@@ -548,7 +544,6 @@ def hash_login(self, domain, username, ntlm_hash):
548544 if self .args .continue_on_success and self .signing :
549545 with contextlib .suppress (Exception ):
550546 self .conn .logoff ()
551- self .create_conn_obj ()
552547 return True
553548 except SessionError as e :
554549 error , desc = e .getErrorString ()
@@ -562,11 +557,9 @@ def hash_login(self, domain, username, ntlm_hash):
562557 return False
563558 except (ConnectionResetError , NetBIOSTimeout , NetBIOSError ) as e :
564559 self .logger .fail (f"Connection Error: { e } " )
565- self .create_conn_obj ()
566560 return False
567561 except BrokenPipeError :
568562 self .logger .fail ("Broken Pipe Error while attempting to login" )
569- self .create_conn_obj ()
570563 return False
571564
572565 def create_smbv1_conn (self , check = False ):
0 commit comments