forked from p15670423/monkey
island: Rename RunLocalMonkeyService -> LocalMonkeyRunService
This commit is contained in:
parent
79eb7442ae
commit
b8d4452e70
|
@ -6,7 +6,7 @@ from flask import jsonify, make_response, request
|
||||||
from monkey_island.cc.models import Monkey
|
from monkey_island.cc.models import Monkey
|
||||||
from monkey_island.cc.resources.auth.auth import jwt_required
|
from monkey_island.cc.resources.auth.auth import jwt_required
|
||||||
from monkey_island.cc.services.node import NodeService
|
from monkey_island.cc.services.node import NodeService
|
||||||
from monkey_island.cc.services.run_local_monkey import RunLocalMonkeyService
|
from monkey_island.cc.services.run_local_monkey import LocalMonkeyRunService
|
||||||
|
|
||||||
|
|
||||||
class LocalRun(flask_restful.Resource):
|
class LocalRun(flask_restful.Resource):
|
||||||
|
@ -25,7 +25,7 @@ class LocalRun(flask_restful.Resource):
|
||||||
def post(self):
|
def post(self):
|
||||||
body = json.loads(request.data)
|
body = json.loads(request.data)
|
||||||
if body.get("action") == "run":
|
if body.get("action") == "run":
|
||||||
local_run = RunLocalMonkeyService.run_local_monkey()
|
local_run = LocalMonkeyRunService.run_local_monkey()
|
||||||
return jsonify(is_running=local_run[0], error_text=local_run[1])
|
return jsonify(is_running=local_run[0], error_text=local_run[1])
|
||||||
|
|
||||||
# default action
|
# default action
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from monkey_island.cc.services.post_breach_files import PostBreachFilesService
|
from monkey_island.cc.services.post_breach_files import PostBreachFilesService
|
||||||
from monkey_island.cc.services.run_local_monkey import RunLocalMonkeyService
|
from monkey_island.cc.services.run_local_monkey import LocalMonkeyRunService
|
||||||
|
|
||||||
|
|
||||||
def initialize_services(data_dir):
|
def initialize_services(data_dir):
|
||||||
PostBreachFilesService.initialize(data_dir)
|
PostBreachFilesService.initialize(data_dir)
|
||||||
RunLocalMonkeyService.initialize(data_dir)
|
LocalMonkeyRunService.initialize(data_dir)
|
||||||
|
|
|
@ -13,7 +13,7 @@ from monkey_island.cc.services.utils.network_utils import local_ip_addresses
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class RunLocalMonkeyService:
|
class LocalMonkeyRunService:
|
||||||
DATA_DIR = None
|
DATA_DIR = None
|
||||||
|
|
||||||
# TODO: A number of these services should be instance objects instead of
|
# TODO: A number of these services should be instance objects instead of
|
||||||
|
@ -31,7 +31,7 @@ class RunLocalMonkeyService:
|
||||||
return False, "OS Type not found"
|
return False, "OS Type not found"
|
||||||
|
|
||||||
src_path = os.path.join(MONKEY_ISLAND_ABS_PATH, "cc", "binaries", result["filename"])
|
src_path = os.path.join(MONKEY_ISLAND_ABS_PATH, "cc", "binaries", result["filename"])
|
||||||
dest_path = os.path.join(RunLocalMonkeyService.DATA_DIR, result["filename"])
|
dest_path = os.path.join(LocalMonkeyRunService.DATA_DIR, result["filename"])
|
||||||
|
|
||||||
# copy the executable to temp path (don't run the monkey from its current location as it may
|
# copy the executable to temp path (don't run the monkey from its current location as it may
|
||||||
# delete itself)
|
# delete itself)
|
||||||
|
@ -48,7 +48,7 @@ class RunLocalMonkeyService:
|
||||||
port = env_singleton.env.get_island_port()
|
port = env_singleton.env.get_island_port()
|
||||||
|
|
||||||
args = [dest_path, "m0nk3y", "-s", f"{ip}:{port}"]
|
args = [dest_path, "m0nk3y", "-s", f"{ip}:{port}"]
|
||||||
subprocess.Popen(args, cwd=RunLocalMonkeyService.DATA_DIR)
|
subprocess.Popen(args, cwd=LocalMonkeyRunService.DATA_DIR)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.error("popen failed", exc_info=True)
|
logger.error("popen failed", exc_info=True)
|
||||||
return False, "popen failed: %s" % exc
|
return False, "popen failed: %s" % exc
|
||||||
|
|
Loading…
Reference in New Issue