Add name consistency for get_monkey_commandline

This commit is contained in:
Ilija Lazoroski 2021-06-18 11:53:04 +02:00 committed by Ilija Lazoroski
parent d76e69fffe
commit b93be212f4
4 changed files with 18 additions and 18 deletions

View File

@ -16,8 +16,8 @@ from infection_monkey.system_info import OperatingSystem, SystemInfoCollector
from infection_monkey.telemetry.attack.t1106_telem import T1106Telem from infection_monkey.telemetry.attack.t1106_telem import T1106Telem
from infection_monkey.utils.commands import ( from infection_monkey.utils.commands import (
build_monkey_commandline_explicitly, build_monkey_commandline_explicitly,
get_monkey_cmd_lines_linux, get_monkey_commandline_linux,
get_monkey_cmd_lines_windows, get_monkey_commandline_windows,
) )
if "win32" == sys.platform: if "win32" == sys.platform:
@ -146,12 +146,12 @@ class MonkeyDrops(object):
if OperatingSystem.Windows == SystemInfoCollector.get_os(): 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 self._config["destination_path"], monkey_options
) )
monkey_process = subprocess.Popen( monkey_process = subprocess.Popen(
monkey_cmdline, monkey_commandline,
stdin=subprocess.PIPE, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, stderr=subprocess.PIPE,
@ -163,12 +163,12 @@ class MonkeyDrops(object):
# In Linux, we need to change the directory first, which is done # In Linux, we need to change the directory first, which is done
# using thw `cwd` argument in `subprocess.Popen` below # 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_process = subprocess.Popen(
monkey_cmdline, monkey_commandline,
stdin=subprocess.PIPE, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, stderr=subprocess.PIPE,
@ -180,7 +180,7 @@ class MonkeyDrops(object):
LOG.info( LOG.info(
"Executed monkey process (PID=%d) with command line: %s", "Executed monkey process (PID=%d) with command line: %s",
monkey_process.pid, monkey_process.pid,
" ".join(monkey_cmdline), " ".join(monkey_commandline),
) )
time.sleep(3) time.sleep(3)

View File

@ -49,13 +49,13 @@ def build_monkey_commandline_explicitly(
return cmdline 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] monkey_cmdline = [CMD_EXE, CMD_CARRY_OUT, destination_path, MONKEY_ARG]
return monkey_cmdline + monkey_options 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] monkey_cmdline = [destination_path.split("/")[-1], MONKEY_ARG]
return monkey_cmdline + monkey_options return monkey_cmdline + monkey_options

View File

@ -9,7 +9,7 @@ from infection_monkey.config import WormConfiguration
from infection_monkey.control import ControlClient from infection_monkey.control import ControlClient
from infection_monkey.utils.commands import ( from infection_monkey.utils.commands import (
build_monkey_commandline_explicitly, 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 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 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 WormConfiguration.dropper_target_path_win_64, monkey_options
) )

View File

@ -1,7 +1,7 @@
from infection_monkey.utils.commands import ( from infection_monkey.utils.commands import (
build_monkey_commandline_explicitly, build_monkey_commandline_explicitly,
get_monkey_cmd_lines_linux, get_monkey_commandline_linux,
get_monkey_cmd_lines_windows, get_monkey_commandline_windows,
) )
@ -65,7 +65,7 @@ def test_build_monkey_commandline_explicitly():
assert test3 == result3 assert test3 == result3
def test_get_monkey_cmd_lines_windows(): def test_get_monkey_commandline_windows():
test1 = [ test1 = [
"cmd.exe", "cmd.exe",
"/c", "/c",
@ -76,7 +76,7 @@ def test_get_monkey_cmd_lines_windows():
"-t", "-t",
"10.10.101.10", "10.10.101.10",
] ]
result1 = get_monkey_cmd_lines_windows( result1 = get_monkey_commandline_windows(
"C:\\windows\\abc", "C:\\windows\\abc",
[ [
"-p", "-p",
@ -89,7 +89,7 @@ def test_get_monkey_cmd_lines_windows():
assert test1 == result1 assert test1 == result1
def test_get_monkey_cmd_lines_linux(): def test_get_monkey_commandline_linux():
test1 = [ test1 = [
"monkey-linux-64", "monkey-linux-64",
"m0nk3y", "m0nk3y",
@ -98,7 +98,7 @@ def test_get_monkey_cmd_lines_linux():
"-t", "-t",
"10.10.101.10", "10.10.101.10",
] ]
result1 = get_monkey_cmd_lines_linux( result1 = get_monkey_commandline_linux(
"/home/user/monkey-linux-64", "/home/user/monkey-linux-64",
[ [
"-p", "-p",