Skip to content

Commit

Permalink
Release 2.1.6, Fixed #84 (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
p0dalirius authored Oct 3, 2024
1 parent 91ea799 commit 8fba2f7
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"]

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import setuptools


VERSION = "2.1.5"
VERSION = "2.1.6"


long_description = """
Expand Down
8 changes: 5 additions & 3 deletions smbclientng/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from smbclientng.core.SessionsManager import SessionsManager


VERSION = "2.1.5"
VERSION = "2.1.6"


def parseArgs():
Expand All @@ -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.")
Expand Down Expand Up @@ -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,
Expand All @@ -128,6 +129,7 @@ def main():
host=options.host,
port=options.port,
timeout=options.timeout,
advertisedName=options.advertisedName
)

# Start the main interactive command line
Expand Down
4 changes: 3 additions & 1 deletion smbclientng/core/SMBSession.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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,
)
Expand Down
4 changes: 3 additions & 1 deletion smbclientng/core/SessionsManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
)
Expand Down Expand Up @@ -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)")
Expand Down
2 changes: 1 addition & 1 deletion testing/run.sh
Original file line number Diff line number Diff line change
@@ -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' ${@}

0 comments on commit 8fba2f7

Please sign in to comment.