forked from p15670423/monkey
Added proxies to post request going towards the island
This commit is contained in:
parent
a22cd893d8
commit
a979f2160b
|
@ -12,6 +12,7 @@ import requests
|
||||||
import infection_monkey.monkeyfs as monkeyfs
|
import infection_monkey.monkeyfs as monkeyfs
|
||||||
from infection_monkey.transport.base import TransportProxyBase, update_last_serve_time
|
from infection_monkey.transport.base import TransportProxyBase, update_last_serve_time
|
||||||
from infection_monkey.network.tools import get_interface_to_target
|
from infection_monkey.network.tools import get_interface_to_target
|
||||||
|
import infection_monkey.control
|
||||||
|
|
||||||
__author__ = 'hoffer'
|
__author__ = 'hoffer'
|
||||||
|
|
||||||
|
@ -117,16 +118,11 @@ class HTTPConnectProxyHandler(http.server.BaseHTTPRequestHandler):
|
||||||
post_data = self.rfile.read(content_length).decode()
|
post_data = self.rfile.read(content_length).decode()
|
||||||
LOG.info("Received bootloader's request: {}".format(post_data))
|
LOG.info("Received bootloader's request: {}".format(post_data))
|
||||||
try:
|
try:
|
||||||
r = requests.post(url=self.path, data=post_data)
|
r = requests.post(url=self.path, data=post_data, proxies=infection_monkey.control.ControlClient.proxies)
|
||||||
except requests.exceptions.ConnectionError as e:
|
except requests.exceptions.ConnectionError as e:
|
||||||
LOG.error("Couldn't forward request to the island: {}".format(e))
|
LOG.error("Couldn't forward request to the island: {}".format(e))
|
||||||
return self.send_response(404)
|
return self.send_response(404)
|
||||||
if r.status_code != 200:
|
self.send_response(r.status_code)
|
||||||
# somehow forward post request to the next proxy
|
|
||||||
r = requests.post(url=self.path, data=post_data, proxy=self.path)
|
|
||||||
if (r.status_code != 200):
|
|
||||||
return self.send_response(404)
|
|
||||||
self.send_response(200)
|
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write(r.content)
|
self.wfile.write(r.content)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -136,6 +132,7 @@ class HTTPConnectProxyHandler(http.server.BaseHTTPRequestHandler):
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def do_CONNECT(self):
|
def do_CONNECT(self):
|
||||||
|
LOG.info("Received a connect request!")
|
||||||
# just provide a tunnel, transfer the data with no modification
|
# just provide a tunnel, transfer the data with no modification
|
||||||
req = self
|
req = self
|
||||||
req.path = "https://%s/" % req.path.replace(':443', '')
|
req.path = "https://%s/" % req.path.replace(':443', '')
|
||||||
|
|
Loading…
Reference in New Issue