diff --git a/monkey/infection_monkey/dropper.py b/monkey/infection_monkey/dropper.py index a9b753357..9df8f6a82 100644 --- a/monkey/infection_monkey/dropper.py +++ b/monkey/infection_monkey/dropper.py @@ -16,8 +16,8 @@ from infection_monkey.system_info import OperatingSystem, SystemInfoCollector from infection_monkey.telemetry.attack.t1106_telem import T1106Telem from infection_monkey.utils.commands import ( build_monkey_commandline_explicitly, - get_monkey_cmd_lines_linux, - get_monkey_cmd_lines_windows, + get_monkey_commandline_linux, + get_monkey_commandline_windows, ) if "win32" == sys.platform: @@ -146,12 +146,12 @@ class MonkeyDrops(object): if OperatingSystem.Windows == SystemInfoCollector.get_os(): - monkey_cmdline = get_monkey_cmd_lines_windows( + monkey_commandline = get_monkey_commandline_windows( self._config["destination_path"], monkey_options ) monkey_process = subprocess.Popen( - monkey_cmdline, + monkey_commandline, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, @@ -163,12 +163,12 @@ class MonkeyDrops(object): # In Linux, we need to change the directory first, which is done # using thw `cwd` argument in `subprocess.Popen` below - monkey_cmdline = get_monkey_cmd_lines_linux(dest_path, monkey_options) + monkey_commandline = get_monkey_commandline_linux(dest_path, monkey_options) - LOG.info("Commands of monkey cmdline_split %s", monkey_cmdline) + LOG.info("Commands of monkey cmdline_split %s", monkey_commandline) monkey_process = subprocess.Popen( - monkey_cmdline, + monkey_commandline, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, @@ -180,7 +180,7 @@ class MonkeyDrops(object): LOG.info( "Executed monkey process (PID=%d) with command line: %s", monkey_process.pid, - " ".join(monkey_cmdline), + " ".join(monkey_commandline), ) time.sleep(3) diff --git a/monkey/infection_monkey/utils/commands.py b/monkey/infection_monkey/utils/commands.py index 8d3229965..32d423fa6 100644 --- a/monkey/infection_monkey/utils/commands.py +++ b/monkey/infection_monkey/utils/commands.py @@ -49,13 +49,13 @@ def build_monkey_commandline_explicitly( return cmdline -def get_monkey_cmd_lines_windows(destination_path, monkey_options): +def get_monkey_commandline_windows(destination_path, monkey_options): monkey_cmdline = [CMD_EXE, CMD_CARRY_OUT, destination_path, MONKEY_ARG] return monkey_cmdline + monkey_options -def get_monkey_cmd_lines_linux(destination_path, monkey_options): +def get_monkey_commandline_linux(destination_path, monkey_options): monkey_cmdline = [destination_path.split("/")[-1], MONKEY_ARG] return monkey_cmdline + monkey_options diff --git a/monkey/infection_monkey/windows_upgrader.py b/monkey/infection_monkey/windows_upgrader.py index 09936fc5b..b3745bf48 100644 --- a/monkey/infection_monkey/windows_upgrader.py +++ b/monkey/infection_monkey/windows_upgrader.py @@ -9,7 +9,7 @@ from infection_monkey.config import WormConfiguration from infection_monkey.control import ControlClient from infection_monkey.utils.commands import ( build_monkey_commandline_explicitly, - get_monkey_cmd_lines_windows, + get_monkey_commandline_windows, ) from infection_monkey.utils.environment import is_64bit_python, is_64bit_windows_os, is_windows_os @@ -47,7 +47,7 @@ class WindowsUpgrader(object): opts.parent, opts.tunnel, opts.server, opts.depth ) - monkey_cmdline = get_monkey_cmd_lines_windows( + monkey_cmdline = get_monkey_commandline_windows( WormConfiguration.dropper_target_path_win_64, monkey_options ) diff --git a/monkey/tests/unit_tests/infection_monkey/utils/test_commands.py b/monkey/tests/unit_tests/infection_monkey/utils/test_commands.py index 511adeb4b..00b62dd6b 100644 --- a/monkey/tests/unit_tests/infection_monkey/utils/test_commands.py +++ b/monkey/tests/unit_tests/infection_monkey/utils/test_commands.py @@ -1,7 +1,7 @@ from infection_monkey.utils.commands import ( build_monkey_commandline_explicitly, - get_monkey_cmd_lines_linux, - get_monkey_cmd_lines_windows, + get_monkey_commandline_linux, + get_monkey_commandline_windows, ) @@ -65,7 +65,7 @@ def test_build_monkey_commandline_explicitly(): assert test3 == result3 -def test_get_monkey_cmd_lines_windows(): +def test_get_monkey_commandline_windows(): test1 = [ "cmd.exe", "/c", @@ -76,7 +76,7 @@ def test_get_monkey_cmd_lines_windows(): "-t", "10.10.101.10", ] - result1 = get_monkey_cmd_lines_windows( + result1 = get_monkey_commandline_windows( "C:\\windows\\abc", [ "-p", @@ -89,7 +89,7 @@ def test_get_monkey_cmd_lines_windows(): assert test1 == result1 -def test_get_monkey_cmd_lines_linux(): +def test_get_monkey_commandline_linux(): test1 = [ "monkey-linux-64", "m0nk3y", @@ -98,7 +98,7 @@ def test_get_monkey_cmd_lines_linux(): "-t", "10.10.101.10", ] - result1 = get_monkey_cmd_lines_linux( + result1 = get_monkey_commandline_linux( "/home/user/monkey-linux-64", [ "-p",