From 8524c3717ea34e48ef325401d2215aad2d3a8c62 Mon Sep 17 00:00:00 2001 From: Chris Truncer Date: Thu, 3 Dec 2015 13:33:22 -0700 Subject: [PATCH] Working http and https clients on non standard ports --- protocols/clients/http_client.py | 8 ++++++-- protocols/clients/https_client.py | 11 +++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/protocols/clients/http_client.py b/protocols/clients/http_client.py index 787eebb..770f9c8 100644 --- a/protocols/clients/http_client.py +++ b/protocols/clients/http_client.py @@ -14,6 +14,10 @@ class Client: self.data_to_transmit = '' self.remote_server = cli_object.ip self.protocol = "http" + if cli_object.client_port is None: + self.port = 80 + else: + self.port = cli_object.client_port if cli_object.file is None: self.file_transfer = False else: @@ -25,7 +29,7 @@ class Client: def transmit(self, data_to_transmit): if not self.file_transfer: - url = "http://" + self.remote_server + ":" + self.port + "/post_data.php" + url = "http://" + self.remote_server + ":" + str(self.port) + "/post_data.php" # Post the data to the web server at the specified URL try: @@ -37,7 +41,7 @@ class Client: print "[*] Error: Please check server to make sure it is active!" sys.exit() else: - url = "http://" + self.remote_server + "/post_file.php" + url = "http://" + self.remote_server + ":" + str(self.port) + "/post_file.php" try: data_to_transmit = self.file_transfer + ".:::-989-:::." + data_to_transmit diff --git a/protocols/clients/https_client.py b/protocols/clients/https_client.py index b4c45ce..8683227 100644 --- a/protocols/clients/https_client.py +++ b/protocols/clients/https_client.py @@ -4,6 +4,7 @@ This is the web client code ''' +import ssl import sys import urllib2 @@ -14,6 +15,10 @@ class Client: self.data_to_transmit = '' self.remote_server = cli_object.ip self.protocol = "https" + if cli_object.client_port is None: + self.port = 443 + else: + self.port = cli_object.client_port if cli_object.file is None: self.file_transfer = False else: @@ -23,8 +28,10 @@ class Client: self.file_transfer = cli_object.file def transmit(self, data_to_transmit): + + ssl._create_default_https_context = ssl._create_unverified_context if not self.file_transfer: - url = "https://" + self.remote_server + ":" + self.port + "/post_data.php" + url = "https://" + self.remote_server + ":" + str(self.port) + "/post_data.php" # Post the data to the web server at the specified URL try: @@ -36,7 +43,7 @@ class Client: print "[*] Error: Please check server to make sure it is active!" sys.exit() else: - url = "https://" + self.remote_server + "/post_file.php" + url = "https://" + self.remote_server + ":" + str(self.port) + "/post_file.php" try: data_to_transmit = self.file_transfer + ".:::-989-:::." + data_to_transmit