BB: Use `replace_agent_configuration()` and `replace_propagation_credentials()` for all test configuration modifications

This commit is contained in:
Shreya Malviya 2022-09-01 17:09:53 +05:30
parent 2352bb0d5e
commit 6cf62d48cb
8 changed files with 82 additions and 16 deletions

View File

@ -9,6 +9,8 @@ from .utils import (
add_http_ports,
add_subnets,
add_tcp_ports,
replace_agent_configuration,
replace_propagation_credentials,
set_maximum_depth,
)
@ -89,5 +91,9 @@ CREDENTIALS = (
)
depth_1_a_test_configuration = noop_test_configuration.copy()
depth_1_a_test_configuration.agent_configuration = test_agent_configuration
depth_1_a_test_configuration.propagation_credentials = CREDENTIALS
replace_agent_configuration(
test_configuration=depth_1_a_test_configuration, agent_configuration=test_agent_configuration
)
replace_propagation_credentials(
test_configuration=depth_1_a_test_configuration, propagation_credentials=CREDENTIALS
)

View File

@ -2,7 +2,14 @@ from common.agent_configuration import AgentConfiguration, PluginConfiguration
from common.credentials import Credentials, Password, Username
from .noop import noop_test_configuration
from .utils import add_exploiters, add_subnets, add_tcp_ports, set_maximum_depth
from .utils import (
add_exploiters,
add_subnets,
add_tcp_ports,
replace_agent_configuration,
replace_propagation_credentials,
set_maximum_depth,
)
# Tests:
@ -38,5 +45,9 @@ CREDENTIALS = (
)
depth_2_a_test_configuration = noop_test_configuration.copy()
depth_2_a_test_configuration.agent_configuration = test_agent_configuration
depth_2_a_test_configuration.propagation_credentials = CREDENTIALS
replace_agent_configuration(
test_configuration=depth_2_a_test_configuration, agent_configuration=test_agent_configuration
)
replace_propagation_credentials(
test_configuration=depth_2_a_test_configuration, propagation_credentials=CREDENTIALS
)

View File

@ -6,6 +6,8 @@ from .utils import (
add_exploiters,
add_subnets,
add_tcp_ports,
replace_agent_configuration,
replace_propagation_credentials,
set_keep_tunnel_open_time,
set_maximum_depth,
)
@ -65,5 +67,9 @@ CREDENTIALS = (
)
depth_3_a_test_configuration = noop_test_configuration.copy()
depth_3_a_test_configuration.agent_configuration = test_agent_configuration
depth_3_a_test_configuration.propagation_credentials = CREDENTIALS
replace_agent_configuration(
test_configuration=depth_3_a_test_configuration, agent_configuration=test_agent_configuration
)
replace_propagation_credentials(
test_configuration=depth_3_a_test_configuration, propagation_credentials=CREDENTIALS
)

View File

@ -1,7 +1,13 @@
from common.agent_configuration import AgentConfiguration, PluginConfiguration
from .noop import noop_test_configuration
from .utils import add_exploiters, add_subnets, add_tcp_ports, set_maximum_depth
from .utils import (
add_exploiters,
add_subnets,
add_tcp_ports,
replace_agent_configuration,
set_maximum_depth,
)
def _add_exploiters(agent_configuration: AgentConfiguration) -> AgentConfiguration:
@ -30,4 +36,7 @@ test_agent_configuration = _add_subnets(test_agent_configuration)
test_agent_configuration = _add_tcp_ports(test_agent_configuration)
powershell_credentials_reuse_test_configuration = noop_test_configuration.copy()
powershell_credentials_reuse_test_configuration.agent_configuration = test_agent_configuration
replace_agent_configuration(
test_configuration=powershell_credentials_reuse_test_configuration,
agent_configuration=test_agent_configuration,
)

View File

@ -6,6 +6,8 @@ from .utils import (
add_exploiters,
add_subnets,
add_tcp_ports,
replace_agent_configuration,
replace_propagation_credentials,
set_keep_tunnel_open_time,
set_maximum_depth,
)
@ -49,5 +51,9 @@ CREDENTIALS = (
)
smb_pth_test_configuration = noop_test_configuration.copy()
smb_pth_test_configuration.agent_configuration = test_agent_configuration
smb_pth_test_configuration.propagation_credentials = CREDENTIALS
replace_agent_configuration(
test_configuration=smb_pth_test_configuration, agent_configuration=test_agent_configuration
)
replace_propagation_credentials(
test_configuration=smb_pth_test_configuration, propagation_credentials=CREDENTIALS
)

View File

@ -1,6 +1,8 @@
from typing import Sequence
from typing import Sequence, Tuple
from common.agent_configuration import AgentConfiguration, PluginConfiguration
from common.credentials import Credentials
from envs.monkey_zoo.blackbox.test_configurations.test_configuration import TestConfiguration
def add_exploiters(
@ -84,3 +86,15 @@ def set_maximum_depth(
agent_configuration_copy.propagation.maximum_depth = maximum_depth
return agent_configuration_copy
def replace_agent_configuration(
test_configuration: TestConfiguration, agent_configuration: AgentConfiguration
):
test_configuration.agent_configuration = agent_configuration
def replace_propagation_credentials(
test_configuration: TestConfiguration, propagation_credentials: Tuple[Credentials, ...]
):
test_configuration.propagation_credentials = propagation_credentials

View File

@ -7,6 +7,8 @@ from .utils import (
add_exploiters,
add_subnets,
add_tcp_ports,
replace_agent_configuration,
replace_propagation_credentials,
set_maximum_depth,
)
@ -54,5 +56,9 @@ CREDENTIALS = (
)
wmi_mimikatz_test_configuration = noop_test_configuration.copy()
wmi_mimikatz_test_configuration.agent_configuration = test_agent_configuration
wmi_mimikatz_test_configuration.propagation_credentials = CREDENTIALS
replace_agent_configuration(
test_configuration=wmi_mimikatz_test_configuration, agent_configuration=test_agent_configuration
)
replace_propagation_credentials(
test_configuration=wmi_mimikatz_test_configuration, propagation_credentials=CREDENTIALS
)

View File

@ -1,7 +1,13 @@
from common.agent_configuration import AgentConfiguration, PluginConfiguration
from .noop import noop_test_configuration
from .utils import add_exploiters, add_subnets, add_tcp_ports, set_maximum_depth
from .utils import (
add_exploiters,
add_subnets,
add_tcp_ports,
replace_agent_configuration,
set_maximum_depth,
)
def _add_exploiters(agent_configuration: AgentConfiguration) -> AgentConfiguration:
@ -27,4 +33,6 @@ test_agent_configuration = _add_tcp_ports(test_agent_configuration)
test_agent_configuration = _add_subnets(test_agent_configuration)
zerologon_test_configuration = noop_test_configuration.copy()
zerologon_test_configuration.agent_configuration = test_agent_configuration
replace_agent_configuration(
test_configuration=zerologon_test_configuration, agent_configuration=test_agent_configuration
)