diff --git a/smbclientng/__main__.py b/smbclientng/__main__.py index c5d1897..df5083d 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=int, 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..b7fd67b 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 = 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=int(self.port) ) except OSError as err: print("[!] %s" % err)