forked from p15670423/monkey
Island: Add an endpoint for setting the island's mode. Also, add an enum of all the modes
This commit is contained in:
parent
af739b6c99
commit
f8b6277a88
|
@ -26,6 +26,7 @@ from monkey_island.cc.resources.edge import Edge
|
||||||
from monkey_island.cc.resources.environment import Environment
|
from monkey_island.cc.resources.environment import Environment
|
||||||
from monkey_island.cc.resources.island_configuration import IslandConfiguration
|
from monkey_island.cc.resources.island_configuration import IslandConfiguration
|
||||||
from monkey_island.cc.resources.island_logs import IslandLog
|
from monkey_island.cc.resources.island_logs import IslandLog
|
||||||
|
from monkey_island.cc.resources.island_mode import IslandMode
|
||||||
from monkey_island.cc.resources.local_run import LocalRun
|
from monkey_island.cc.resources.local_run import LocalRun
|
||||||
from monkey_island.cc.resources.log import Log
|
from monkey_island.cc.resources.log import Log
|
||||||
from monkey_island.cc.resources.monkey import Monkey
|
from monkey_island.cc.resources.monkey import Monkey
|
||||||
|
@ -132,6 +133,8 @@ def init_api_resources(api):
|
||||||
api.add_resource(
|
api.add_resource(
|
||||||
Telemetry, "/api/telemetry", "/api/telemetry/", "/api/telemetry/<string:monkey_guid>"
|
Telemetry, "/api/telemetry", "/api/telemetry/", "/api/telemetry/<string:monkey_guid>"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
api.add_resource(IslandMode, "/api/island-mode")
|
||||||
api.add_resource(MonkeyConfiguration, "/api/configuration", "/api/configuration/")
|
api.add_resource(MonkeyConfiguration, "/api/configuration", "/api/configuration/")
|
||||||
api.add_resource(IslandConfiguration, "/api/configuration/island", "/api/configuration/island/")
|
api.add_resource(IslandConfiguration, "/api/configuration/island", "/api/configuration/island/")
|
||||||
api.add_resource(ConfigurationExport, "/api/configuration/export")
|
api.add_resource(ConfigurationExport, "/api/configuration/export")
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
import json
|
||||||
|
|
||||||
|
import flask_restful
|
||||||
|
from flask import make_response, request
|
||||||
|
|
||||||
|
from monkey_island.cc.resources.auth.auth import jwt_required
|
||||||
|
from monkey_island.cc.services.mode import island_mode_service
|
||||||
|
from monkey_island.cc.services.mode.mode_enum import IslandModeEnum
|
||||||
|
|
||||||
|
|
||||||
|
class IslandMode(flask_restful.Resource):
|
||||||
|
@jwt_required
|
||||||
|
def post(self):
|
||||||
|
body = json.loads(request.data)
|
||||||
|
mode_str = body.get("mode")
|
||||||
|
mode = IslandModeEnum(mode_str)
|
||||||
|
island_mode_service.set_mode(mode)
|
||||||
|
|
||||||
|
# TODO return status
|
||||||
|
return make_response({})
|
|
@ -0,0 +1,5 @@
|
||||||
|
from monkey_island.cc.services.mode.mode_enum import IslandModeEnum
|
||||||
|
|
||||||
|
|
||||||
|
def set_mode(mode: IslandModeEnum):
|
||||||
|
pass
|
|
@ -0,0 +1,6 @@
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
|
class IslandModeEnum(Enum):
|
||||||
|
RANSOMWARE = "ransomware"
|
||||||
|
ADVANCED = "advanced"
|
Loading…
Reference in New Issue