From e9b6b39a2177761756d96f828884aa962a459695 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Tue, 7 Nov 2017 13:17:02 +0200 Subject: [PATCH] Add tunnel info to report --- monkey_island/cc/services/node.py | 4 ++++ monkey_island/cc/services/report.py | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/monkey_island/cc/services/node.py b/monkey_island/cc/services/node.py index 3acd66b75..af92eaa42 100644 --- a/monkey_island/cc/services/node.py +++ b/monkey_island/cc/services/node.py @@ -89,6 +89,10 @@ class NodeService: return True + @staticmethod + def get_monkey_label_by_id(monkey_id): + return NodeService.get_monkey_label(NodeService.get_monkey_by_id(monkey_id)) + @staticmethod def get_monkey_label(monkey): label = monkey["hostname"] + " : " + monkey["ip_addresses"][0] diff --git a/monkey_island/cc/services/report.py b/monkey_island/cc/services/report.py index 4356c84fd..fd8bc3bdb 100644 --- a/monkey_island/cc/services/report.py +++ b/monkey_island/cc/services/report.py @@ -1,4 +1,5 @@ from cc.database import mongo +from cc.services.node import NodeService __author__ = "itay.mizeretz" @@ -24,6 +25,12 @@ class ReportService: exploit_types = mongo.db.command({'distinct': 'edge', 'key': 'exploits.exploiter'})['values'] return [exploit for exploit in exploit_types if ReportService.did_exploit_type_succeed(exploit)] + @staticmethod + def get_tunnels(): + return [ + (NodeService.get_monkey_label_by_id(tunnel['_id']), NodeService.get_monkey_label_by_id(tunnel['tunnel'])) + for tunnel in mongo.db.monkey.find({'tunnel': {'$exists': True}}, {'tunnel': 1})] + @staticmethod def get_report(): return \ @@ -32,6 +39,7 @@ class ReportService: 'last_monkey_dead_time': ReportService.get_last_monkey_dead_time(), 'breach_count': ReportService.get_breach_count(), 'successful_exploit_types': ReportService.get_successful_exploit_types(), + 'tunnels': ReportService.get_tunnels() } @staticmethod