forked from p15670423/monkey
Zoo: Replace --os with --skip-powershell-reuse
With this logic the powershell cached will run if we don't provide the cli param --skip-powershell-reuse.
This commit is contained in:
parent
07c08ac0b6
commit
a438f3afb0
|
@ -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(
|
|
@ -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."
|
||||
)
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue