From a44e9a901f9528acfe2ed44b689dc9d08ac8dc80 Mon Sep 17 00:00:00 2001 From: Daniel Goldberg Date: Wed, 17 Oct 2018 16:45:48 +0300 Subject: [PATCH 1/2] Limit monkey lookup in find_server. Prevents a situation where the Monkey attempts to connect to a server, but it's not accessible over the regular port but requires a tunnel. However the Monkey on the other side will quit before getting the tunnel request because the isolated monkey is waiting forever --- monkey/infection_monkey/control.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/monkey/infection_monkey/control.py b/monkey/infection_monkey/control.py index 7322322e7..ea7507626 100644 --- a/monkey/infection_monkey/control.py +++ b/monkey/infection_monkey/control.py @@ -19,6 +19,9 @@ requests.packages.urllib3.disable_warnings() LOG = logging.getLogger(__name__) DOWNLOAD_CHUNK = 1024 +# random number greater than 5, +# to prevent the monkey from just waiting forever to try and connect to an island before going elsewhere. +TIMEOUT = 9 class ControlClient(object): @@ -72,7 +75,8 @@ class ControlClient(object): LOG.debug(debug_message) requests.get("https://%s/api?action=is-up" % (server,), verify=False, - proxies=ControlClient.proxies) + proxies=ControlClient.proxies, + timeout=TIMEOUT) WormConfiguration.current_server = current_server break From 372a08791da57bf7874b7cee58e800acb004920e Mon Sep 17 00:00:00 2001 From: Daniel Goldberg Date: Thu, 18 Oct 2018 15:47:12 +0300 Subject: [PATCH 2/2] Change timeout --- monkey/infection_monkey/control.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monkey/infection_monkey/control.py b/monkey/infection_monkey/control.py index ea7507626..98ad55671 100644 --- a/monkey/infection_monkey/control.py +++ b/monkey/infection_monkey/control.py @@ -21,7 +21,7 @@ LOG = logging.getLogger(__name__) DOWNLOAD_CHUNK = 1024 # random number greater than 5, # to prevent the monkey from just waiting forever to try and connect to an island before going elsewhere. -TIMEOUT = 9 +TIMEOUT = 15 class ControlClient(object):