Skip to content

Commit

Permalink
Fix logic bug when creating smbv1 connection and add timeout check fo…
Browse files Browse the repository at this point in the history
…r smbv3
  • Loading branch information
NeffIsBack committed Jan 6, 2025
1 parent 33ecfb1 commit 0236ef7
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions nxc/protocols/smb.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ def __init__(self, args, db, host):
self.remote_ops = None
self.bootkey = None
self.output_filename = None
self.smbv1 = None
self.smbv3 = None
self.smbv1 = None # Check if SMBv1 is supported
self.smbv3 = None # Check if SMBv3 is supported
self.is_timeouted = False
self.signing = False
self.smb_share_name = smb_share_name
Expand Down Expand Up @@ -554,7 +554,8 @@ def create_smbv1_conn(self, check=False):
preferredDialect=SMB_DIALECT,
timeout=self.args.smb_timeout,
)
if check:
self.smbv1 = True
if not check:
self.conn = conn
except OSError as e:
if "Connection reset by peer" in str(e):
Expand Down Expand Up @@ -583,8 +584,13 @@ def create_smbv3_conn(self):
self.port,
timeout=self.args.smb_timeout,
)
self.smbv3 = True
except (Exception, NetBIOSTimeout, OSError) as e:
self.logger.info(f"Error creating SMBv3 connection to {self.host}: {e}")
if "timed out" in str(e):
self.is_timeouted = True
self.logger.debug(f"Timeout creating SMBv3 connection to {self.host}")
else:
self.logger.info(f"Error creating SMBv3 connection to {self.host}: {e}")
return False
return True

Expand Down

0 comments on commit 0236ef7

Please sign in to comment.