From 7766e27f16083d345cae5b30bbe5a3e84a965b39 Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Mon, 22 Nov 2021 13:46:09 +0100 Subject: [PATCH] Island: Add mock endpoint to check if the agent should stop --- monkey/monkey_island/cc/app.py | 2 ++ .../cc/resources/monkey_control/stop_agent_check.py | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 monkey/monkey_island/cc/resources/monkey_control/stop_agent_check.py diff --git a/monkey/monkey_island/cc/app.py b/monkey/monkey_island/cc/app.py index 7ea91c0db..113c20d06 100644 --- a/monkey/monkey_island/cc/app.py +++ b/monkey/monkey_island/cc/app.py @@ -33,6 +33,7 @@ from monkey_island.cc.resources.monkey import Monkey from monkey_island.cc.resources.monkey_configuration import MonkeyConfiguration from monkey_island.cc.resources.monkey_control.remote_port_check import RemotePortCheck from monkey_island.cc.resources.monkey_control.started_on_island import StartedOnIsland +from monkey_island.cc.resources.monkey_control.stop_agent_check import StopAgentCheck from monkey_island.cc.resources.monkey_download import MonkeyDownload from monkey_island.cc.resources.netmap import NetMap from monkey_island.cc.resources.node import Node @@ -168,6 +169,7 @@ def init_api_resources(api): api.add_resource(VersionUpdate, "/api/version-update", "/api/version-update/") api.add_resource(RemotePortCheck, "/api/monkey_control/check_remote_port/") api.add_resource(StartedOnIsland, "/api/monkey_control/started_on_island") + api.add_resource(StopAgentCheck, "/api/monkey_control/") api.add_resource(ScoutSuiteAuth, "/api/scoutsuite_auth/") api.add_resource(AWSKeys, "/api/aws_keys") diff --git a/monkey/monkey_island/cc/resources/monkey_control/stop_agent_check.py b/monkey/monkey_island/cc/resources/monkey_control/stop_agent_check.py new file mode 100644 index 000000000..817d6db94 --- /dev/null +++ b/monkey/monkey_island/cc/resources/monkey_control/stop_agent_check.py @@ -0,0 +1,9 @@ +import flask_restful + + +class StopAgentCheck(flask_restful.Resource): + def get(self, monkey_guid: int): + if monkey_guid % 2: + return {"stop_agent": True} + else: + return {"stop_agent": False}