From 39a208afc3b7b2a65629ffc15b875c0b5a9526b7 Mon Sep 17 00:00:00 2001 From: acepace Date: Sun, 31 Jul 2016 14:33:48 +0300 Subject: [PATCH] Added local kill switch to flow, right after loading configuration. --- chaos_monkey/config.py | 4 ++-- chaos_monkey/example.conf | 5 ++--- chaos_monkey/main.py | 6 ++++++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/chaos_monkey/config.py b/chaos_monkey/config.py index 897488794..76ed1480b 100644 --- a/chaos_monkey/config.py +++ b/chaos_monkey/config.py @@ -106,8 +106,8 @@ class Configuration(object): ########################### # Kill file ########################### - kill_file_path_windows = os.path.expandvars("%temp%\~df4150.tmp") - kill_file_path_linux = '/tmp/user-4150' + kill_file_path_windows = os.path.expandvars("%windir%\monkey.not") + kill_file_path_linux = '/var/run/monkey.not' ########################### # monkey config diff --git a/chaos_monkey/example.conf b/chaos_monkey/example.conf index 999126901..14fb05ee0 100644 --- a/chaos_monkey/example.conf +++ b/chaos_monkey/example.conf @@ -36,9 +36,8 @@ "dropper_set_date": true, "dropper_target_path": "C:\\Windows\\monkey.exe", "dropper_target_path_linux": "/bin/monkey", - - "kill_path_linux": "/tmp/user-4150", - "kill_path_windows": "%temp%\\~df4150.tmp", + "kill_path_linux": "/var/run/monkey.not", + "kill_path_windows": "%windir%\monkey.not", "dropper_try_move_first": false, "exploiter_classes": [ "SSHExploiter", diff --git a/chaos_monkey/main.py b/chaos_monkey/main.py index ee360ac34..6689ad3e7 100644 --- a/chaos_monkey/main.py +++ b/chaos_monkey/main.py @@ -66,6 +66,12 @@ def main(): print "Loaded Configuration: %r" % WormConfiguration.as_dict() + #Make sure we're not in a machine that has the kill file + kill_path = WormConfiguration.kill_file_path_windows if sys.platform == "win32" else WormConfiguration.kill_file_path_linux + if os.path.exists(kill_path): + print "Kill path found, finished run" + return True + try: if MONKEY_ARG == monkey_mode: log_path = os.path.expandvars(WormConfiguration.monkey_log_path_windows) if sys.platform == "win32" else WormConfiguration.monkey_log_path_linux