#3062 - First pass at unifying naming convention for discriminators (still errors) [skip ci]
This commit is contained in:
@@ -99,15 +99,15 @@ def basic_network() -> Network:
|
||||
def setup_c2(given_network: Network):
|
||||
"""Installs the C2 Beacon & Server, configures and then returns."""
|
||||
computer_a: Computer = given_network.get_node_by_hostname("node_a")
|
||||
c2_server: C2Server = computer_a.software_manager.software.get("C2Server")
|
||||
c2_server: C2Server = computer_a.software_manager.software.get("c2-server")
|
||||
computer_a.software_manager.install(DatabaseService)
|
||||
computer_a.software_manager.software["DatabaseService"].start()
|
||||
computer_a.software_manager.software["database-service"].start()
|
||||
|
||||
computer_b: Computer = given_network.get_node_by_hostname("node_b")
|
||||
c2_beacon: C2Beacon = computer_b.software_manager.software.get("C2Beacon")
|
||||
c2_beacon: C2Beacon = computer_b.software_manager.software.get("c2-beacon")
|
||||
computer_b.software_manager.install(DatabaseClient)
|
||||
computer_b.software_manager.software["DatabaseClient"].configure(server_ip_address=IPv4Address("192.168.0.2"))
|
||||
computer_b.software_manager.software["DatabaseClient"].run()
|
||||
computer_b.software_manager.software["database-client"].configure(server_ip_address=IPv4Address("192.168.0.2"))
|
||||
computer_b.software_manager.software["database-client"].run()
|
||||
|
||||
c2_beacon.configure(c2_server_ip_address="192.168.0.2", keep_alive_frequency=2)
|
||||
c2_server.run()
|
||||
@@ -177,9 +177,9 @@ def test_c2_suite_configure_request(basic_network):
|
||||
"masquerade_port": 80,
|
||||
}
|
||||
|
||||
network.apply_request(["node", "node_b", "application", "C2Beacon", "configure", c2_beacon_config])
|
||||
network.apply_request(["node", "node_b", "application", "c2-beacon", "configure", c2_beacon_config])
|
||||
network.apply_timestep(0)
|
||||
network.apply_request(["node", "node_b", "application", "C2Beacon", "execute"])
|
||||
network.apply_request(["node", "node_b", "application", "c2-beacon", "execute"])
|
||||
|
||||
assert c2_beacon.c2_connection_active is True
|
||||
assert c2_server.c2_connection_active is True
|
||||
@@ -195,13 +195,13 @@ def test_c2_suite_ransomware_commands(basic_network):
|
||||
# Testing Via Requests:
|
||||
computer_b.software_manager.install(software_class=RansomwareScript)
|
||||
ransomware_config = {"server_ip_address": "192.168.0.2"}
|
||||
network.apply_request(["node", "node_a", "application", "C2Server", "ransomware_configure", ransomware_config])
|
||||
network.apply_request(["node", "node_a", "application", "c2-server", "ransomware_configure", ransomware_config])
|
||||
|
||||
ransomware_script: RansomwareScript = computer_b.software_manager.software["RansomwareScript"]
|
||||
ransomware_script: RansomwareScript = computer_b.software_manager.software["ransomware-script"]
|
||||
|
||||
assert ransomware_script.server_ip_address == "192.168.0.2"
|
||||
|
||||
network.apply_request(["node", "node_a", "application", "C2Server", "ransomware_launch"])
|
||||
network.apply_request(["node", "node_a", "application", "c2-server", "ransomware_launch"])
|
||||
|
||||
database_file = computer_a.software_manager.file_system.get_file("database", "database.db")
|
||||
|
||||
@@ -491,10 +491,10 @@ def test_c2_suite_yaml():
|
||||
|
||||
yaml_network = game.simulation.network
|
||||
computer_a: Computer = yaml_network.get_node_by_hostname("node_a")
|
||||
c2_server: C2Server = computer_a.software_manager.software.get("C2Server")
|
||||
c2_server: C2Server = computer_a.software_manager.software.get("c2-server")
|
||||
|
||||
computer_b: Computer = yaml_network.get_node_by_hostname("node_b")
|
||||
c2_beacon: C2Beacon = computer_b.software_manager.software.get("C2Beacon")
|
||||
c2_beacon: C2Beacon = computer_b.software_manager.software.get("c2-beacon")
|
||||
c2_beacon.configure(
|
||||
c2_server_ip_address=c2_beacon.config.c2_server_ip_address,
|
||||
keep_alive_frequency=c2_beacon.config.keep_alive_frequency,
|
||||
|
||||
@@ -27,20 +27,20 @@ def data_manipulation_bot_and_db_server(client_server) -> Tuple[DataManipulation
|
||||
|
||||
# install db client on computer
|
||||
computer.software_manager.install(DatabaseClient)
|
||||
db_client: DatabaseClient = computer.software_manager.software.get("DatabaseClient")
|
||||
db_client: DatabaseClient = computer.software_manager.software.get("database-client")
|
||||
db_client.run()
|
||||
|
||||
# Install DoSBot on computer
|
||||
computer.software_manager.install(DataManipulationBot)
|
||||
|
||||
data_manipulation_bot: DataManipulationBot = computer.software_manager.software.get("DataManipulationBot")
|
||||
data_manipulation_bot: DataManipulationBot = computer.software_manager.software.get("data-manipulation-bot")
|
||||
data_manipulation_bot.configure(
|
||||
server_ip_address=IPv4Address(server.network_interface[1].ip_address), payload="DELETE"
|
||||
)
|
||||
|
||||
# Install DB Server service on server
|
||||
server.software_manager.install(DatabaseService)
|
||||
db_server_service: DatabaseService = server.software_manager.software.get("DatabaseService")
|
||||
db_server_service: DatabaseService = server.software_manager.software.get("database-service")
|
||||
db_server_service.start()
|
||||
|
||||
return data_manipulation_bot, computer, db_server_service, server
|
||||
@@ -64,26 +64,26 @@ def data_manipulation_db_server_green_client(example_network) -> Network:
|
||||
|
||||
# install db client on client 1
|
||||
client_1.software_manager.install(DatabaseClient)
|
||||
db_client: DatabaseClient = client_1.software_manager.software.get("DatabaseClient")
|
||||
db_client: DatabaseClient = client_1.software_manager.software.get("database-client")
|
||||
db_client.run()
|
||||
|
||||
# install Data Manipulation bot on client 1
|
||||
client_1.software_manager.install(DataManipulationBot)
|
||||
|
||||
data_manipulation_bot: DataManipulationBot = client_1.software_manager.software.get("DataManipulationBot")
|
||||
data_manipulation_bot: DataManipulationBot = client_1.software_manager.software.get("data-manipulation-bot")
|
||||
data_manipulation_bot.configure(
|
||||
server_ip_address=IPv4Address(server.network_interface[1].ip_address), payload="DELETE"
|
||||
)
|
||||
|
||||
# install db server service on server
|
||||
server.software_manager.install(DatabaseService)
|
||||
db_server_service: DatabaseService = server.software_manager.software.get("DatabaseService")
|
||||
db_server_service: DatabaseService = server.software_manager.software.get("database-service")
|
||||
db_server_service.start()
|
||||
|
||||
# Install DB client (green) on client 2
|
||||
client_2.software_manager.install(DatabaseClient)
|
||||
|
||||
database_client: DatabaseClient = client_2.software_manager.software.get("DatabaseClient")
|
||||
database_client: DatabaseClient = client_2.software_manager.software.get("database-client")
|
||||
database_client.configure(server_ip_address=IPv4Address(server.network_interface[1].ip_address))
|
||||
database_client.run()
|
||||
|
||||
@@ -137,13 +137,13 @@ def test_data_manipulation_disrupts_green_agent_connection(data_manipulation_db_
|
||||
network: Network = data_manipulation_db_server_green_client
|
||||
|
||||
client_1: Computer = network.get_node_by_hostname("client_1")
|
||||
data_manipulation_bot: DataManipulationBot = client_1.software_manager.software.get("DataManipulationBot")
|
||||
data_manipulation_bot: DataManipulationBot = client_1.software_manager.software.get("data-manipulation-bot")
|
||||
|
||||
client_2: Computer = network.get_node_by_hostname("client_2")
|
||||
green_db_client: DatabaseClient = client_2.software_manager.software.get("DatabaseClient")
|
||||
green_db_client: DatabaseClient = client_2.software_manager.software.get("database-client")
|
||||
|
||||
server: Server = network.get_node_by_hostname("server_1")
|
||||
db_server_service: DatabaseService = server.software_manager.software.get("DatabaseService")
|
||||
db_server_service: DatabaseService = server.software_manager.software.get("database-service")
|
||||
|
||||
green_db_connection: DatabaseClientConnection = green_db_client.get_new_connection()
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ def dos_bot_and_db_server(client_server) -> Tuple[DoSBot, Computer, DatabaseServ
|
||||
# Install DoSBot on computer
|
||||
computer.software_manager.install(DoSBot)
|
||||
|
||||
dos_bot: DoSBot = computer.software_manager.software.get("DoSBot")
|
||||
dos_bot: DoSBot = computer.software_manager.software.get("dos-bot")
|
||||
dos_bot.configure(
|
||||
target_ip_address=IPv4Address(server.network_interface[1].ip_address),
|
||||
target_port=PORT_LOOKUP["POSTGRES_SERVER"],
|
||||
@@ -31,7 +31,7 @@ def dos_bot_and_db_server(client_server) -> Tuple[DoSBot, Computer, DatabaseServ
|
||||
|
||||
# Install DB Server service on server
|
||||
server.software_manager.install(DatabaseService)
|
||||
db_server_service: DatabaseService = server.software_manager.software.get("DatabaseService")
|
||||
db_server_service: DatabaseService = server.software_manager.software.get("database-service")
|
||||
db_server_service.start()
|
||||
|
||||
return dos_bot, computer, db_server_service, server
|
||||
@@ -56,7 +56,7 @@ def dos_bot_db_server_green_client(example_network) -> Network:
|
||||
# install DoS bot on client 1
|
||||
client_1.software_manager.install(DoSBot)
|
||||
|
||||
dos_bot: DoSBot = client_1.software_manager.software.get("DoSBot")
|
||||
dos_bot: DoSBot = client_1.software_manager.software.get("dos-bot")
|
||||
dos_bot.configure(
|
||||
target_ip_address=IPv4Address(server.network_interface[1].ip_address),
|
||||
target_port=PORT_LOOKUP["POSTGRES_SERVER"],
|
||||
@@ -64,13 +64,13 @@ def dos_bot_db_server_green_client(example_network) -> Network:
|
||||
|
||||
# install db server service on server
|
||||
server.software_manager.install(DatabaseService)
|
||||
db_server_service: DatabaseService = server.software_manager.software.get("DatabaseService")
|
||||
db_server_service: DatabaseService = server.software_manager.software.get("database-service")
|
||||
db_server_service.start()
|
||||
|
||||
# Install DB client (green) on client 2
|
||||
client_2.software_manager.install(DatabaseClient)
|
||||
|
||||
database_client: DatabaseClient = client_2.software_manager.software.get("DatabaseClient")
|
||||
database_client: DatabaseClient = client_2.software_manager.software.get("database-client")
|
||||
database_client.configure(server_ip_address=IPv4Address("192.168.0.1"))
|
||||
database_client.run()
|
||||
|
||||
@@ -159,13 +159,13 @@ def test_dos_blocks_green_agent_connection(dos_bot_db_server_green_client):
|
||||
network: Network = dos_bot_db_server_green_client
|
||||
|
||||
client_1: Computer = network.get_node_by_hostname("client_1")
|
||||
dos_bot: DoSBot = client_1.software_manager.software.get("DoSBot")
|
||||
dos_bot: DoSBot = client_1.software_manager.software.get("dos-bot")
|
||||
|
||||
client_2: Computer = network.get_node_by_hostname("client_2")
|
||||
green_db_client: DatabaseClient = client_2.software_manager.software.get("DatabaseClient")
|
||||
green_db_client: DatabaseClient = client_2.software_manager.software.get("database-client")
|
||||
|
||||
server: Server = network.get_node_by_hostname("server_1")
|
||||
db_server_service: DatabaseService = server.software_manager.software.get("DatabaseService")
|
||||
db_server_service: DatabaseService = server.software_manager.software.get("database-service")
|
||||
|
||||
assert db_server_service.health_state_actual is SoftwareHealthState.GOOD
|
||||
|
||||
|
||||
@@ -22,20 +22,20 @@ def ransomware_script_and_db_server(client_server) -> Tuple[RansomwareScript, Co
|
||||
|
||||
# install db client on computer
|
||||
computer.software_manager.install(DatabaseClient)
|
||||
db_client: DatabaseClient = computer.software_manager.software.get("DatabaseClient")
|
||||
db_client: DatabaseClient = computer.software_manager.software.get("database-client")
|
||||
db_client.run()
|
||||
|
||||
# Install DoSBot on computer
|
||||
computer.software_manager.install(RansomwareScript)
|
||||
|
||||
ransomware_script_application: RansomwareScript = computer.software_manager.software.get("RansomwareScript")
|
||||
ransomware_script_application: RansomwareScript = computer.software_manager.software.get("ransomware-script")
|
||||
ransomware_script_application.configure(
|
||||
server_ip_address=IPv4Address(server.network_interface[1].ip_address), payload="ENCRYPT"
|
||||
)
|
||||
|
||||
# Install DB Server service on server
|
||||
server.software_manager.install(DatabaseService)
|
||||
db_server_service: DatabaseService = server.software_manager.software.get("DatabaseService")
|
||||
db_server_service: DatabaseService = server.software_manager.software.get("database-service")
|
||||
db_server_service.start()
|
||||
|
||||
return ransomware_script_application, computer, db_server_service, server
|
||||
@@ -59,26 +59,26 @@ def ransomware_script_db_server_green_client(example_network) -> Network:
|
||||
|
||||
# install db client on client 1
|
||||
client_1.software_manager.install(DatabaseClient)
|
||||
db_client: DatabaseClient = client_1.software_manager.software.get("DatabaseClient")
|
||||
db_client: DatabaseClient = client_1.software_manager.software.get("database-client")
|
||||
db_client.run()
|
||||
|
||||
# install Ransomware Script bot on client 1
|
||||
client_1.software_manager.install(RansomwareScript)
|
||||
|
||||
ransomware_script_application: RansomwareScript = client_1.software_manager.software.get("RansomwareScript")
|
||||
ransomware_script_application: RansomwareScript = client_1.software_manager.software.get("ransomware-script")
|
||||
ransomware_script_application.configure(
|
||||
server_ip_address=IPv4Address(server.network_interface[1].ip_address), payload="ENCRYPT"
|
||||
)
|
||||
|
||||
# install db server service on server
|
||||
server.software_manager.install(DatabaseService)
|
||||
db_server_service: DatabaseService = server.software_manager.software.get("DatabaseService")
|
||||
db_server_service: DatabaseService = server.software_manager.software.get("database-service")
|
||||
db_server_service.start()
|
||||
|
||||
# Install DB client (green) on client 2
|
||||
client_2.software_manager.install(DatabaseClient)
|
||||
|
||||
database_client: DatabaseClient = client_2.software_manager.software.get("DatabaseClient")
|
||||
database_client: DatabaseClient = client_2.software_manager.software.get("database-client")
|
||||
database_client.configure(server_ip_address=IPv4Address(server.network_interface[1].ip_address))
|
||||
database_client.run()
|
||||
|
||||
@@ -110,15 +110,15 @@ def test_ransomware_disrupts_green_agent_connection(ransomware_script_db_server_
|
||||
network: Network = ransomware_script_db_server_green_client
|
||||
|
||||
client_1: Computer = network.get_node_by_hostname("client_1")
|
||||
ransomware_script_application: RansomwareScript = client_1.software_manager.software.get("RansomwareScript")
|
||||
ransomware_script_application: RansomwareScript = client_1.software_manager.software.get("ransomware-script")
|
||||
|
||||
client_2: Computer = network.get_node_by_hostname("client_2")
|
||||
green_db_client: DatabaseClient = client_2.software_manager.software.get("DatabaseClient")
|
||||
green_db_client: DatabaseClient = client_2.software_manager.software.get("database-client")
|
||||
green_db_client.connect()
|
||||
green_db_client_connection: DatabaseClientConnection = green_db_client.get_new_connection()
|
||||
|
||||
server: Server = network.get_node_by_hostname("server_1")
|
||||
db_server_service: DatabaseService = server.software_manager.software.get("DatabaseService")
|
||||
db_server_service: DatabaseService = server.software_manager.software.get("database-service")
|
||||
|
||||
assert db_server_service.db_file.health_status is FileSystemItemHealthStatus.GOOD
|
||||
assert green_db_client.query("SELECT") is True
|
||||
|
||||
Reference in New Issue
Block a user