From f82b56fca64a8061b647a52c05c4350be39e374a Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Mon, 16 Mar 2020 12:07:17 +0200 Subject: [PATCH] Improved bootloader telem logging, added docs about monkeyzoo tunneling machine used in tests --- envs/monkey_zoo/docs/fullDocs.md | 6 +---- monkey/infection_monkey/transport/http.py | 30 +++++++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/envs/monkey_zoo/docs/fullDocs.md b/envs/monkey_zoo/docs/fullDocs.md index 1605a4792..e788bb36c 100644 --- a/envs/monkey_zoo/docs/fullDocs.md +++ b/envs/monkey_zoo/docs/fullDocs.md @@ -559,17 +559,13 @@ fullTest.conf is a good config to start, because it covers all machines. OS: Windows server 2019 x64 - -Software: -OpenSSL - Default service’s port: 445 Root password: -:t67TC5ZD+mz +t67TC5ZDmz Server’s config: diff --git a/monkey/infection_monkey/transport/http.py b/monkey/infection_monkey/transport/http.py index 80a977561..40b5a6196 100644 --- a/monkey/infection_monkey/transport/http.py +++ b/monkey/infection_monkey/transport/http.py @@ -112,21 +112,25 @@ class HTTPConnectProxyHandler(http.server.BaseHTTPRequestHandler): proxy_via = None # pseudonym of the proxy in Via header, set to None not to modify original Via header def do_POST(self): - content_length = int(self.headers['Content-Length']) - post_data = self.rfile.read(content_length).decode() try: - r = requests.post(url=self.path, data=post_data) - except requests.exceptions.ConnectionError as e: - LOG.error("Couldn't forward request to the island: {}".format(e)) - return self.send_response(404) - if r.status_code != 200: - # 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): + content_length = int(self.headers['Content-Length']) + post_data = self.rfile.read(content_length).decode() + LOG.info("Received bootloader's request: {}".format(post_data)) + try: + r = requests.post(url=self.path, data=post_data) + except requests.exceptions.ConnectionError as e: + LOG.error("Couldn't forward request to the island: {}".format(e)) return self.send_response(404) - self.send_response(200) - self.end_headers() - self.wfile.write(r.content) + if r.status_code != 200: + # 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.wfile.write(r.content) + except Exception as e: + LOG.error("Failed receiving bootloader telemetry: {}".format(e)) def version_string(self): return ""