From 8d225b5c1b1da66025e1beaafd512966aed8dc45 Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Mon, 30 May 2022 13:26:39 +0200 Subject: [PATCH] Agent: Remove --config argument --- CHANGELOG.md | 1 + monkey/infection_monkey/config.py | 4 ---- monkey/infection_monkey/main.py | 24 ++---------------------- 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27bf5e27f..e1d37d08b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,6 +73,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/). - Island log download button from "Telemetries"(previously called "Logs") page. #1640 - "/api/client-monkey" endpoint. #1889 - "+dev" from version numbers. #1553 +- agent's "--config" argument. #906 ### Fixed - A bug in network map page that caused delay of telemetry log loading. #1545 diff --git a/monkey/infection_monkey/config.py b/monkey/infection_monkey/config.py index 1f8c46311..ddf224b10 100644 --- a/monkey/infection_monkey/config.py +++ b/monkey/infection_monkey/config.py @@ -1,12 +1,8 @@ -import os -import sys import uuid from abc import ABCMeta GUID = str(uuid.getnode()) -EXTERNAL_CONFIG_FILE = os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), "monkey.bin") - SENSITIVE_FIELDS = [ "exploit_password_list", "exploit_user_list", diff --git a/monkey/infection_monkey/main.py b/monkey/infection_monkey/main.py index 74961e0ad..1ee8023a3 100644 --- a/monkey/infection_monkey/main.py +++ b/monkey/infection_monkey/main.py @@ -1,5 +1,4 @@ import argparse -import json import logging import logging.config import os @@ -12,7 +11,7 @@ from pprint import pformat # noinspection PyUnresolvedReferences import infection_monkey.post_breach # noqa: F401 from common.version import get_version -from infection_monkey.config import EXTERNAL_CONFIG_FILE, WormConfiguration +from infection_monkey.config import WormConfiguration from infection_monkey.dropper import MonkeyDrops from infection_monkey.model import DROPPER_ARG, MONKEY_ARG from infection_monkey.monkey import InfectionMonkey @@ -53,27 +52,8 @@ def main(): if not (monkey_mode in [MONKEY_ARG, DROPPER_ARG]): return True - config_file = EXTERNAL_CONFIG_FILE - arg_parser = argparse.ArgumentParser() - arg_parser.add_argument("-c", "--config") - opts, monkey_args = arg_parser.parse_known_args(sys.argv[2:]) - if opts.config: - config_file = opts.config - if os.path.isfile(config_file): - # using print because config can also change log locations - print("Loading config from %s." % config_file) - try: - with open(config_file) as config_fo: - json_dict = json.load(config_fo) - WormConfiguration.from_kv(json_dict) - except ValueError as e: - print("Error loading config: %s, using default" % (e,)) - else: - print( - "Config file wasn't supplied and default path: %s wasn't found, using internal " - "default" % (config_file,) - ) + _, monkey_args = arg_parser.parse_known_args(sys.argv[2:]) formatted_config = pformat(WormConfiguration.hide_sensitive_info(WormConfiguration.as_dict())) print(f"Loaded Configuration:\n{formatted_config}")