Skip to content

Commit

Permalink
add feat option --port
Browse files Browse the repository at this point in the history
Default value to 445
  • Loading branch information
StopThatTalace committed Jun 22, 2024
1 parent 17b49ec commit 259cd61
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions smbclientng/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions smbclientng/core/SMBSession.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 259cd61

Please sign in to comment.