Compare commits

...
3 changed files with 15 additions and 4 deletions

No files matched your search

+1
View File
@@ -344,6 +344,7 @@ class connection:
data = [] # Arbitrary data needed for the login, e.g. ssh_key
for cred_id in self.args.cred_id:
self.logger.debug(f"Querying database for credential ID: {cred_id}")
if cred_id.lower() == "all":
creds = self.db.get_credentials()
else:
+6
View File
@@ -162,6 +162,12 @@ class NXCAdapter(logging.LoggerAdapter):
nxc_console.print(text, *args, **kwargs)
self.log_console_to_file(text, *args, **kwargs)
def error(self, msg, *args, exc_info=None, stack_info=False, stacklevel=1, extra=None, **kwargs):
"""Wrapper for the error method of the logger, but will also print the host ip if available"""
if self.extra and self.extra["host"]:
msg = f"Host {self.extra['host']}: {msg}"
return super().error(msg, *args, exc_info=exc_info, stack_info=stack_info, stacklevel=stacklevel, extra=extra, **kwargs)
def log_console_to_file(self, text, *args, **kwargs):
"""Log the console output to a file
+8 -4
View File
@@ -209,7 +209,7 @@ class smb(connection):
self.local_ip = self.conn.getSMBServer().get_socket().getsockname()[0]
try:
self.conn.login("", "")
logged_in = self.conn.login("", "")
except BrokenPipeError:
self.logger.fail("Broken Pipe Error while attempting to login")
except Exception as e:
@@ -305,8 +305,13 @@ class smb(connection):
self.logger.info(f"Resolved domain: {self.domain} with dns, kdcHost: {self.kdcHost}")
# If we want to authenticate we should create another connection object, because we already logged in
if self.args.username or self.args.cred_id or self.kerberos or self.args.use_kcache:
self.create_conn_obj()
# if self.args.username or self.args.cred_id or self.kerberos or self.args.use_kcache:
# self.logger.debug(f"Recreating connection object because of {bool(self.args.username)=}, {bool(self.args.cred_id)=}, {self.kerberos=}, {self.args.use_kcache=}")
# self.create_conn_obj()
# if logged_in:
# self.logger.debug(f"Logged in anonymously to host {self.host}, recreating connection object")
# self.create_conn_obj()
self.create_conn_obj()
def print_host_info(self):
signing = colored(f"signing:{self.signing}", host_info_colors[0], attrs=["bold"]) if self.signing else colored(f"signing:{self.signing}", host_info_colors[1], attrs=["bold"])
@@ -404,7 +409,6 @@ class smb(connection):
return False
def plaintext_login(self, domain, username, password):
# Re-connect since we logged off
try:
self.password = password
self.username = username