Lets users specify port for clients if using non-standard ports

client_ports
Chris Truncer 2015-12-03 12:30:23 -07:00
parent cbe3fcc0f4
commit 7da42645cc
4 changed files with 19 additions and 3 deletions

View File

@ -27,6 +27,9 @@ def cli_parser():
protocols.add_argument(
"--client", default=None, metavar="[http]",
help="Extract data over the specified protocol.")
protocols.add_argument(
"--client-port", default=None, metavar="34567", type=int,
help="Port to connect over if using non-standard port.")
protocols.add_argument(
"--list-clients", default=False, action='store_true',
help="List all supported client protocols.")

View File

@ -19,6 +19,10 @@ class Client:
self.remote_server = cli_object.ip
self.username = cli_object.username
self.password = cli_object.password
if cli_object.client_port is None:
self.port = 21
else:
self.port = cli_object.client_port
if cli_object.file is None:
self.file_transfer = False
else:
@ -30,7 +34,8 @@ class Client:
def transmit(self, data_to_transmit):
try:
ftp = FTP(self.remote_server)
ftp = FTP()
ftp.connect(self.remote_server, self.port)
except socket.gaierror:
print "[*] Error: Cannot connect to FTP server. Checking provided ip!"
sys.exit()

View File

@ -21,6 +21,10 @@ class Client:
self.username = cli_object.username
self.password = cli_object.password
self.remote_system = cli_object.ip
if cli_object.client_port is None:
self.port = 22
else:
self.port = cli_object.client_port
if cli_object.file is None:
self.file_transfer = False
else:
@ -37,7 +41,7 @@ class Client:
sftp_file_name = helpers.writeout_text_data(data_to_transmit)
full_path = helpers.ea_path() + "/" + sftp_file_name
transport = paramiko.Transport(self.remote_system)
transport = paramiko.Transport((self.remote_system, self.port))
transport.connect(username=self.username, password=self.password)
sftp = paramiko.SFTPClient.from_transport(transport)
sftp.put(full_path, '/' + sftp_file_name)

View File

@ -23,6 +23,10 @@ class Client:
def __init__(self, cli_object):
self.protocol = "smtp"
self.remote_server = cli_object.ip
if cli_object.client_port is None:
self.port = 25
else:
self.port = cli_object.client_ports
if cli_object.file is None:
self.file_transfer = False
else:
@ -58,7 +62,7 @@ class Client:
part.add_header('Content-Disposition', 'attachment; filename=' + self.file_transfer)
msg.attach(part)
server = smtplib.SMTP(self.remote_server, 25)
server = smtplib.SMTP(self.remote_server, self.port)
server.set_debuglevel(False)
try:
server.sendmail('tester@egress-assess.com', ['server@egress-assess.com'], msg.as_string())