fix exception handling and remove unused function
parent
85335213da
commit
1e381fb62d
|
@ -5,6 +5,7 @@ import threading
|
|||
from threading import enumerate
|
||||
from sys import exit
|
||||
from impacket import smbserver
|
||||
from nxc.helpers.logger import nxc_logger
|
||||
|
||||
|
||||
class NXCSMBServer(threading.Thread):
|
||||
|
@ -28,18 +29,17 @@ class NXCSMBServer(threading.Thread):
|
|||
except Exception as e:
|
||||
errno, message = e.args
|
||||
if errno == 98 and message == "Address already in use":
|
||||
logger.error("Error starting SMB server on port 445: the port is already in use")
|
||||
nxc_logger.error("Error starting SMB server on port 445: the port is already in use")
|
||||
else:
|
||||
logger.error(f"Error starting SMB server on port 445: {message}")
|
||||
nxc_logger.error(f"Error starting SMB server on port 445: {message}")
|
||||
exit(1)
|
||||
|
||||
def addShare(self, share_name, share_path):
|
||||
self.server.addShare(share_name, share_path)
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
self.server.start()
|
||||
except:
|
||||
except Exception as e:
|
||||
nxc_logger.debug(f"Error starting SMB server: {e}")
|
||||
pass
|
||||
|
||||
def shutdown(self):
|
||||
|
@ -49,5 +49,6 @@ class NXCSMBServer(threading.Thread):
|
|||
if thread.is_alive():
|
||||
try:
|
||||
self._stop()
|
||||
except:
|
||||
except Exception as e:
|
||||
nxc_logger.debug(f"Error stopping SMB server: {e}")
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue