From 259cd61b9ec5379d6298ef86125e6a7f53f2a1ce Mon Sep 17 00:00:00 2001 From: StopThatTalace <117742366+StopThatTalace@users.noreply.github.com> Date: Sat, 22 Jun 2024 12:09:46 +0200 Subject: [PATCH] add feat option --port Default value to 445 --- smbclientng/__main__.py | 3 +++ smbclientng/core/SMBSession.py | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/smbclientng/__main__.py b/smbclientng/__main__.py index c5d1897..ce82a92 100644 --- a/smbclientng/__main__.py +++ b/smbclientng/__main__.py @@ -28,6 +28,8 @@ def parseArgs(): parser.add_argument("--debug", dest="debug", action="store_true", default=False, help="Debug mode.") parser.add_argument("--no-colors", dest="no_colors", action="store_true", default=False, help="No colors mode.") parser.add_argument("--target", action="store", metavar="ip address", required=True, type=str, help="IP Address of the SMB Server to connect to.") + parser.add_argument("--port", action="store", metavar="port of smb service", type=str, default='445', help="Port of the SMB Server to connect to.") + authconn = parser.add_argument_group("Authentication & connection") authconn.add_argument("--kdcHost", dest="kdcHost", action="store", metavar="FQDN KDC", help="FQDN of KDC for Kerberos.") @@ -97,6 +99,7 @@ def main(): smbSession = SMBSession( address=options.target, + port=options.port, domain=options.auth_domain, username=options.auth_username, password=options.auth_password, diff --git a/smbclientng/core/SMBSession.py b/smbclientng/core/SMBSession.py index 5a03421..fa32868 100644 --- a/smbclientng/core/SMBSession.py +++ b/smbclientng/core/SMBSession.py @@ -44,13 +44,15 @@ class SMBSession(object): Initializes the SMB session by connecting to the server and authenticating using the specified method. """ - def __init__(self, address, domain, username, password, lmhash, nthash, use_kerberos=False, kdcHost=None, config=None): + def __init__(self, address, port, domain, username, password, lmhash, nthash, use_kerberos=False, kdcHost=None, config=None): super(SMBSession, self).__init__() # Objects self.config = config # Target server self.address = address + # Target port (by default on 445) + self.port = int(port) # Credentials self.domain = domain @@ -94,7 +96,7 @@ def init_smb_session(self): self.smbClient = impacket.smbconnection.SMBConnection( remoteName=self.address, remoteHost=self.address, - sess_port=int(445) + sess_port=self.port ) except OSError as err: print("[!] %s" % err)