Skip to content

Commit b520fdf

Browse files
authored
Merge pull request Pennyw0rth#601 from Pennyw0rth/neff-revert-speed-improvs
Revert Pennyw0rth#411 due to connection issues (Pennyw0rth#479)
2 parents 340bc60 + 26c4847 commit b520fdf

1 file changed

Lines changed: 4 additions & 11 deletions

File tree

nxc/protocols/smb.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,6 @@ def enum_host_info(self):
308308
self.kdcHost = result["host"] if result else None
309309
self.logger.info(f"Resolved domain: {self.domain} with dns, kdcHost: {self.kdcHost}")
310310

311-
# If we want to authenticate we should create another connection object, because we already logged in
312-
if self.args.username or self.args.cred_id or self.kerberos or self.args.use_kcache:
313-
self.create_conn_obj()
314-
315311
def print_host_info(self):
316312
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"])
317313
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"])
@@ -357,6 +353,8 @@ def print_host_info(self):
357353

358354
def kerberos_login(self, domain, username, password="", ntlm_hash="", aesKey="", kdcHost="", useCache=False):
359355
self.logger.debug(f"KDC set to: {kdcHost}")
356+
# Re-connect since we logged off
357+
self.create_conn_obj()
360358
lmhash = ""
361359
nthash = ""
362360

@@ -414,7 +412,6 @@ def kerberos_login(self, domain, username, password="", ntlm_hash="", aesKey="",
414412
if self.args.continue_on_success and self.signing:
415413
with contextlib.suppress(Exception):
416414
self.conn.logoff()
417-
self.create_conn_obj()
418415
return True
419416
except SessionKeyDecryptionError:
420417
# success for now, since it's a vulnerability - previously was an error
@@ -447,6 +444,7 @@ def kerberos_login(self, domain, username, password="", ntlm_hash="", aesKey="",
447444

448445
def plaintext_login(self, domain, username, password):
449446
# Re-connect since we logged off
447+
self.create_conn_obj()
450448
try:
451449
self.password = password
452450
self.username = username
@@ -479,7 +477,6 @@ def plaintext_login(self, domain, username, password):
479477
if self.args.continue_on_success and self.signing:
480478
with contextlib.suppress(Exception):
481479
self.conn.logoff()
482-
self.create_conn_obj()
483480
return True
484481
except SessionError as e:
485482
error, desc = e.getErrorString()
@@ -492,15 +489,14 @@ def plaintext_login(self, domain, username, password):
492489
return False
493490
except (ConnectionResetError, NetBIOSTimeout, NetBIOSError) as e:
494491
self.logger.fail(f"Connection Error: {e}")
495-
self.create_conn_obj()
496492
return False
497493
except BrokenPipeError:
498494
self.logger.fail("Broken Pipe Error while attempting to login")
499-
self.create_conn_obj()
500495
return False
501496

502497
def hash_login(self, domain, username, ntlm_hash):
503498
# Re-connect since we logged off
499+
self.create_conn_obj()
504500
lmhash = ""
505501
nthash = ""
506502
try:
@@ -543,7 +539,6 @@ def hash_login(self, domain, username, ntlm_hash):
543539
if self.args.continue_on_success and self.signing:
544540
with contextlib.suppress(Exception):
545541
self.conn.logoff()
546-
self.create_conn_obj()
547542
return True
548543
except SessionError as e:
549544
error, desc = e.getErrorString()
@@ -557,11 +552,9 @@ def hash_login(self, domain, username, ntlm_hash):
557552
return False
558553
except (ConnectionResetError, NetBIOSTimeout, NetBIOSError) as e:
559554
self.logger.fail(f"Connection Error: {e}")
560-
self.create_conn_obj()
561555
return False
562556
except BrokenPipeError:
563557
self.logger.fail("Broken Pipe Error while attempting to login")
564-
self.create_conn_obj()
565558
return False
566559

567560
def create_smbv1_conn(self, check=False):

0 commit comments

Comments
 (0)