diff --git a/envs/monkey_zoo/blackbox/config_templates/powershell.py b/envs/monkey_zoo/blackbox/config_templates/powershell.py index fddfd32ae..96ba0b908 100644 --- a/envs/monkey_zoo/blackbox/config_templates/powershell.py +++ b/envs/monkey_zoo/blackbox/config_templates/powershell.py @@ -7,6 +7,8 @@ from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemp class PowerShell(ConfigTemplate): config_values = copy(BaseTemplate.config_values) + # TODO: Remove .\\ from exploit user list when DC name is added, + # for more context see https://github.com/guardicore/monkey/issues/1486 config_values.update( { "basic.exploiters.exploiter_classes": ["PowerShellExploiter"], @@ -17,7 +19,7 @@ class PowerShell(ConfigTemplate): "10.2.3.48", ], "basic.credentials.exploit_password_list": ["Passw0rd!"], - "basic_network.scope.depth": 2, # TODO: Remove .\\ when DC name is added + "basic_network.scope.depth": 2, "basic.credentials.exploit_user_list": ["m0nk3y", "m0nk3y-user", ".\\m0nk3y"], "internal.classes.finger_classes": ["PingScanner"], "internal.network.tcp_scanner.HTTP_PORTS": [], @@ -27,20 +29,3 @@ class PowerShell(ConfigTemplate): ], } ) - - -class PowerShell_Cached(ConfigTemplate): - config_values = copy(BaseTemplate.config_values) - - config_values.update( - { - "basic.exploiters.exploiter_classes": ["PowerShellExploiter"], - "basic_network.scope.subnet_scan_list": [ - "10.2.3.46", - ], - "basic_network.scope.depth": 2, - "internal.classes.finger_classes": ["PingScanner"], - "internal.network.tcp_scanner.HTTP_PORTS": [], - "internal.network.tcp_scanner.tcp_target_ports": [], - } - ) diff --git a/envs/monkey_zoo/blackbox/config_templates/powershell_cached_credentials.py b/envs/monkey_zoo/blackbox/config_templates/powershell_cached_credentials.py new file mode 100644 index 000000000..c8a40f94b --- /dev/null +++ b/envs/monkey_zoo/blackbox/config_templates/powershell_cached_credentials.py @@ -0,0 +1,21 @@ +from copy import copy + +from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate + + +class PowerShellCachedCredentials(ConfigTemplate): + config_values = copy(BaseTemplate.config_values) + + config_values.update( + { + "basic.exploiters.exploiter_classes": ["PowerShellExploiter"], + "basic_network.scope.subnet_scan_list": [ + "10.2.3.46", + ], + "basic_network.scope.depth": 2, + "internal.classes.finger_classes": ["PingScanner"], + "internal.network.tcp_scanner.HTTP_PORTS": [], + "internal.network.tcp_scanner.tcp_target_ports": [], + } + ) diff --git a/envs/monkey_zoo/blackbox/conftest.py b/envs/monkey_zoo/blackbox/conftest.py index cfaa1f604..946e9c036 100644 --- a/envs/monkey_zoo/blackbox/conftest.py +++ b/envs/monkey_zoo/blackbox/conftest.py @@ -58,17 +58,17 @@ def pytest_runtest_setup(item): "Skipping performance test because " "--run-performance-tests flag isn't specified." ) - if item.config.getoption("--os"): - os = [mark.args[0] for mark in item.iter_markers(name="os")] - if os: - if item.config.getoption("--os") not in os: - pytest.skip( - f"Skipping OS specific test. Run in {os[0]} if " - f"you want this test to be executed." - ) - else: + if not item.config.getoption("--os"): pytest.skip( "Skipping OS specific test because" "--os flag isn't specified." " Specify --os with windows or linux as options." ) + + os = [mark.args[0] for mark in item.iter_markers(name="os")] + + if os and item.config.getoption("--os") not in os: + pytest.skip( + f'Skipping OS specific test. Run with "--os={os[0]}" if ' + f"you want this test to be executed." + ) diff --git a/envs/monkey_zoo/blackbox/test_blackbox.py b/envs/monkey_zoo/blackbox/test_blackbox.py index 8616d77b5..153f995b9 100644 --- a/envs/monkey_zoo/blackbox/test_blackbox.py +++ b/envs/monkey_zoo/blackbox/test_blackbox.py @@ -13,7 +13,10 @@ from envs.monkey_zoo.blackbox.config_templates.elastic import Elastic from envs.monkey_zoo.blackbox.config_templates.hadoop import Hadoop from envs.monkey_zoo.blackbox.config_templates.mssql import Mssql from envs.monkey_zoo.blackbox.config_templates.performance import Performance -from envs.monkey_zoo.blackbox.config_templates.powershell import PowerShell, PowerShell_Cached +from envs.monkey_zoo.blackbox.config_templates.powershell import PowerShell +from envs.monkey_zoo.blackbox.config_templates.powershell_cached_credentials import ( + PowerShellCachedCredentials, +) from envs.monkey_zoo.blackbox.config_templates.shellshock import ShellShock from envs.monkey_zoo.blackbox.config_templates.smb_mimikatz import SmbMimikatz from envs.monkey_zoo.blackbox.config_templates.smb_pth import SmbPth @@ -53,7 +56,6 @@ LOG_DIR_PATH = "./logs" logging.basicConfig(level=logging.INFO) LOGGER = logging.getLogger(__name__) WINDOWS = "windows" -LINUX = "linux" @pytest.fixture(autouse=True, scope="session") @@ -171,7 +173,9 @@ class TestMonkeyBlackbox: @pytest.mark.os(WINDOWS) def test_powershell_exploiter_cached_credentials(self, island_client): TestMonkeyBlackbox.run_exploitation_test( - island_client, PowerShell_Cached, "PowerShell_Remoting_exploiter_cached_credentials" + island_client, + PowerShellCachedCredentials, + "PowerShell_Remoting_exploiter_cached_credentials", ) def test_smb_and_mimikatz_exploiters(self, island_client): diff --git a/vulture_allowlist.py b/vulture_allowlist.py index 5680cf5b6..905cc74ad 100644 --- a/vulture_allowlist.py +++ b/vulture_allowlist.py @@ -205,6 +205,4 @@ environment # unused variable (monkey/monkey_island/cc/models/monkey.py:59) _.environment # unused attribute (monkey/monkey_island/cc/services/telemetry/processing/system_info_collectors/environment.py:10) _.instance_name # unused attribute (monkey/common/cloud/azure/azure_instance.py:35) _.instance_name # unused attribute (monkey/common/cloud/azure/azure_instance.py:64) -# TODO: Remove this when adding LINUX specific bb test -LINUX # unused variable (envs/monkey_zoo/blackbox/test_blackbox.py:56) GCPHandler # unused function (envs/monkey_zoo/blackbox/test_blackbox.py:57)