Skip to content

Commit 9644cae

Browse files
committed
Simplify logging
1 parent 9e02458 commit 9644cae

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

nxc/protocols/smb.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,11 @@ def create_smbv1_conn(self):
554554
except OSError as e:
555555
if "Connection reset by peer" in str(e):
556556
self.logger.info(f"SMBv1 might be disabled on {self.host}")
557-
if "timed out" in str(e):
557+
elif "timed out" in str(e):
558558
self.is_timeouted = True
559+
self.logger.debug(f"Timeout creating SMBv1 connection to {self.host}")
560+
else:
561+
self.logger.info(f"Error creating SMBv1 connection to {self.host}: {e}")
559562
return False
560563
except NetBIOSError:
561564
self.logger.info(f"SMBv1 disabled on {self.host}")
@@ -576,15 +579,7 @@ def create_smbv3_conn(self):
576579
timeout=self.args.smb_timeout,
577580
)
578581
self.smbv1 = False
579-
except OSError as e:
580-
# This should not happen anymore!!!
581-
if str(e).find("Too many open files") != -1:
582-
if not self.logger:
583-
print("DEBUG ERROR: logger not set, please open an issue on github: " + str(self) + str(self.logger))
584-
self.proto_logger()
585-
self.logger.fail(f"SMBv3 connection error on {self.host}: {e}")
586-
return False
587-
except (Exception, NetBIOSTimeout) as e:
582+
except (Exception, NetBIOSTimeout, OSError) as e:
588583
self.logger.info(f"Error creating SMBv3 connection to {self.host}: {e}")
589584
return False
590585
return True

0 commit comments

Comments
 (0)