Agent: Remove --config argument

This commit is contained in:
Ilija Lazoroski 2022-05-30 13:26:39 +02:00
parent b3710e4772
commit 8d225b5c1b
3 changed files with 3 additions and 26 deletions

View File

@ -73,6 +73,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/).
- Island log download button from "Telemetries"(previously called "Logs") page. #1640 - Island log download button from "Telemetries"(previously called "Logs") page. #1640
- "/api/client-monkey" endpoint. #1889 - "/api/client-monkey" endpoint. #1889
- "+dev" from version numbers. #1553 - "+dev" from version numbers. #1553
- agent's "--config" argument. #906
### Fixed ### Fixed
- A bug in network map page that caused delay of telemetry log loading. #1545 - A bug in network map page that caused delay of telemetry log loading. #1545

View File

@ -1,12 +1,8 @@
import os
import sys
import uuid import uuid
from abc import ABCMeta from abc import ABCMeta
GUID = str(uuid.getnode()) GUID = str(uuid.getnode())
EXTERNAL_CONFIG_FILE = os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), "monkey.bin")
SENSITIVE_FIELDS = [ SENSITIVE_FIELDS = [
"exploit_password_list", "exploit_password_list",
"exploit_user_list", "exploit_user_list",

View File

@ -1,5 +1,4 @@
import argparse import argparse
import json
import logging import logging
import logging.config import logging.config
import os import os
@ -12,7 +11,7 @@ from pprint import pformat
# noinspection PyUnresolvedReferences # noinspection PyUnresolvedReferences
import infection_monkey.post_breach # noqa: F401 import infection_monkey.post_breach # noqa: F401
from common.version import get_version 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.dropper import MonkeyDrops
from infection_monkey.model import DROPPER_ARG, MONKEY_ARG from infection_monkey.model import DROPPER_ARG, MONKEY_ARG
from infection_monkey.monkey import InfectionMonkey from infection_monkey.monkey import InfectionMonkey
@ -53,27 +52,8 @@ def main():
if not (monkey_mode in [MONKEY_ARG, DROPPER_ARG]): if not (monkey_mode in [MONKEY_ARG, DROPPER_ARG]):
return True return True
config_file = EXTERNAL_CONFIG_FILE
arg_parser = argparse.ArgumentParser() arg_parser = argparse.ArgumentParser()
arg_parser.add_argument("-c", "--config") _, monkey_args = arg_parser.parse_known_args(sys.argv[2:])
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,)
)
formatted_config = pformat(WormConfiguration.hide_sensitive_info(WormConfiguration.as_dict())) formatted_config = pformat(WormConfiguration.hide_sensitive_info(WormConfiguration.as_dict()))
print(f"Loaded Configuration:\n{formatted_config}") print(f"Loaded Configuration:\n{formatted_config}")