From 253588b3acabd001cd8e83cd8fec8f60feb52acb Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 12 May 2021 09:03:13 -0400 Subject: [PATCH] island: Move PBA filename paths to config_value_paths.py --- monkey/common/config_value_paths.py | 2 ++ monkey/monkey_island/cc/resources/pba_file_upload.py | 7 ++----- monkey/monkey_island/cc/services/config.py | 12 +++++------- .../monkey_island/cc/services/post_breach_files.py | 6 ------ 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/monkey/common/config_value_paths.py b/monkey/common/config_value_paths.py index 4fc94ea4e..db10fb9e1 100644 --- a/monkey/common/config_value_paths.py +++ b/monkey/common/config_value_paths.py @@ -11,3 +11,5 @@ SUBNET_SCAN_LIST_PATH = ["basic_network", "scope", "subnet_scan_list"] LOCAL_NETWORK_SCAN_PATH = ["basic_network", "scope", "local_network_scan"] LM_HASH_LIST_PATH = ["internal", "exploits", "exploit_lm_hash_list"] NTLM_HASH_LIST_PATH = ["internal", "exploits", "exploit_ntlm_hash_list"] +PBA_LINUX_FILENAME_PATH = ["monkey", "post_breach", "PBA_linux_filename"] +PBA_WINDOWS_FILENAME_PATH = ["monkey", "post_breach", "PBA_windows_filename"] diff --git a/monkey/monkey_island/cc/resources/pba_file_upload.py b/monkey/monkey_island/cc/resources/pba_file_upload.py index 25b54cb28..369bc3c42 100644 --- a/monkey/monkey_island/cc/resources/pba_file_upload.py +++ b/monkey/monkey_island/cc/resources/pba_file_upload.py @@ -6,13 +6,10 @@ import flask_restful from flask import Response, request, send_from_directory from werkzeug.utils import secure_filename +from common.config_value_paths import PBA_LINUX_FILENAME_PATH, PBA_WINDOWS_FILENAME_PATH from monkey_island.cc.resources.auth.auth import jwt_required from monkey_island.cc.services.config import ConfigService -from monkey_island.cc.services.post_breach_files import ( - PBA_LINUX_FILENAME_PATH, - PBA_WINDOWS_FILENAME_PATH, - PostBreachFilesService, -) +from monkey_island.cc.services.post_breach_files import PostBreachFilesService __author__ = "VakarisZ" diff --git a/monkey/monkey_island/cc/services/config.py b/monkey/monkey_island/cc/services/config.py index c0fb3a20c..7c7429756 100644 --- a/monkey/monkey_island/cc/services/config.py +++ b/monkey/monkey_island/cc/services/config.py @@ -9,11 +9,7 @@ import monkey_island.cc.environment.environment_singleton as env_singleton from monkey_island.cc.database import mongo from monkey_island.cc.server_utils.encryptor import get_encryptor from monkey_island.cc.services.config_schema.config_schema import SCHEMA -from monkey_island.cc.services.post_breach_files import ( - PBA_LINUX_FILENAME_PATH, - PBA_WINDOWS_FILENAME_PATH, - PostBreachFilesService, -) +from monkey_island.cc.services.post_breach_files import PostBreachFilesService from monkey_island.cc.services.utils.network_utils import local_ip_addresses __author__ = "itay.mizeretz" @@ -24,6 +20,8 @@ from common.config_value_paths import ( LM_HASH_LIST_PATH, NTLM_HASH_LIST_PATH, PASSWORD_LIST_PATH, + PBA_LINUX_FILENAME_PATH, + PBA_WINDOWS_FILENAME_PATH, SSH_KEYS_PATH, STARTED_ON_ISLAND_PATH, USER_LIST_PATH, @@ -216,8 +214,8 @@ class ConfigService: linux_filename = ConfigService.get_config_value(PBA_LINUX_FILENAME_PATH) windows_filename = ConfigService.get_config_value(PBA_WINDOWS_FILENAME_PATH) - config_json["monkey"]["post_breach"]["PBA_linux_filename"] = linux_filename - config_json["monkey"]["post_breach"]["PBA_windows_filename"] = windows_filename + ConfigService.set_config_value(PBA_LINUX_FILENAME_PATH, linux_filename) + ConfigService.set_config_value(PBA_WINDOWS_FILENAME_PATH, windows_filename) @staticmethod def init_default_config(): diff --git a/monkey/monkey_island/cc/services/post_breach_files.py b/monkey/monkey_island/cc/services/post_breach_files.py index 1a8407564..06d2ffe48 100644 --- a/monkey/monkey_island/cc/services/post_breach_files.py +++ b/monkey/monkey_island/cc/services/post_breach_files.py @@ -2,14 +2,8 @@ import logging import os from pathlib import Path -__author__ = "VakarisZ" - logger = logging.getLogger(__name__) -# Where to find file names in config -PBA_LINUX_FILENAME_PATH = ["monkey", "post_breach", "PBA_linux_filename"] -PBA_WINDOWS_FILENAME_PATH = ["monkey", "post_breach", "PBA_windows_filename"] - class PostBreachFilesService: DATA_DIR = None