Skip to content

Commit

Permalink
Merge branch 'main' into Add-option-to-read-interactive-commands-from…
Browse files Browse the repository at this point in the history
…-a-file
  • Loading branch information
p0dalirius authored Jun 22, 2024
2 parents a6c04b3 + 2bd4e5b commit 88df57f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion smbclientng/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ 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("-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("--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.")
Expand Down Expand Up @@ -107,6 +107,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 = 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=int(self.port)
)
except OSError as err:
print("[!] %s" % err)
Expand Down

0 comments on commit 88df57f

Please sign in to comment.