Skip to content

Commit 0236ef7

Browse files
committed
Fix logic bug when creating smbv1 connection and add timeout check for smbv3
1 parent 33ecfb1 commit 0236ef7

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

nxc/protocols/smb.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ def __init__(self, args, db, host):
156156
self.remote_ops = None
157157
self.bootkey = None
158158
self.output_filename = None
159-
self.smbv1 = None
160-
self.smbv3 = None
159+
self.smbv1 = None # Check if SMBv1 is supported
160+
self.smbv3 = None # Check if SMBv3 is supported
161161
self.is_timeouted = False
162162
self.signing = False
163163
self.smb_share_name = smb_share_name
@@ -554,7 +554,8 @@ def create_smbv1_conn(self, check=False):
554554
preferredDialect=SMB_DIALECT,
555555
timeout=self.args.smb_timeout,
556556
)
557-
if check:
557+
self.smbv1 = True
558+
if not check:
558559
self.conn = conn
559560
except OSError as e:
560561
if "Connection reset by peer" in str(e):
@@ -583,8 +584,13 @@ def create_smbv3_conn(self):
583584
self.port,
584585
timeout=self.args.smb_timeout,
585586
)
587+
self.smbv3 = True
586588
except (Exception, NetBIOSTimeout, OSError) as e:
587-
self.logger.info(f"Error creating SMBv3 connection to {self.host}: {e}")
589+
if "timed out" in str(e):
590+
self.is_timeouted = True
591+
self.logger.debug(f"Timeout creating SMBv3 connection to {self.host}")
592+
else:
593+
self.logger.info(f"Error creating SMBv3 connection to {self.host}: {e}")
588594
return False
589595
return True
590596

0 commit comments

Comments
 (0)