diff --git a/envs/monkey_zoo/blackbox/config_templates/powershell_cached_credentials.py b/envs/monkey_zoo/blackbox/config_templates/powershell_credentials_reuse.py similarity index 93% rename from envs/monkey_zoo/blackbox/config_templates/powershell_cached_credentials.py rename to envs/monkey_zoo/blackbox/config_templates/powershell_credentials_reuse.py index c8a40f94b..d6113dc15 100644 --- a/envs/monkey_zoo/blackbox/config_templates/powershell_cached_credentials.py +++ b/envs/monkey_zoo/blackbox/config_templates/powershell_credentials_reuse.py @@ -4,7 +4,7 @@ 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): +class PowerShellCredentialsReuse(ConfigTemplate): config_values = copy(BaseTemplate.config_values) config_values.update( diff --git a/envs/monkey_zoo/blackbox/conftest.py b/envs/monkey_zoo/blackbox/conftest.py index 946e9c036..82c6d3d9a 100644 --- a/envs/monkey_zoo/blackbox/conftest.py +++ b/envs/monkey_zoo/blackbox/conftest.py @@ -28,10 +28,10 @@ def pytest_addoption(parser): help="If enabled performance tests will be run.", ) parser.addoption( - "--os", - action="store", - default=None, - help="Use to run Windows or Linux specific tests.", + "--skip-powershell-reuse", + action="store_true", + default=False, + help="Use to run PowerShell credentials reuse test.", ) @@ -58,17 +58,10 @@ def pytest_runtest_setup(item): "Skipping performance test because " "--run-performance-tests flag isn't specified." ) - if not item.config.getoption("--os"): + if "skip_powershell_reuse" in item.keywords and item.config.getoption( + "--skip-powershell-reuse" + ): 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." + "Skipping powershell credentials reuse test because " + "--skip-powershell-cached flag isn't specified." ) diff --git a/envs/monkey_zoo/blackbox/test_blackbox.py b/envs/monkey_zoo/blackbox/test_blackbox.py index 153f995b9..cc4d6ba97 100644 --- a/envs/monkey_zoo/blackbox/test_blackbox.py +++ b/envs/monkey_zoo/blackbox/test_blackbox.py @@ -14,8 +14,8 @@ 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 -from envs.monkey_zoo.blackbox.config_templates.powershell_cached_credentials import ( - PowerShellCachedCredentials, +from envs.monkey_zoo.blackbox.config_templates.powershell_credentials_reuse import ( + PowerShellCredentialsReuse, ) from envs.monkey_zoo.blackbox.config_templates.shellshock import ShellShock from envs.monkey_zoo.blackbox.config_templates.smb_mimikatz import SmbMimikatz @@ -55,7 +55,6 @@ MACHINE_BOOTUP_WAIT_SECONDS = 30 LOG_DIR_PATH = "./logs" logging.basicConfig(level=logging.INFO) LOGGER = logging.getLogger(__name__) -WINDOWS = "windows" @pytest.fixture(autouse=True, scope="session") @@ -170,12 +169,12 @@ class TestMonkeyBlackbox: island_client, PowerShell, "PowerShell_Remoting_exploiter" ) - @pytest.mark.os(WINDOWS) - def test_powershell_exploiter_cached_credentials(self, island_client): + @pytest.mark.skip_powershell_reuse + def test_powershell_exploiter_credentials_reuse(self, island_client): TestMonkeyBlackbox.run_exploitation_test( island_client, - PowerShellCachedCredentials, - "PowerShell_Remoting_exploiter_cached_credentials", + PowerShellCredentialsReuse, + "PowerShell_Remoting_exploiter_credentials_reuse", ) def test_smb_and_mimikatz_exploiters(self, island_client):