From 5e3829aab3420a34e6992cfbefe0d409807f867e Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Wed, 9 Mar 2022 17:00:33 +0530 Subject: [PATCH] Island: Add field `propagated` to node and rename image files --- monkey/monkey_island/cc/services/node.py | 15 ++++++++++++++- .../cc/services/telemetry/processing/exploit.py | 2 ++ .../cc/services/utils/node_states.py | 2 ++ ...{exploited_linux.png => propagated_linux.png} | Bin ...loited_windows.png => propagated_windows.png} | Bin 5 files changed, 18 insertions(+), 1 deletion(-) rename monkey/monkey_island/cc/ui/src/images/nodes/{exploited_linux.png => propagated_linux.png} (100%) rename monkey/monkey_island/cc/ui/src/images/nodes/{exploited_windows.png => propagated_windows.png} (100%) diff --git a/monkey/monkey_island/cc/services/node.py b/monkey/monkey_island/cc/services/node.py index 74fb1b091..a1708e270 100644 --- a/monkey/monkey_island/cc/services/node.py +++ b/monkey/monkey_island/cc/services/node.py @@ -128,8 +128,16 @@ class NodeService: def get_node_group(node) -> str: if "group" in node and node["group"]: return node["group"] - node_type = "exploited" if node.get("exploited") else "clean" + + if node.get("exploited"): + node_type = "exploited" + elif node.get("propagated"): + node_type = "propagated" + else: + node_type = "clean" + node_os = NodeService.get_node_os(node) + return NodeStates.get_by_keywords([node_type, node_os]).value @staticmethod @@ -202,6 +210,7 @@ class NodeService: "ip_addresses": [ip_address], "domain_name": domain_name, "exploited": False, + "propagated": False, "os": {"type": "unknown", "version": "unknown"}, } ) @@ -288,6 +297,10 @@ class NodeService: def set_node_exploited(node_id): mongo.db.node.update({"_id": node_id}, {"$set": {"exploited": True}}) + @staticmethod + def set_node_propagated(node_id): + mongo.db.node.update({"_id": node_id}, {"$set": {"propagated": True}}) + @staticmethod def update_dead_monkeys(): # Update dead monkeys only if no living monkey transmitted keepalive in the last 10 minutes diff --git a/monkey/monkey_island/cc/services/telemetry/processing/exploit.py b/monkey/monkey_island/cc/services/telemetry/processing/exploit.py index d035dedd3..da46cdcc7 100644 --- a/monkey/monkey_island/cc/services/telemetry/processing/exploit.py +++ b/monkey/monkey_island/cc/services/telemetry/processing/exploit.py @@ -52,6 +52,8 @@ def update_network_with_exploit(edge: EdgeService, telemetry_json): edge.update_based_on_exploit(new_exploit) if new_exploit["exploitation_result"]: NodeService.set_node_exploited(edge.dst_node_id) + if new_exploit["propagation_result"]: + NodeService.set_node_propagated(edge.dst_node_id) def encrypt_exploit_creds(telemetry_json): diff --git a/monkey/monkey_island/cc/services/utils/node_states.py b/monkey/monkey_island/cc/services/utils/node_states.py index 0d6371111..476255de4 100644 --- a/monkey/monkey_island/cc/services/utils/node_states.py +++ b/monkey/monkey_island/cc/services/utils/node_states.py @@ -11,6 +11,8 @@ class NodeStates(Enum): CLEAN_WINDOWS = "clean_windows" EXPLOITED_LINUX = "exploited_linux" EXPLOITED_WINDOWS = "exploited_windows" + PROPAGATED_LINUX = "propagated_linux" + PROPAGATED_WINDOWS = "propagated_windows" ISLAND = "island" ISLAND_MONKEY_LINUX = "island_monkey_linux" ISLAND_MONKEY_LINUX_RUNNING = "island_monkey_linux_running" diff --git a/monkey/monkey_island/cc/ui/src/images/nodes/exploited_linux.png b/monkey/monkey_island/cc/ui/src/images/nodes/propagated_linux.png similarity index 100% rename from monkey/monkey_island/cc/ui/src/images/nodes/exploited_linux.png rename to monkey/monkey_island/cc/ui/src/images/nodes/propagated_linux.png diff --git a/monkey/monkey_island/cc/ui/src/images/nodes/exploited_windows.png b/monkey/monkey_island/cc/ui/src/images/nodes/propagated_windows.png similarity index 100% rename from monkey/monkey_island/cc/ui/src/images/nodes/exploited_windows.png rename to monkey/monkey_island/cc/ui/src/images/nodes/propagated_windows.png