From 81cc196dcefd692f12b3835f3dd8066867958fbd Mon Sep 17 00:00:00 2001 From: root Date: Mon, 16 Dec 2019 19:08:29 +0530 Subject: [PATCH 01/13] External IP Patch --- monkey/infection_monkey/monkey.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index 80d2d86425c..f18c91f7300 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -79,12 +79,24 @@ def initialize(self): self._network = NetworkScanner() self._dropper_path = sys.argv[0] + server_num=0 + secondary_servers= len(self._args) + if self._default_server: if self._default_server not in WormConfiguration.command_servers: LOG.debug("Added default server: %s" % self._default_server) - WormConfiguration.command_servers.insert(0, self._default_server) + WormConfiguration.command_servers.insert(server_num, self._default_server) else: LOG.debug("Default server: %s is already in command servers list" % self._default_server) + server_num=server_num+1 + + while server_num<(secondary_servers+1): + if self._args[server_num -1] not in WormConfiguration.command_servers: + LOG.debug("Added default server: %s" % self._args[server_num -1]) + WormConfiguration.command_servers.insert(server_num, self._args[server_num-1]) + else: + LOG.debug("Default server: %s is already in command servers list" % self._args[server_num-1]) + server_num=server_num+1 def start(self): LOG.info("Monkey is running...") From b820eb029bc020da9e6322c59a253e2bc05cc858 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 7 Apr 2020 16:56:36 +0530 Subject: [PATCH 02/13] Pre-Final Patch --- .../infection_monkey/exploit/tools/helpers.py | 6 +++- monkey/infection_monkey/monkey.py | 28 +++++++++---------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/monkey/infection_monkey/exploit/tools/helpers.py b/monkey/infection_monkey/exploit/tools/helpers.py index 1fc2fc4f180..b241b1ae26f 100644 --- a/monkey/infection_monkey/exploit/tools/helpers.py +++ b/monkey/infection_monkey/exploit/tools/helpers.py @@ -62,8 +62,12 @@ def build_monkey_commandline_explicitly(parent=None, tunnel=None, server=None, d def build_monkey_commandline(target_host, depth, location=None): from infection_monkey.config import GUID + from infection_monkey.config import WormConfiguration + Server_String =" " + for server in WormConfiguration.command_servers: + Server_String = Server_String + server + " " return build_monkey_commandline_explicitly( - GUID, target_host.default_tunnel, target_host.default_server, depth, location) + GUID, target_host.default_tunnel, Server_String, depth, location) def get_monkey_depth(): diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index 1b29a2e29b4..9538987e208 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -72,7 +72,7 @@ def initialize(self): arg_parser = argparse.ArgumentParser() arg_parser.add_argument('-p', '--parent') arg_parser.add_argument('-t', '--tunnel') - arg_parser.add_argument('-s', '--server') + arg_parser.add_argument('-s', '--server',nargs = '+') arg_parser.add_argument('-d', '--depth', type=int) self._opts, self._args = arg_parser.parse_known_args(self._args) @@ -90,20 +90,20 @@ def initialize(self): secondary_servers= len(self._args) if self._default_server: - if self._default_server not in WormConfiguration.command_servers: - LOG.debug("Added default server: %s" % self._default_server) - WormConfiguration.command_servers.insert(server_num, self._default_server) - else: - LOG.debug("Default server: %s is already in command servers list" % self._default_server) - server_num=server_num+1 + if self._default_server[0] not in WormConfiguration.command_servers: + LOG.debug("Added default server: %s" % self._default_server[0]) + WormConfiguration.command_servers.insert(0, self._default_server[0]) + else: + LOG.debug("Default server: %s is already in command servers list" % self._default_server[0]) + server_num=server_num+1 - while server_num<(secondary_servers+1): - if self._args[server_num -1] not in WormConfiguration.command_servers: - LOG.debug("Added default server: %s" % self._args[server_num -1]) - WormConfiguration.command_servers.insert(server_num, self._args[server_num-1]) - else: - LOG.debug("Default server: %s is already in command servers list" % self._args[server_num-1]) - server_num=server_num+1 + while server_num<(secondary_servers): + if self._default_server[server_num ] not in WormConfiguration.command_servers: + LOG.debug("Added default server: %s" % self._default_server[server_num]) + WormConfiguration.command_servers.insert(server_num, self._default_server[server_num]) + else: + LOG.debug("Default server: %s is already in command servers list" % self._default_server[server_num]) + server_num=server_num+1 def start(self): try: From 398d714ae6d2de5aeca1bd722f72c562458a24ac Mon Sep 17 00:00:00 2001 From: root Date: Tue, 21 Apr 2020 18:48:26 +0530 Subject: [PATCH 03/13] 1 --- monkey/infection_monkey/monkey.py | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index 9538987e208..a2790286498 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -57,7 +57,7 @@ def __init__(self, args): self._dropper_path = None self._exploiters = None self._fingerprint = None - self._default_server = None + self._default_servers = None self._default_server_port = None self._depth = 0 self._opts = None @@ -72,13 +72,13 @@ def initialize(self): arg_parser = argparse.ArgumentParser() arg_parser.add_argument('-p', '--parent') arg_parser.add_argument('-t', '--tunnel') - arg_parser.add_argument('-s', '--server',nargs = '+') + arg_parser.add_argument('-s', '--server', nargs = '+') arg_parser.add_argument('-d', '--depth', type=int) self._opts, self._args = arg_parser.parse_known_args(self._args) self._parent = self._opts.parent self._default_tunnel = self._opts.tunnel - self._default_server = self._opts.server + self._default_servers = self._opts.server if self._opts.depth: WormConfiguration._depth_from_commandline = True @@ -87,17 +87,10 @@ def initialize(self): self._dropper_path = sys.argv[0] server_num=0 - secondary_servers= len(self._args) + server_count= len(self._args)+1 - if self._default_server: - if self._default_server[0] not in WormConfiguration.command_servers: - LOG.debug("Added default server: %s" % self._default_server[0]) - WormConfiguration.command_servers.insert(0, self._default_server[0]) - else: - LOG.debug("Default server: %s is already in command servers list" % self._default_server[0]) - server_num=server_num+1 - - while server_num<(secondary_servers): + if self._default_servers + while server_num < (server_count): if self._default_server[server_num ] not in WormConfiguration.command_servers: LOG.debug("Added default server: %s" % self._default_server[server_num]) WormConfiguration.command_servers.insert(server_num, self._default_server[server_num]) @@ -186,13 +179,13 @@ def start(self): if monkey_tunnel: monkey_tunnel.set_tunnel_for_host(machine) - if self._default_server: - if self._network.on_island(self._default_server): + if self._default_servers: + if self._network.on_island(self._default_servers): machine.set_default_server(get_interface_to_target(machine.ip_addr) + (':' + self._default_server_port if self._default_server_port else '')) else: - machine.set_default_server(self._default_server) - LOG.debug("Default server for machine: %r set to %s" % (machine, machine.default_server)) + machine.set_default_server(self._default_servers) + LOG.debug("Default server for machine: %r set to %s" % (machine, machine.default_servers)) # Order exploits according to their type if WormConfiguration.should_exploit: From eb616514e857d24d13be21dd3281db541ffba158 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 21 Apr 2020 19:10:50 +0530 Subject: [PATCH 04/13] Pre-Final Patch 2 --- .../infection_monkey/exploit/tools/helpers.py | 12 ++++++---- .../monkey_island/cc/resources/local_run.py | 24 ++++++++++++++++++- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/monkey/infection_monkey/exploit/tools/helpers.py b/monkey/infection_monkey/exploit/tools/helpers.py index b241b1ae26f..3a06a928b7d 100644 --- a/monkey/infection_monkey/exploit/tools/helpers.py +++ b/monkey/infection_monkey/exploit/tools/helpers.py @@ -43,6 +43,12 @@ def get_target_monkey_by_os(is_windows, is_32bit): def build_monkey_commandline_explicitly(parent=None, tunnel=None, server=None, depth=None, location=None): cmdline = "" + + from infection_monkey.config import WormConfiguration #Passing Multiple Servers for Monkey to connect back + Server_String =" " + for server in WormConfiguration.command_servers: + Server_String = Server_String + server + " " + server = Server_String if parent is not None: cmdline += " -p " + parent @@ -62,12 +68,8 @@ def build_monkey_commandline_explicitly(parent=None, tunnel=None, server=None, d def build_monkey_commandline(target_host, depth, location=None): from infection_monkey.config import GUID - from infection_monkey.config import WormConfiguration - Server_String =" " - for server in WormConfiguration.command_servers: - Server_String = Server_String + server + " " return build_monkey_commandline_explicitly( - GUID, target_host.default_tunnel, Server_String, depth, location) + GUID, target_host.default_tunnel, target_host.default_server, depth, location) def get_monkey_depth(): diff --git a/monkey/monkey_island/cc/resources/local_run.py b/monkey/monkey_island/cc/resources/local_run.py index 41f5fa417d2..e6e8db7ab09 100644 --- a/monkey/monkey_island/cc/resources/local_run.py +++ b/monkey/monkey_island/cc/resources/local_run.py @@ -43,7 +43,29 @@ def run_local_monkey(): # run the monkey try: - args = ['"%s" m0nk3y -s %s:%s' % (target_path, local_ip_addresses()[0], env.get_island_port())] + + #Retrieving the Command Servers from Monkey_Island UI + Config_Dict=ConfigService.get_config(False,True,True) + CommandServerUI_List=Config_Dict['cnc']['servers']['command_servers'] + Final_IPList=[] #The IP List of all servers that need to be communicated + + i=0 + while(i Date: Thu, 23 Apr 2020 13:45:16 +0530 Subject: [PATCH 05/13] Pre Final Patch-3 --- monkey/infection_monkey/dropper.py | 2 +- .../infection_monkey/exploit/tools/helpers.py | 19 +++++++++++------- monkey/infection_monkey/model/host.py | 4 +--- monkey/infection_monkey/monkey.py | 20 ++++++++----------- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/monkey/infection_monkey/dropper.py b/monkey/infection_monkey/dropper.py index 55a359b60cf..03836855738 100644 --- a/monkey/infection_monkey/dropper.py +++ b/monkey/infection_monkey/dropper.py @@ -41,7 +41,7 @@ def __init__(self, args): arg_parser = argparse.ArgumentParser() arg_parser.add_argument('-p', '--parent') arg_parser.add_argument('-t', '--tunnel') - arg_parser.add_argument('-s', '--server') + arg_parser.add_argument('-s', '--servers') arg_parser.add_argument('-d', '--depth', type=int) arg_parser.add_argument('-l', '--location') self.monkey_args = args[1:] diff --git a/monkey/infection_monkey/exploit/tools/helpers.py b/monkey/infection_monkey/exploit/tools/helpers.py index 3a06a928b7d..15b71c38071 100644 --- a/monkey/infection_monkey/exploit/tools/helpers.py +++ b/monkey/infection_monkey/exploit/tools/helpers.py @@ -40,22 +40,27 @@ def get_target_monkey_by_os(is_windows, is_32bit): from infection_monkey.control import ControlClient return ControlClient.download_monkey_exe_by_os(is_windows, is_32bit) - -def build_monkey_commandline_explicitly(parent=None, tunnel=None, server=None, depth=None, location=None): - cmdline = "" +def build_server_string(): from infection_monkey.config import WormConfiguration #Passing Multiple Servers for Monkey to connect back - Server_String =" " + server_string = " " for server in WormConfiguration.command_servers: - Server_String = Server_String + server + " " - server = Server_String + server_string = server_string + server + " " + + return server_string + + +def build_monkey_commandline_explicitly(parent=None, tunnel=None, servers=None, depth=None, location=None): + cmdline = "" + + servers = build_server_string() #Getting the Multiple Server String if parent is not None: cmdline += " -p " + parent if tunnel is not None: cmdline += " -t " + tunnel if server is not None: - cmdline += " -s " + server + cmdline += " -s " + servers if depth is not None: if depth < 0: depth = 0 diff --git a/monkey/infection_monkey/model/host.py b/monkey/infection_monkey/model/host.py index 1a4fef1c81d..7f14466ae5d 100644 --- a/monkey/infection_monkey/model/host.py +++ b/monkey/infection_monkey/model/host.py @@ -9,7 +9,7 @@ def __init__(self, ip_addr, domain_name=''): self.services = {} self.monkey_exe = None self.default_tunnel = None - self.default_server = None + self.server_list = None def as_dict(self): return self.__dict__ @@ -44,5 +44,3 @@ def __str__(self): victim += "target monkey: %s" % self.monkey_exe return victim - def set_default_server(self, default_server): - self.default_server = default_server diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index a2790286498..275c50546d6 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -57,7 +57,7 @@ def __init__(self, args): self._dropper_path = None self._exploiters = None self._fingerprint = None - self._default_servers = None + self._default_server = None self._default_server_port = None self._depth = 0 self._opts = None @@ -72,13 +72,13 @@ def initialize(self): arg_parser = argparse.ArgumentParser() arg_parser.add_argument('-p', '--parent') arg_parser.add_argument('-t', '--tunnel') - arg_parser.add_argument('-s', '--server', nargs = '+') + arg_parser.add_argument('-s', '--servers', nargs = '+') arg_parser.add_argument('-d', '--depth', type=int) self._opts, self._args = arg_parser.parse_known_args(self._args) self._parent = self._opts.parent self._default_tunnel = self._opts.tunnel - self._default_servers = self._opts.server + self._default_server = self._opts.server if self._opts.depth: WormConfiguration._depth_from_commandline = True @@ -87,9 +87,9 @@ def initialize(self): self._dropper_path = sys.argv[0] server_num=0 - server_count= len(self._args)+1 + server_count = len(self._default_server) - if self._default_servers + if self._default_server: while server_num < (server_count): if self._default_server[server_num ] not in WormConfiguration.command_servers: LOG.debug("Added default server: %s" % self._default_server[server_num]) @@ -179,13 +179,9 @@ def start(self): if monkey_tunnel: monkey_tunnel.set_tunnel_for_host(machine) - if self._default_servers: - if self._network.on_island(self._default_servers): - machine.set_default_server(get_interface_to_target(machine.ip_addr) + - (':' + self._default_server_port if self._default_server_port else '')) - else: - machine.set_default_server(self._default_servers) - LOG.debug("Default server for machine: %r set to %s" % (machine, machine.default_servers)) + if self._default_server: + machine.server_list = WormConfiguration.command_servers + # Order exploits according to their type if WormConfiguration.should_exploit: From e0c70e248a95fd951be4753b71204b92d99c71a9 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 26 Apr 2020 16:18:27 +0530 Subject: [PATCH 06/13] Final Patch 1 --- monkey/infection_monkey/config.py | 12 +++++++++ .../infection_monkey/exploit/tools/helpers.py | 14 +--------- monkey/infection_monkey/monkey.py | 26 +++++++++---------- .../monkey_island/cc/resources/local_run.py | 24 +---------------- 4 files changed, 27 insertions(+), 49 deletions(-) diff --git a/monkey/infection_monkey/config.py b/monkey/infection_monkey/config.py index 5c5b5a3923a..dcb228e7807 100644 --- a/monkey/infection_monkey/config.py +++ b/monkey/infection_monkey/config.py @@ -232,6 +232,18 @@ def get_exploit_user_password_or_hash_product(self): cred_list.append(cred) return cred_list + def get_command_server_string(self): + """ + Returns a string that contains all the command servers that monkey can connect back to + """ + server_string = " " + + for server in self.command_servers: + server_string = server_string + server + " " + + return server_string + + exploit_user_list = ['Administrator', 'root', 'user'] exploit_password_list = ["Password1!", "1234", "password", "12345678"] exploit_lm_hash_list = [] diff --git a/monkey/infection_monkey/exploit/tools/helpers.py b/monkey/infection_monkey/exploit/tools/helpers.py index 15b71c38071..aa9e61aa465 100644 --- a/monkey/infection_monkey/exploit/tools/helpers.py +++ b/monkey/infection_monkey/exploit/tools/helpers.py @@ -40,26 +40,14 @@ def get_target_monkey_by_os(is_windows, is_32bit): from infection_monkey.control import ControlClient return ControlClient.download_monkey_exe_by_os(is_windows, is_32bit) -def build_server_string(): - - from infection_monkey.config import WormConfiguration #Passing Multiple Servers for Monkey to connect back - server_string = " " - for server in WormConfiguration.command_servers: - server_string = server_string + server + " " - - return server_string - - def build_monkey_commandline_explicitly(parent=None, tunnel=None, servers=None, depth=None, location=None): cmdline = "" - - servers = build_server_string() #Getting the Multiple Server String if parent is not None: cmdline += " -p " + parent if tunnel is not None: cmdline += " -t " + tunnel - if server is not None: + if servers is not None: cmdline += " -s " + servers if depth is not None: if depth < 0: diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index 275c50546d6..86705d9e89b 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -57,7 +57,7 @@ def __init__(self, args): self._dropper_path = None self._exploiters = None self._fingerprint = None - self._default_server = None + self._default_servers = None self._default_server_port = None self._depth = 0 self._opts = None @@ -78,7 +78,7 @@ def initialize(self): self._parent = self._opts.parent self._default_tunnel = self._opts.tunnel - self._default_server = self._opts.server + self._default_servers = self._opts.server if self._opts.depth: WormConfiguration._depth_from_commandline = True @@ -87,15 +87,15 @@ def initialize(self): self._dropper_path = sys.argv[0] server_num=0 - server_count = len(self._default_server) + server_count = len(self._default_servers) - if self._default_server: + if self._default_servers: while server_num < (server_count): - if self._default_server[server_num ] not in WormConfiguration.command_servers: - LOG.debug("Added default server: %s" % self._default_server[server_num]) - WormConfiguration.command_servers.insert(server_num, self._default_server[server_num]) + if self._default_servers[server_num ] not in WormConfiguration.command_servers: + LOG.debug("Added default server: %s" % self._default_servers[server_num]) + WormConfiguration.command_servers.insert(server_num, self._default_servers[server_num]) else: - LOG.debug("Default server: %s is already in command servers list" % self._default_server[server_num]) + LOG.debug("Default server: %s is already in command servers list" % self._default_servers[server_num]) server_num=server_num+1 def start(self): @@ -179,8 +179,8 @@ def start(self): if monkey_tunnel: monkey_tunnel.set_tunnel_for_host(machine) - if self._default_server: - machine.server_list = WormConfiguration.command_servers + if self._default_servers: + machine.server_list = WormConfiguration.get_command_server_string() # Order exploits according to their type @@ -364,7 +364,7 @@ def successfully_exploited(self, machine, exploiter): def set_default_port(self): try: - self._default_server_port = self._default_server.split(':')[1] + self._default_server_port = self._default_servers.split(':')[1] except KeyError: self._default_server_port = '' @@ -375,5 +375,5 @@ def set_default_server(self): """ if not ControlClient.find_server(default_tunnel=self._default_tunnel): raise PlannedShutdownException("Monkey couldn't find server with {} default tunnel.".format(self._default_tunnel)) - self._default_server = WormConfiguration.current_server - LOG.debug("default server set to: %s" % self._default_server) + self._default_servers = WormConfiguration.current_server + LOG.debug("Servers set to: %s" % self._default_servers) diff --git a/monkey/monkey_island/cc/resources/local_run.py b/monkey/monkey_island/cc/resources/local_run.py index e6e8db7ab09..41f5fa417d2 100644 --- a/monkey/monkey_island/cc/resources/local_run.py +++ b/monkey/monkey_island/cc/resources/local_run.py @@ -43,29 +43,7 @@ def run_local_monkey(): # run the monkey try: - - #Retrieving the Command Servers from Monkey_Island UI - Config_Dict=ConfigService.get_config(False,True,True) - CommandServerUI_List=Config_Dict['cnc']['servers']['command_servers'] - Final_IPList=[] #The IP List of all servers that need to be communicated - - i=0 - while(i Date: Fri, 1 May 2020 16:54:20 +0530 Subject: [PATCH 07/13] Update monkey/infection_monkey/monkey.py Co-authored-by: VakarisZ <36815064+VakarisZ@users.noreply.github.com> --- monkey/infection_monkey/monkey.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index 86705d9e89b..fdfacf675f9 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -86,7 +86,7 @@ def initialize(self): self._network = NetworkScanner() self._dropper_path = sys.argv[0] - server_num=0 + server_num = 0 server_count = len(self._default_servers) if self._default_servers: From 38f912a395dd11cd4513b3dd3892679a70b6efc9 Mon Sep 17 00:00:00 2001 From: Shivank Date: Fri, 1 May 2020 16:54:42 +0530 Subject: [PATCH 08/13] Update monkey/infection_monkey/monkey.py Co-authored-by: VakarisZ <36815064+VakarisZ@users.noreply.github.com> --- monkey/infection_monkey/monkey.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index fdfacf675f9..65e0351cc29 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -96,7 +96,7 @@ def initialize(self): WormConfiguration.command_servers.insert(server_num, self._default_servers[server_num]) else: LOG.debug("Default server: %s is already in command servers list" % self._default_servers[server_num]) - server_num=server_num+1 + server_num = server_num + 1 def start(self): try: From eb04e5c7f5b6ba296f004cf666cbd9fb183b0b1b Mon Sep 17 00:00:00 2001 From: root Date: Sun, 3 May 2020 16:32:36 +0530 Subject: [PATCH 09/13] Final Patch2 --- monkey/infection_monkey/dropper.py | 10 +++++++--- monkey/infection_monkey/exploit/tools/helpers.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/monkey/infection_monkey/dropper.py b/monkey/infection_monkey/dropper.py index 03836855738..06ee54d9c9b 100644 --- a/monkey/infection_monkey/dropper.py +++ b/monkey/infection_monkey/dropper.py @@ -41,7 +41,7 @@ def __init__(self, args): arg_parser = argparse.ArgumentParser() arg_parser.add_argument('-p', '--parent') arg_parser.add_argument('-t', '--tunnel') - arg_parser.add_argument('-s', '--servers') + arg_parser.add_argument('-s', '--servers', nargs ='+') arg_parser.add_argument('-d', '--depth', type=int) arg_parser.add_argument('-l', '--location') self.monkey_args = args[1:] @@ -113,9 +113,13 @@ def start(self): (ref_stat.st_atime, ref_stat.st_mtime)) except OSError: LOG.warning("Cannot set reference date to destination file") - + + server_string =" " + for server in self.opts.servers: + server_string = server_string + " " + server #Making the server string containing multiple server + monkey_options = \ - build_monkey_commandline_explicitly(self.opts.parent, self.opts.tunnel, self.opts.server, self.opts.depth) + build_monkey_commandline_explicitly(self.opts.parent, self.opts.tunnel, server_string, self.opts.depth) if OperatingSystem.Windows == SystemInfoCollector.get_os(): monkey_cmdline = MONKEY_CMDLINE_WINDOWS % {'monkey_path': self._config['destination_path']} + monkey_options diff --git a/monkey/infection_monkey/exploit/tools/helpers.py b/monkey/infection_monkey/exploit/tools/helpers.py index aa9e61aa465..3414656e81d 100644 --- a/monkey/infection_monkey/exploit/tools/helpers.py +++ b/monkey/infection_monkey/exploit/tools/helpers.py @@ -62,7 +62,7 @@ def build_monkey_commandline_explicitly(parent=None, tunnel=None, servers=None, def build_monkey_commandline(target_host, depth, location=None): from infection_monkey.config import GUID return build_monkey_commandline_explicitly( - GUID, target_host.default_tunnel, target_host.default_server, depth, location) + GUID, target_host.default_tunnel, target_host.server_list, depth, location) def get_monkey_depth(): From 0765d3367eea3b85350f30146c2061c14035dca0 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 4 May 2020 13:57:34 +0530 Subject: [PATCH 10/13] Final Patch 3 --- monkey/infection_monkey/dropper.py | 4 +--- monkey/infection_monkey/monkey.py | 18 +++++------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/monkey/infection_monkey/dropper.py b/monkey/infection_monkey/dropper.py index 06ee54d9c9b..9351ac0c98e 100644 --- a/monkey/infection_monkey/dropper.py +++ b/monkey/infection_monkey/dropper.py @@ -114,9 +114,7 @@ def start(self): except OSError: LOG.warning("Cannot set reference date to destination file") - server_string =" " - for server in self.opts.servers: - server_string = server_string + " " + server #Making the server string containing multiple server + server_string = " ".join(self.opts.servers) #Making the server string containing multiple server monkey_options = \ build_monkey_commandline_explicitly(self.opts.parent, self.opts.tunnel, server_string, self.opts.depth) diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index 65e0351cc29..192201d130b 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -78,25 +78,17 @@ def initialize(self): self._parent = self._opts.parent self._default_tunnel = self._opts.tunnel - self._default_servers = self._opts.server + self._default_servers = self._opts.servers if self._opts.depth: WormConfiguration._depth_from_commandline = True self._keep_running = True self._network = NetworkScanner() self._dropper_path = sys.argv[0] - - server_num = 0 - server_count = len(self._default_servers) - - if self._default_servers: - while server_num < (server_count): - if self._default_servers[server_num ] not in WormConfiguration.command_servers: - LOG.debug("Added default server: %s" % self._default_servers[server_num]) - WormConfiguration.command_servers.insert(server_num, self._default_servers[server_num]) - else: - LOG.debug("Default server: %s is already in command servers list" % self._default_servers[server_num]) - server_num = server_num + 1 + + def_server_list = [ def_server for def_server in WormConfiguration.command_servers ] + WormConfiguration.command_servers = [ server for server in self._default_servers ] + WormConfiguration.command_servers = WormConfiguration.command_servers + def_server_list # Constructing the command server list def start(self): try: From 318f9e8fb7127778fdb294fbafd82892fe55844d Mon Sep 17 00:00:00 2001 From: root Date: Mon, 4 May 2020 14:07:00 +0530 Subject: [PATCH 11/13] Final Patch 4 --- monkey/infection_monkey/dropper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monkey/infection_monkey/dropper.py b/monkey/infection_monkey/dropper.py index 9351ac0c98e..6f1c0cd4e31 100644 --- a/monkey/infection_monkey/dropper.py +++ b/monkey/infection_monkey/dropper.py @@ -41,7 +41,7 @@ def __init__(self, args): arg_parser = argparse.ArgumentParser() arg_parser.add_argument('-p', '--parent') arg_parser.add_argument('-t', '--tunnel') - arg_parser.add_argument('-s', '--servers', nargs ='+') + arg_parser.add_argument('-s', '--servers', nargs = '+') arg_parser.add_argument('-d', '--depth', type=int) arg_parser.add_argument('-l', '--location') self.monkey_args = args[1:] From 14b5b6867433f6b192b22daf8caf0eb0eac276c0 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 4 May 2020 16:20:18 +0530 Subject: [PATCH 12/13] Final Patch 5 --- monkey/infection_monkey/monkey.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index 192201d130b..5b7aeeee35d 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -86,7 +86,7 @@ def initialize(self): self._network = NetworkScanner() self._dropper_path = sys.argv[0] - def_server_list = [ def_server for def_server in WormConfiguration.command_servers ] + def_server_list = WormConfiguration.command_servers WormConfiguration.command_servers = [ server for server in self._default_servers ] WormConfiguration.command_servers = WormConfiguration.command_servers + def_server_list # Constructing the command server list From 322036fddab0e4dff15a99cfcb2c43d56e46e6f0 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 5 May 2020 14:05:55 +0530 Subject: [PATCH 13/13] Final Patch 5 --- monkey/infection_monkey/monkey.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index 5b7aeeee35d..d9a7dc0c92c 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -88,7 +88,7 @@ def initialize(self): def_server_list = WormConfiguration.command_servers WormConfiguration.command_servers = [ server for server in self._default_servers ] - WormConfiguration.command_servers = WormConfiguration.command_servers + def_server_list # Constructing the command server list + WormConfiguration.command_servers = WormConfiguration.command_servers + def_server_list # Constructing the command server list def start(self): try: @@ -368,4 +368,4 @@ def set_default_server(self): if not ControlClient.find_server(default_tunnel=self._default_tunnel): raise PlannedShutdownException("Monkey couldn't find server with {} default tunnel.".format(self._default_tunnel)) self._default_servers = WormConfiguration.current_server - LOG.debug("Servers set to: %s" % self._default_servers) + LOG.debug("Default server set to: %s" % self._default_servers)