Island: Add local_ips resource

This commit is contained in:
Ilija Lazoroski 2022-06-13 16:33:35 +02:00 committed by vakarisz
parent ac172dc81f
commit 9444f1a9d7
2 changed files with 20 additions and 0 deletions

View File

@ -30,6 +30,7 @@ from monkey_island.cc.resources.exploitations.monkey_exploitation import MonkeyE
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.island_mode import IslandMode
from monkey_island.cc.resources.local_ips import LocalIps
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
@ -171,6 +172,7 @@ def init_api_resources(api: FlaskDIWrapper):
api.add_resource(TelemetryFeed) api.add_resource(TelemetryFeed)
api.add_resource(Log) api.add_resource(Log)
api.add_resource(IslandLog) api.add_resource(IslandLog)
api.add_resource(LocalIps)
# API Spec: These two should be the same resource, GET for download and POST for upload # API Spec: These two should be the same resource, GET for download and POST for upload
api.add_resource(PBAFileDownload) api.add_resource(PBAFileDownload)

View File

@ -0,0 +1,18 @@
from monkey_island.cc.resources.AbstractResource import AbstractResource
from monkey_island.cc.resources.request_authentication import jwt_required
from monkey_island.cc.services.utils.network_utils import local_ip_addresses
class LocalIps(AbstractResource):
urls = ["/api/island/local-ips"]
@jwt_required
def get(self):
"""
Gets the local ip address from the Island
:return: a list of local ips
"""
local_ips = local_ip_addresses()
return {"local_ips": local_ips}