#2912 - Updated to include __all__ and some test fixes. New extensible actions documentation page
This commit is contained in:
@@ -97,16 +97,16 @@ agents:
|
||||
action_space:
|
||||
action_list:
|
||||
- type: do_nothing
|
||||
- type: FIREWALL_ACL_ADDRULE firewall_acl_add_rule
|
||||
- type: FIREWALL_ACL_REMOVERULE
|
||||
- type: NETWORK_PORT_DISABLE
|
||||
- type: NETWORK_PORT_ENABLE
|
||||
- type: firewall_acl_add_rule
|
||||
- type: firewall_acl_remove_rule
|
||||
- type: network_port_disable
|
||||
- type: network_port_enable
|
||||
action_map:
|
||||
0:
|
||||
action: DONOTHING
|
||||
action: do_nothing
|
||||
options: {}
|
||||
1:
|
||||
action: FIREWALL_ACL_ADDRULE
|
||||
action: firewall_acl_add_rule
|
||||
options:
|
||||
target_firewall_nodename: firewall
|
||||
firewall_port_name: internal
|
||||
@@ -121,14 +121,14 @@ agents:
|
||||
source_wildcard_id: 0
|
||||
dest_wildcard_id: 0
|
||||
2:
|
||||
action: FIREWALL_ACL_REMOVERULE
|
||||
action: firewall_acl_remove_rule
|
||||
options:
|
||||
target_firewall_nodename: firewall
|
||||
firewall_port_name: internal
|
||||
firewall_port_direction: inbound
|
||||
position: 1
|
||||
3:
|
||||
action: FIREWALL_ACL_ADDRULE
|
||||
action: firewall_acl_add_rule
|
||||
options:
|
||||
target_firewall_nodename: firewall
|
||||
firewall_port_name: internal
|
||||
@@ -143,14 +143,14 @@ agents:
|
||||
source_wildcard_id: 0
|
||||
dest_wildcard_id: 0
|
||||
4:
|
||||
action: FIREWALL_ACL_REMOVERULE
|
||||
action: firewall_acl_remove_rule
|
||||
options:
|
||||
target_firewall_nodename: firewall
|
||||
firewall_port_name: internal
|
||||
firewall_port_direction: outbound
|
||||
position: 1
|
||||
5:
|
||||
action: FIREWALL_ACL_ADDRULE
|
||||
action: firewall_acl_add_rule
|
||||
options:
|
||||
target_firewall_nodename: firewall
|
||||
firewall_port_name: dmz
|
||||
@@ -165,14 +165,14 @@ agents:
|
||||
source_wildcard_id: 0
|
||||
dest_wildcard_id: 0
|
||||
6:
|
||||
action: FIREWALL_ACL_REMOVERULE
|
||||
action: firewall_acl_remove_rule
|
||||
options:
|
||||
target_firewall_nodename: firewall
|
||||
firewall_port_name: dmz
|
||||
firewall_port_direction: inbound
|
||||
position: 1
|
||||
7:
|
||||
action: FIREWALL_ACL_ADDRULE
|
||||
action: firewall_acl_add_rule
|
||||
options:
|
||||
target_firewall_nodename: firewall
|
||||
firewall_port_name: dmz
|
||||
@@ -187,14 +187,14 @@ agents:
|
||||
source_wildcard_id: 0
|
||||
dest_wildcard_id: 0
|
||||
8:
|
||||
action: FIREWALL_ACL_REMOVERULE
|
||||
action: firewall_acl_remove_rule
|
||||
options:
|
||||
target_firewall_nodename: firewall
|
||||
firewall_port_name: dmz
|
||||
firewall_port_direction: outbound
|
||||
position: 2
|
||||
9:
|
||||
action: FIREWALL_ACL_ADDRULE
|
||||
action: firewall_acl_add_rule
|
||||
options:
|
||||
target_firewall_nodename: firewall
|
||||
firewall_port_name: external
|
||||
@@ -209,14 +209,14 @@ agents:
|
||||
source_wildcard_id: 0
|
||||
dest_wildcard_id: 0
|
||||
10:
|
||||
action: FIREWALL_ACL_REMOVERULE
|
||||
action: firewall_acl_remove_rule
|
||||
options:
|
||||
target_firewall_nodename: firewall
|
||||
firewall_port_name: external
|
||||
firewall_port_direction: inbound
|
||||
position: 10
|
||||
11:
|
||||
action: FIREWALL_ACL_ADDRULE
|
||||
action: firewall_acl_add_rule
|
||||
options:
|
||||
target_firewall_nodename: firewall
|
||||
firewall_port_name: external
|
||||
@@ -231,19 +231,19 @@ agents:
|
||||
source_wildcard_id: 0
|
||||
dest_wildcard_id: 0
|
||||
12:
|
||||
action: FIREWALL_ACL_REMOVERULE
|
||||
action: firewall_acl_remove_rule
|
||||
options:
|
||||
target_firewall_nodename: firewall
|
||||
firewall_port_name: external
|
||||
firewall_port_direction: outbound
|
||||
position: 1
|
||||
13:
|
||||
action: NETWORK_PORT_DISABLE
|
||||
action: network_port_disable
|
||||
options:
|
||||
target_nodename: firewall
|
||||
port_id: 3
|
||||
14:
|
||||
action: NETWORK_PORT_ENABLE
|
||||
action: network_port_enable
|
||||
options:
|
||||
target_nodename: firewall
|
||||
port_id: 3
|
||||
|
||||
@@ -463,7 +463,7 @@ def game_and_agent():
|
||||
{"type": "c2_server_ransomware_configure"},
|
||||
{"type": "c2_server_terminal_command"},
|
||||
{"type": "c2_server_data_exfiltrate"},
|
||||
{"type": "node_accounts_change_password"},
|
||||
{"type": "node_account_change_password"},
|
||||
{"type": "node_session_remote_login"},
|
||||
{"type": "node_session_remote_logoff"},
|
||||
{"type": "node_send_remote_command"},
|
||||
|
||||
@@ -4,7 +4,7 @@ from ipaddress import IPv4Address
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from primaite.game.agent.actions import (
|
||||
from primaite.game.agent.actions.config import (
|
||||
ConfigureDatabaseClientAction,
|
||||
ConfigureDoSBotAction,
|
||||
ConfigureRansomwareScriptAction,
|
||||
@@ -35,10 +35,10 @@ class TestConfigureDatabaseAction:
|
||||
db_client: DatabaseClient = client_1.software_manager.software["DatabaseClient"]
|
||||
|
||||
action = (
|
||||
"CONFIGURE_DATABASE_CLIENT",
|
||||
"configure_database_client",
|
||||
{
|
||||
"node_id": 0,
|
||||
"config": {
|
||||
"node_name": "client_1",
|
||||
"model_config": {
|
||||
"server_ip_address": "192.168.1.99",
|
||||
"server_password": "admin123",
|
||||
},
|
||||
@@ -53,7 +53,7 @@ class TestConfigureDatabaseAction:
|
||||
def test_configure_ip(self, game_and_agent):
|
||||
game, agent = game_and_agent
|
||||
agent: ControlledAgent
|
||||
agent.action_manager.actions["CONFIGURE_DATABASE_CLIENT"] = ConfigureDatabaseClientAction(agent.action_manager)
|
||||
agent.action_manager.actions["configure_database_client"] = ConfigureDatabaseClientAction(agent.action_manager)
|
||||
|
||||
# make sure there is a database client on this node
|
||||
client_1 = game.simulation.network.get_node_by_hostname("client_1")
|
||||
|
||||
@@ -124,15 +124,15 @@ def test_router_acl_addrule_integration(game_and_agent: Tuple[PrimaiteGame, Prox
|
||||
"router_acl_add_rule",
|
||||
{
|
||||
"target_router": "router",
|
||||
"position": 4, # 4th rule
|
||||
"permission": 2, # DENY
|
||||
"source_ip_id": 3, # 10.0.1.2 (client_1)
|
||||
"dest_ip_id": 6, # 10.0.2.3 (server_2)
|
||||
"dest_port_id": 1, # ALL
|
||||
"source_port_id": 1, # ALL
|
||||
"protocol_name": "ALL", # ALL
|
||||
"source_wildcard_id": 0,
|
||||
"dest_wildcard_id": 0,
|
||||
"position": 4,
|
||||
"permission": "DENY",
|
||||
"src_ip": "10.0.1.2",
|
||||
"src_wildcard": 0,
|
||||
"source_port": "ALL",
|
||||
"dst_ip": "10.0.2.3",
|
||||
"dst_wildcard": 0,
|
||||
"dst_port": "ALL",
|
||||
"protocol_name": "ALL",
|
||||
},
|
||||
)
|
||||
agent.store_action(action)
|
||||
@@ -148,18 +148,18 @@ def test_router_acl_addrule_integration(game_and_agent: Tuple[PrimaiteGame, Prox
|
||||
|
||||
# 4: Add a rule to block server_1 from reaching server_2 on router (this should not affect comms as they are on same subnet)
|
||||
action = (
|
||||
"ROUTER_ACL_ADDRULE",
|
||||
"router_acl_add_rule",
|
||||
{
|
||||
"target_router": "router",
|
||||
"position": 5, # 5th rule
|
||||
"permission": 2, # DENY
|
||||
"source_ip_id": 5, # 10.0.2.2 (server_1)
|
||||
"dest_ip_id": 6, # 10.0.2.3 (server_2)
|
||||
"dest_port_id": 1, # ALL
|
||||
"source_port_id": 1, # ALL
|
||||
"protocol_id": 1, # ALL
|
||||
"source_wildcard_id": 0,
|
||||
"dest_wildcard_id": 0,
|
||||
"permission": "DENY", # DENY
|
||||
"src_ip": "10.0.2.2", # 10.0.2.2 (server_1)
|
||||
"src_wildcard": 0,
|
||||
"source_port": "ALL", # ALL
|
||||
"dst_ip": "10.0.2.3", # 10.0.2.3 (server_2)
|
||||
"dst_wildcard": 0,
|
||||
"dst_port": "ALL", # ALL
|
||||
"protocol_name": "ALL", # ALL
|
||||
},
|
||||
)
|
||||
agent.store_action(action)
|
||||
|
||||
Reference in New Issue
Block a user