From 8fba2f73518e4979afa9178d2a86e364cd0ed5fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20GASCOU=20=28Podalirius=29?= Date: Thu, 3 Oct 2024 16:14:53 +0200 Subject: [PATCH] Release 2.1.6, Fixed #84 (#105) --- pyproject.toml | 2 +- setup.py | 2 +- smbclientng/__main__.py | 8 +++++--- smbclientng/core/SMBSession.py | 4 +++- smbclientng/core/SessionsManager.py | 4 +++- testing/run.sh | 2 +- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1620333..16ccf9f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "smbclientng" -version = "2.1.5" +version = "2.1.6" description = "smbclient-ng, a fast and user friendly way to interact with SMB shares." authors = ["p0dalirius"] diff --git a/setup.py b/setup.py index 69305e3..ed8f202 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ import setuptools -VERSION = "2.1.5" +VERSION = "2.1.6" long_description = """ diff --git a/smbclientng/__main__.py b/smbclientng/__main__.py index 34944ee..f28c73e 100644 --- a/smbclientng/__main__.py +++ b/smbclientng/__main__.py @@ -13,7 +13,7 @@ from smbclientng.core.SessionsManager import SessionsManager -VERSION = "2.1.5" +VERSION = "2.1.6" def parseArgs(): @@ -31,7 +31,8 @@ def parseArgs(): parser.add_argument("-S", "--startup-script", metavar="startup_script", required=False, type=str, help="File containing the list of commands to be typed at start of the console.") parser.add_argument("-N", "--not-interactive", dest="not_interactive", required=False, action="store_true", default=False, help="Non interactive mode.") parser.add_argument("-L", "--logfile", dest="logfile", metavar="LOGFILE", required=False, default=None, type=str, help="File to write logs to.") - parser.add_argument( "--timeout", dest="timeout", metavar="TIMEOUT", required=False, type=float, default=3, help="Timeout in seconds for SMB connections (default: 3)") + parser.add_argument("--timeout", dest="timeout", metavar="TIMEOUT", required=False, type=float, default=3, help="Timeout in seconds for SMB connections (default: 3)") + parser.add_argument("--advertised-name", dest="advertisedName", metavar="ADVERTISED_NAME", required=False, type=str, help="Advertised name of your machine to the SMB client.") group_target = parser.add_argument_group("Target") group_target.add_argument("--host", action="store", metavar="HOST", required=True, type=str, help="IP address or hostname of the SMB Server to connect to.") @@ -113,7 +114,7 @@ def main(): sessionsManager = SessionsManager(config=config, logger=logger) - if any([(options.auth_domain != '.'), (options.auth_username is not None), (options.auth_password is not None),(options.auth_hashes is not None)]): + if any([(options.auth_domain != '.'), (options.auth_username is not None), (options.auth_password is not None), (options.auth_hashes is not None)]): credentials = Credentials( domain=options.auth_domain, username=options.auth_username, @@ -128,6 +129,7 @@ def main(): host=options.host, port=options.port, timeout=options.timeout, + advertisedName=options.advertisedName ) # Start the main interactive command line diff --git a/smbclientng/core/SMBSession.py b/smbclientng/core/SMBSession.py index 691d9c2..019af58 100644 --- a/smbclientng/core/SMBSession.py +++ b/smbclientng/core/SMBSession.py @@ -53,7 +53,7 @@ class SMBSession(object): test_rights(sharename): Tests read and write access rights on a share. """ - def __init__(self, host, port, timeout, credentials, config=None, logger=None): + def __init__(self, host, port, timeout, credentials, advertisedName=None, config=None, logger=None): super(SMBSession, self).__init__() # Objects self.config = config @@ -65,6 +65,7 @@ def __init__(self, host, port, timeout, credentials, config=None, logger=None): self.port = port # Timeout (default 3 seconds) self.timeout = timeout + self.advertisedName = advertisedName # Credentials self.credentials = credentials @@ -125,6 +126,7 @@ def init_smb_session(self): self.smbClient = impacket.smbconnection.SMBConnection( remoteName=self.host, remoteHost=self.host, + myName=self.advertisedName, sess_port=int(self.port), timeout=self.timeout, ) diff --git a/smbclientng/core/SessionsManager.py b/smbclientng/core/SessionsManager.py index 6bf77f4..0081f47 100644 --- a/smbclientng/core/SessionsManager.py +++ b/smbclientng/core/SessionsManager.py @@ -38,7 +38,7 @@ def __init__(self, config, logger): self.config = config self.logger = logger - def create_new_session(self, credentials, host, timeout, port=445): + def create_new_session(self, credentials, host, timeout, port=445, advertisedName=None): """ Creates a new session with the given session information. @@ -54,6 +54,7 @@ def create_new_session(self, credentials, host, timeout, port=445): port=port, timeout=timeout, credentials=credentials, + advertisedName=advertisedName, config=self.config, logger=self.logger ) @@ -127,6 +128,7 @@ def process_command_line(self, arguments): # Create mode_create = ModuleArgumentParser(add_help=False, description="Create a new session.") + mode_create.add_argument("--advertised-name", dest="advertisedName", metavar="ADVERTISED_NAME", required=False, type=str, help="Advertised name of your machine to the SMB client.") group_target = mode_create.add_argument_group("Target") group_target.add_argument("--host", action="store", metavar="HOST", required=True, type=str, help="IP address or hostname of the SMB Server to connect to.") group_target.add_argument("--port", action="store", metavar="PORT", type=int, default=445, help="Port of the SMB Server to connect to. (default: 445)") diff --git a/testing/run.sh b/testing/run.sh index 4ce5390..e574930 100644 --- a/testing/run.sh +++ b/testing/run.sh @@ -1,3 +1,3 @@ #!/bin/bash -python3 main.py -d 'LAB' -u 'Administrator' -p 'Admin123!' --host '192.168.56.106' ${@} +python3 main.py -d 'LAB' -u 'Administrator' -p 'Admin123!' --host '10.0.0.201' ${@}