diff --git a/smbclientng/core/InteractiveShell.py b/smbclientng/core/InteractiveShell.py index c2012dc..6b71b8d 100644 --- a/smbclientng/core/InteractiveShell.py +++ b/smbclientng/core/InteractiveShell.py @@ -874,10 +874,11 @@ def command_sizeof(self, arguments, command): # SMB share needed : Yes class RecursiveSizeOfPrint(object): - def __init__(self, entry, smbSession, config): + def __init__(self, entry, sessionsManager, config, logger): self.entry = entry self.config = config - self.sessionsManager.current_session = smbSession + self.logger = logger + self.sessionsManager = sessionsManager self.size = 0 def update(self, entry, fullpath, depth): @@ -913,7 +914,12 @@ def print(self, end='\n'): total = 0 for entry in entries: - rsop = RecursiveSizeOfPrint(entry=entry, smbSession=self.sessionsManager.current_session, config=self.config) + rsop = RecursiveSizeOfPrint( + entry=entry, + sessionsManager=self.sessionsManager, + config=self.config, + logger=self.logger + ) # Directory if entry.is_directory(): self.sessionsManager.current_session.find( diff --git a/smbclientng/core/Logger.py b/smbclientng/core/Logger.py index 71e75c3..8787469 100644 --- a/smbclientng/core/Logger.py +++ b/smbclientng/core/Logger.py @@ -49,7 +49,7 @@ def __init__(self, config, logfile=None): self.logfile = self.logfile + (".%d" % k) open(self.logfile, "w").close() - def print(self, message=""): + def print(self, message="", end='\n'): """ Prints a message to stdout and logs it to a file if logging is enabled. @@ -61,10 +61,10 @@ def print(self, message=""): nocolor_message = re.sub(r"\x1b[\[]([0-9;]+)m", "", message) if self.config.no_colors: - print(nocolor_message) + print(nocolor_message, end=end) else: - print(message) - self.__write_to_logfile(nocolor_message) + print(message, end=end) + self.__write_to_logfile(nocolor_message, end=end) def info(self, message): """ @@ -118,7 +118,7 @@ def error(self, message): print("[\x1b[1;91merror\x1b[0m] %s" % message) self.__write_to_logfile("[error] %s" % nocolor_message) - def __write_to_logfile(self, message): + def __write_to_logfile(self, message, end='\n'): """ Writes the provided message to the log file specified during Logger instance initialization. @@ -127,8 +127,8 @@ def __write_to_logfile(self, message): Args: message (str): The message to be written to the log file. """ - + if self.logfile is not None: f = open(self.logfile, "a") - f.write(message + "\n") + f.write(message + end) f.close() \ No newline at end of file diff --git a/smbclientng/core/SessionsManager.py b/smbclientng/core/SessionsManager.py index 1840262..cb79bb1 100644 --- a/smbclientng/core/SessionsManager.py +++ b/smbclientng/core/SessionsManager.py @@ -23,7 +23,7 @@ def __init__(self, config, logger): self.current_session = None self.current_session_id = None - self.config = config, + self.config = config self.logger = logger def create_new_session(self, credentials, host, port=445):