Vary start node of red agent.
This commit is contained in:
@@ -85,7 +85,7 @@ agents:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
- ref: client_1_data_manipulation_red_bot
|
- ref: data_manipulation_attacker
|
||||||
team: RED
|
team: RED
|
||||||
type: RedDatabaseCorruptingAgent
|
type: RedDatabaseCorruptingAgent
|
||||||
|
|
||||||
@@ -106,6 +106,9 @@ agents:
|
|||||||
- node_name: client_1
|
- node_name: client_1
|
||||||
applications:
|
applications:
|
||||||
- application_name: DataManipulationBot
|
- application_name: DataManipulationBot
|
||||||
|
- node_name: client_2
|
||||||
|
applications:
|
||||||
|
- application_name: DataManipulationBot
|
||||||
max_folders_per_node: 1
|
max_folders_per_node: 1
|
||||||
max_files_per_folder: 1
|
max_files_per_folder: 1
|
||||||
max_services_per_node: 1
|
max_services_per_node: 1
|
||||||
@@ -730,6 +733,13 @@ simulation:
|
|||||||
type: WebBrowser
|
type: WebBrowser
|
||||||
options:
|
options:
|
||||||
target_url: http://arcd.com/users/
|
target_url: http://arcd.com/users/
|
||||||
|
- ref: data_manipulation_bot
|
||||||
|
type: DataManipulationBot
|
||||||
|
options:
|
||||||
|
port_scan_p_of_success: 0.8
|
||||||
|
data_manipulation_p_of_success: 0.8
|
||||||
|
payload: "DELETE"
|
||||||
|
server_ip: 192.168.1.14
|
||||||
services:
|
services:
|
||||||
- ref: client_2_dns_client
|
- ref: client_2_dns_client
|
||||||
type: DNSClient
|
type: DNSClient
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ agents:
|
|||||||
frequency: 4
|
frequency: 4
|
||||||
variance: 3
|
variance: 3
|
||||||
|
|
||||||
- ref: client_1_data_manipulation_red_bot
|
- ref: data_manipulation_attacker
|
||||||
team: RED
|
team: RED
|
||||||
type: RedDatabaseCorruptingAgent
|
type: RedDatabaseCorruptingAgent
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,20 @@
|
|||||||
import random
|
import random
|
||||||
from typing import Dict, List, Tuple
|
from typing import Dict, Tuple
|
||||||
|
|
||||||
from gymnasium.core import ObsType
|
from gymnasium.core import ObsType
|
||||||
|
|
||||||
from primaite.game.agent.interface import AbstractScriptedAgent
|
from primaite.game.agent.interface import AbstractScriptedAgent
|
||||||
from primaite.simulator.system.applications.red_applications.data_manipulation_bot import DataManipulationBot
|
|
||||||
|
|
||||||
|
|
||||||
class DataManipulationAgent(AbstractScriptedAgent):
|
class DataManipulationAgent(AbstractScriptedAgent):
|
||||||
"""Agent that uses a DataManipulationBot to perform an SQL injection attack."""
|
"""Agent that uses a DataManipulationBot to perform an SQL injection attack."""
|
||||||
|
|
||||||
data_manipulation_bots: List["DataManipulationBot"] = []
|
|
||||||
next_execution_timestep: int = 0
|
next_execution_timestep: int = 0
|
||||||
|
starting_node_idx: int = 0
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self._set_next_execution_timestep(self.agent_settings.start_settings.start_step)
|
self.reset_agent_for_episode()
|
||||||
|
|
||||||
def _set_next_execution_timestep(self, timestep: int) -> None:
|
def _set_next_execution_timestep(self, timestep: int) -> None:
|
||||||
"""Set the next execution timestep with a configured random variance.
|
"""Set the next execution timestep with a configured random variance.
|
||||||
@@ -44,9 +43,16 @@ class DataManipulationAgent(AbstractScriptedAgent):
|
|||||||
|
|
||||||
self._set_next_execution_timestep(current_timestep + self.agent_settings.start_settings.frequency)
|
self._set_next_execution_timestep(current_timestep + self.agent_settings.start_settings.frequency)
|
||||||
|
|
||||||
return "NODE_APPLICATION_EXECUTE", {"node_id": 0, "application_id": 0}
|
return "NODE_APPLICATION_EXECUTE", {"node_id": self.starting_node_idx, "application_id": 0}
|
||||||
|
|
||||||
def reset_agent_for_episode(self) -> None:
|
def reset_agent_for_episode(self) -> None:
|
||||||
"""Set the next execution timestep when the episode resets."""
|
"""Set the next execution timestep when the episode resets."""
|
||||||
super().reset_agent_for_episode()
|
super().reset_agent_for_episode()
|
||||||
|
self._select_start_node()
|
||||||
self._set_next_execution_timestep(self.agent_settings.start_settings.start_step)
|
self._set_next_execution_timestep(self.agent_settings.start_settings.start_step)
|
||||||
|
|
||||||
|
def _select_start_node(self) -> None:
|
||||||
|
"""Set the starting starting node of the agent to be a random node from this agent's action manager."""
|
||||||
|
# we are assuming that every node in the node manager has a data manipulation application at idx 0
|
||||||
|
num_nodes = len(self.action_manager.node_names)
|
||||||
|
self.starting_node_idx = random.randint(0, num_nodes - 1)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"""PrimAITE game - Encapsulates the simulation and agents."""
|
"""PrimAITE game - Encapsulates the simulation and agents."""
|
||||||
from ipaddress import IPv4Address
|
from ipaddress import IPv4Address
|
||||||
from typing import Dict, List
|
from typing import Dict, List, Tuple
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict
|
from pydantic import BaseModel, ConfigDict
|
||||||
|
|
||||||
@@ -131,8 +131,14 @@ class PrimaiteGame:
|
|||||||
agent.update_reward(state)
|
agent.update_reward(state)
|
||||||
agent.reward_function.total_reward += agent.reward_function.current_reward
|
agent.reward_function.total_reward += agent.reward_function.current_reward
|
||||||
|
|
||||||
def apply_agent_actions(self) -> None:
|
def apply_agent_actions(self) -> Dict[str, Tuple[str, Dict]]:
|
||||||
"""Apply all actions to simulation as requests."""
|
"""
|
||||||
|
Apply all actions to simulation as requests.
|
||||||
|
|
||||||
|
:return: A recap of each agent's actions, in CAOS format.
|
||||||
|
:rtype: Dict[str, Tuple[str, Dict]]
|
||||||
|
|
||||||
|
"""
|
||||||
agent_actions = {}
|
agent_actions = {}
|
||||||
for agent in self.agents:
|
for agent in self.agents:
|
||||||
obs = agent.observation_manager.current_observation
|
obs = agent.observation_manager.current_observation
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -46,7 +46,7 @@ agents:
|
|||||||
frequency: 20
|
frequency: 20
|
||||||
variance: 5
|
variance: 5
|
||||||
|
|
||||||
- ref: client_1_data_manipulation_red_bot
|
- ref: data_manipulation_attacker
|
||||||
team: RED
|
team: RED
|
||||||
type: RedDatabaseCorruptingAgent
|
type: RedDatabaseCorruptingAgent
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ agents:
|
|||||||
frequency: 20
|
frequency: 20
|
||||||
variance: 5
|
variance: 5
|
||||||
|
|
||||||
- ref: client_1_data_manipulation_red_bot
|
- ref: data_manipulation_attacker
|
||||||
team: RED
|
team: RED
|
||||||
type: RedDatabaseCorruptingAgent
|
type: RedDatabaseCorruptingAgent
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ agents:
|
|||||||
frequency: 20
|
frequency: 20
|
||||||
variance: 5
|
variance: 5
|
||||||
|
|
||||||
- ref: client_1_data_manipulation_red_bot
|
- ref: data_manipulation_attacker
|
||||||
team: RED
|
team: RED
|
||||||
type: RedDatabaseCorruptingAgent
|
type: RedDatabaseCorruptingAgent
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ agents:
|
|||||||
frequency: 20
|
frequency: 20
|
||||||
variance: 5
|
variance: 5
|
||||||
|
|
||||||
- ref: client_1_data_manipulation_red_bot
|
- ref: data_manipulation_attacker
|
||||||
team: RED
|
team: RED
|
||||||
type: RedDatabaseCorruptingAgent
|
type: RedDatabaseCorruptingAgent
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ agents:
|
|||||||
frequency: 20
|
frequency: 20
|
||||||
variance: 5
|
variance: 5
|
||||||
|
|
||||||
- ref: client_1_data_manipulation_red_bot
|
- ref: data_manipulation_attacker
|
||||||
team: RED
|
team: RED
|
||||||
type: RedDatabaseCorruptingAgent
|
type: RedDatabaseCorruptingAgent
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user