From 0783e236aac4a635ac0894154d256b7ee2401b1b Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Tue, 7 Dec 2021 11:29:52 -0500 Subject: [PATCH] Agent: Add agent GUID to /api/propagation-credentials call --- monkey/infection_monkey/master/control_channel.py | 4 +++- .../cc/resources/propagation_credentials.py | 2 +- monkey/monkey_island/cc/services/config.py | 10 +++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/monkey/infection_monkey/master/control_channel.py b/monkey/infection_monkey/master/control_channel.py index 24cd2ae55..3509cedc2 100644 --- a/monkey/infection_monkey/master/control_channel.py +++ b/monkey/infection_monkey/master/control_channel.py @@ -56,7 +56,7 @@ class ControlChannel(IControlChannel): def get_credentials_for_propagation(self) -> dict: try: response = requests.get( # noqa: DUO123 - f"{self._control_channel_server}/api/propagation-credentials", + f"{self._control_channel_server}/api/propagation-credentials/{self._agent_id}", verify=False, proxies=ControlClient.proxies, timeout=SHORT_REQUEST_TIMEOUT, @@ -67,3 +67,5 @@ class ControlChannel(IControlChannel): except Exception as e: # TODO: Evaluate how this exception is handled; don't just log and ignore it. logger.error(f"An error occurred while trying to connect to server. {e}") + + return {} diff --git a/monkey/monkey_island/cc/resources/propagation_credentials.py b/monkey/monkey_island/cc/resources/propagation_credentials.py index f85ffea0d..532501658 100644 --- a/monkey/monkey_island/cc/resources/propagation_credentials.py +++ b/monkey/monkey_island/cc/resources/propagation_credentials.py @@ -7,7 +7,7 @@ from monkey_island.cc.services.config import ConfigService class PropagationCredentials(flask_restful.Resource): def get(self, guid: str): monkey_json = mongo.db.monkey.find_one_or_404({"guid": guid}) - ConfigService.decrypt_flat_config(monkey_json) + ConfigService.decrypt_flat_config(monkey_json["config"]) propagation_credentials = ConfigService.get_config_propagation_credentials_from_flat_config( monkey_json["config"] diff --git a/monkey/monkey_island/cc/services/config.py b/monkey/monkey_island/cc/services/config.py index a6a2f9514..af9c0a155 100644 --- a/monkey/monkey_island/cc/services/config.py +++ b/monkey/monkey_island/cc/services/config.py @@ -412,11 +412,11 @@ class ConfigService: @staticmethod def get_config_propagation_credentials_from_flat_config(config): return { - "exploit_user_list": config["exploit_user_list"], - "exploit_password_list": config["exploit_password_list"], - "exploit_lm_hash_list": config["exploit_lm_hash_list"], - "exploit_ntlm_hash_list": config["exploit_ntlm_hash_list"], - "exploit_ssh_keys": config["exploit_ssh_keys"], + "exploit_user_list": config.get("exploit_user_list", []), + "exploit_password_list": config.get("exploit_password_list", []), + "exploit_lm_hash_list": config.get("exploit_lm_hash_list", []), + "exploit_ntlm_hash_list": config.get("exploit_ntlm_hash_list", []), + "exploit_ssh_keys": config.get("exploit_ssh_keys", []), } @staticmethod