Lets users specify port for clients if using non-standard ports
parent
cbe3fcc0f4
commit
7da42645cc
|
@ -27,6 +27,9 @@ def cli_parser():
|
||||||
protocols.add_argument(
|
protocols.add_argument(
|
||||||
"--client", default=None, metavar="[http]",
|
"--client", default=None, metavar="[http]",
|
||||||
help="Extract data over the specified protocol.")
|
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(
|
protocols.add_argument(
|
||||||
"--list-clients", default=False, action='store_true',
|
"--list-clients", default=False, action='store_true',
|
||||||
help="List all supported client protocols.")
|
help="List all supported client protocols.")
|
||||||
|
|
|
@ -19,6 +19,10 @@ class Client:
|
||||||
self.remote_server = cli_object.ip
|
self.remote_server = cli_object.ip
|
||||||
self.username = cli_object.username
|
self.username = cli_object.username
|
||||||
self.password = cli_object.password
|
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:
|
if cli_object.file is None:
|
||||||
self.file_transfer = False
|
self.file_transfer = False
|
||||||
else:
|
else:
|
||||||
|
@ -30,7 +34,8 @@ class Client:
|
||||||
def transmit(self, data_to_transmit):
|
def transmit(self, data_to_transmit):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ftp = FTP(self.remote_server)
|
ftp = FTP()
|
||||||
|
ftp.connect(self.remote_server, self.port)
|
||||||
except socket.gaierror:
|
except socket.gaierror:
|
||||||
print "[*] Error: Cannot connect to FTP server. Checking provided ip!"
|
print "[*] Error: Cannot connect to FTP server. Checking provided ip!"
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
|
@ -21,6 +21,10 @@ class Client:
|
||||||
self.username = cli_object.username
|
self.username = cli_object.username
|
||||||
self.password = cli_object.password
|
self.password = cli_object.password
|
||||||
self.remote_system = cli_object.ip
|
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:
|
if cli_object.file is None:
|
||||||
self.file_transfer = False
|
self.file_transfer = False
|
||||||
else:
|
else:
|
||||||
|
@ -37,7 +41,7 @@ class Client:
|
||||||
sftp_file_name = helpers.writeout_text_data(data_to_transmit)
|
sftp_file_name = helpers.writeout_text_data(data_to_transmit)
|
||||||
full_path = helpers.ea_path() + "/" + sftp_file_name
|
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)
|
transport.connect(username=self.username, password=self.password)
|
||||||
sftp = paramiko.SFTPClient.from_transport(transport)
|
sftp = paramiko.SFTPClient.from_transport(transport)
|
||||||
sftp.put(full_path, '/' + sftp_file_name)
|
sftp.put(full_path, '/' + sftp_file_name)
|
||||||
|
|
|
@ -23,6 +23,10 @@ class Client:
|
||||||
def __init__(self, cli_object):
|
def __init__(self, cli_object):
|
||||||
self.protocol = "smtp"
|
self.protocol = "smtp"
|
||||||
self.remote_server = cli_object.ip
|
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:
|
if cli_object.file is None:
|
||||||
self.file_transfer = False
|
self.file_transfer = False
|
||||||
else:
|
else:
|
||||||
|
@ -58,7 +62,7 @@ class Client:
|
||||||
part.add_header('Content-Disposition', 'attachment; filename=' + self.file_transfer)
|
part.add_header('Content-Disposition', 'attachment; filename=' + self.file_transfer)
|
||||||
msg.attach(part)
|
msg.attach(part)
|
||||||
|
|
||||||
server = smtplib.SMTP(self.remote_server, 25)
|
server = smtplib.SMTP(self.remote_server, self.port)
|
||||||
server.set_debuglevel(False)
|
server.set_debuglevel(False)
|
||||||
try:
|
try:
|
||||||
server.sendmail('tester@egress-assess.com', ['server@egress-assess.com'], msg.as_string())
|
server.sendmail('tester@egress-assess.com', ['server@egress-assess.com'], msg.as_string())
|
||||||
|
|
Loading…
Reference in New Issue