Skip to content

Commit

Permalink
Merge pull request #66 from stratosphereips/sebas-check-bening-agent
Browse files Browse the repository at this point in the history
Sebas-check-bening-agent
  • Loading branch information
eldraco authored Apr 25, 2024
2 parents c4f3d77 + b83636e commit bbd2d13
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 5 additions & 4 deletions agents/benign_random/benign_random_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@

class RandomBenignAgent(BaseAgent):

def __init__(self, host:str, port:int,role:str, allowed_actions:list, amp_limit:int=None) -> None:
def __init__(self, host:str, port:int,role:str, allowed_actions:list, apm_limit:int=None) -> None:
super().__init__(host, port, role)
self._allowed_actions = allowed_actions
self._apm_limit = amp_limit
self._apm_limit = apm_limit
if self._apm_limit:
self.interval = 60/amp_limit
self.interval = 60/apm_limit
else:
self.interval = 0

Expand Down Expand Up @@ -79,12 +79,13 @@ def select_action(self, observation:Observation)->Action:
parser.add_argument("--port", help="Port where the game server is", default=9000, type=int, action='store', required=False)
parser.add_argument("--episodes", help="Sets number of testing episodes", default=10, type=int)
parser.add_argument("--logdir", help="Folder to store logs", default=os.path.join(os.path.dirname(os.path.abspath(__file__)), "logs"))
parser.add_argument("--apm", help="Actions per minute", default=10, type=int, required=False)
args = parser.parse_args()

if not os.path.exists(args.logdir):
os.makedirs(args.logdir)
logging.basicConfig(filename=os.path.join(args.logdir, "benign_random_agent.log"), filemode='w', format='%(asctime)s %(name)s %(levelname)s %(message)s', datefmt='%H:%M:%S',level=logging.DEBUG)

# Create agent
agent = RandomBenignAgent(args.host, args.port,"Human",allowed_actions=[ActionType.FindData, ActionType.ExfiltrateData, ActionType.FindServices], amp_limit=10)
agent = RandomBenignAgent(args.host, args.port,"Human",allowed_actions=[ActionType.FindData, ActionType.ExfiltrateData, ActionType.FindServices], apm_limit=args.apm)
agent.play_game(args.episodes)
7 changes: 7 additions & 0 deletions docs/bening_random.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Bening Random Agent
The gening random agent is an agent designed to do bening actions in a random order.

Actions are the same as in the rest of the agents, but there should not be a specific goal for winning the game, but more like the actions following other goal, such as 'working'.
This agent in particular implements random actions, which in theory looks very similar to the `random agent`. The only differences is that the `bening random agent` has a limitation of APM, or Actions Per Minute, since it is supposed to mimic a human operator.

The other differene is that the `bening random agent` does not do the actions `ScanNetwork`, `ScanServices` or `ExploitServices`. However, it does do the action `FindServices` because it is possible that a network administrator is actually scanning for ports to see which ones are open.

0 comments on commit bbd2d13

Please sign in to comment.