Skip to content

Commit

Permalink
Added config object to __init__ of modules and no_colors in ls function
Browse files Browse the repository at this point in the history
  • Loading branch information
p0dalirius committed May 31, 2024
1 parent 7034d18 commit 7fb70e0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion smbclientng/core/InteractiveShell.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def command_module(self, arguments, command):
module_name = arguments[0]

if module_name in self.modules.keys():
module = self.modules[module_name](self.smbSession)
module = self.modules[module_name](self.smbSession, self.config)
module.run(' '.join(arguments[1:]))
else:
print("[!] Module '%s' does not exist." % module_name)
Expand Down
4 changes: 2 additions & 2 deletions smbclientng/core/Module.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class Module(object):
smbSession = None
options = None

def __init__(self, smbSession):
def __init__(self, smbSession, config):
self.smbSession = smbSession
self.options = None
self.config = config

def parseArgs(self):
raise NotImplementedError("Subclasses must implement this method")
Expand Down
12 changes: 9 additions & 3 deletions smbclientng/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def STYPE_MASK(stype_value):
return flags


def windows_ls_entry(entry, pathToPrint=None):
def windows_ls_entry(entry, config, pathToPrint=None):
"""
This function generates a metadata string based on the attributes of the provided entry object.
Expand Down Expand Up @@ -166,6 +166,12 @@ def windows_ls_entry(entry, pathToPrint=None):
date_str = datetime.datetime.fromtimestamp(entry.get_atime_epoch()).strftime("%Y-%m-%d %H:%M")

if entry.is_directory():
print("%s %10s %s \x1b[1;96m%s\x1b[0m\\" % (meta_string, size_str, date_str, pathToPrint))
if config.no_colors:
print("%s %10s %s %s\\" % (meta_string, size_str, date_str, pathToPrint))
else:
print("%s %10s %s \x1b[1;96m%s\x1b[0m\\" % (meta_string, size_str, date_str, pathToPrint))
else:
print("%s %10s %s \x1b[1m%s\x1b[0m" % (meta_string, size_str, date_str, pathToPrint))
if config.no_colors:
print("%s %10s %s %s" % (meta_string, size_str, date_str, pathToPrint))
else:
print("%s %10s %s \x1b[1m%s\x1b[0m" % (meta_string, size_str, date_str, pathToPrint))
4 changes: 0 additions & 4 deletions smbclientng/modules/Find.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ class Find(Module):
name = "find"
description = "Search for files in a directory hierarchy"

def __init__(self, smbSession):
super(Find, self).__init__(smbSession)
self.smbSession = smbSession

def parseArgs(self, arguments):
parser = ModuleArgumentParser(prog=self.name, description=self.description)

Expand Down

0 comments on commit 7fb70e0

Please sign in to comment.