diff --git a/envs/monkey_zoo/blackbox/config_templates/powershell.py b/envs/monkey_zoo/blackbox/config_templates/powershell.py index ff377a14f..fddfd32ae 100644 --- a/envs/monkey_zoo/blackbox/config_templates/powershell.py +++ b/envs/monkey_zoo/blackbox/config_templates/powershell.py @@ -27,3 +27,20 @@ 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/conftest.py b/envs/monkey_zoo/blackbox/conftest.py index cc608fae8..cfaa1f604 100644 --- a/envs/monkey_zoo/blackbox/conftest.py +++ b/envs/monkey_zoo/blackbox/conftest.py @@ -27,6 +27,12 @@ def pytest_addoption(parser): default=False, help="If enabled performance tests will be run.", ) + parser.addoption( + "--os", + action="store", + default=None, + help="Use to run Windows or Linux specific tests.", + ) @pytest.fixture(scope="session") @@ -51,3 +57,18 @@ def pytest_runtest_setup(item): pytest.skip( "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: + pytest.skip( + "Skipping OS specific test because" + "--os flag isn't specified." + " Specify --os with windows or linux as options." + ) diff --git a/envs/monkey_zoo/blackbox/test_blackbox.py b/envs/monkey_zoo/blackbox/test_blackbox.py index 221d783f6..8616d77b5 100644 --- a/envs/monkey_zoo/blackbox/test_blackbox.py +++ b/envs/monkey_zoo/blackbox/test_blackbox.py @@ -13,7 +13,7 @@ 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 +from envs.monkey_zoo.blackbox.config_templates.powershell import PowerShell, PowerShell_Cached 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 @@ -52,6 +52,8 @@ MACHINE_BOOTUP_WAIT_SECONDS = 30 LOG_DIR_PATH = "./logs" logging.basicConfig(level=logging.INFO) LOGGER = logging.getLogger(__name__) +WINDOWS = "windows" +LINUX = "linux" @pytest.fixture(autouse=True, scope="session") @@ -166,6 +168,12 @@ class TestMonkeyBlackbox: island_client, PowerShell, "PowerShell_Remoting_exploiter" ) + @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" + ) + def test_smb_and_mimikatz_exploiters(self, island_client): TestMonkeyBlackbox.run_exploitation_test( island_client, SmbMimikatz, "SMB_exploiter_mimikatz" diff --git a/vulture_allowlist.py b/vulture_allowlist.py index 905cc74ad..5680cf5b6 100644 --- a/vulture_allowlist.py +++ b/vulture_allowlist.py @@ -205,4 +205,6 @@ 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)