From b284467fbcadeeec4bfe3d50936d98cd6ed42ce7 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Tue, 7 Nov 2017 16:33:26 +0200 Subject: [PATCH] Add scanned and exploited to report --- monkey_island/cc/services/report.py | 38 ++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/monkey_island/cc/services/report.py b/monkey_island/cc/services/report.py index fd8bc3bdb..ca7a55234 100644 --- a/monkey_island/cc/services/report.py +++ b/monkey_island/cc/services/report.py @@ -31,6 +31,40 @@ class ReportService: (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_scanned(): + nodes =\ + [NodeService.get_displayed_node_by_id(node['_id']) for node in mongo.db.node.find({}, {'_id': 1})]\ + + [NodeService.get_displayed_node_by_id(monkey['_id']) for monkey in mongo.db.monkey.find({}, {'_id': 1})] + nodes = [ + { + 'label': node['label'], + 'ip_addresses': node['ip_addresses'], + 'accessible_from_nodes': node['accessible_from_nodes'], + 'services': node['services'] + } + for node in nodes] + + return nodes + + @staticmethod + def get_exploited(): + exploited =\ + [NodeService.get_displayed_node_by_id(monkey['_id']) for monkey in mongo.db.monkey.find({}, {'_id': 1}) + if not NodeService.get_monkey_manual_run(NodeService.get_monkey_by_id(monkey['_id']))]\ + + [NodeService.get_displayed_node_by_id(node['_id']) + for node in mongo.db.node.find({'exploited': True}, {'_id': 1})] + + exploited = [ + { + 'label': monkey['label'], + 'ip_addresses': monkey['ip_addresses'], + 'exploits': [exploit['exploiter'] for exploit in monkey['exploits'] if exploit['result']] + } + for monkey in exploited] + + return exploited + @staticmethod def get_report(): return \ @@ -39,7 +73,9 @@ 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() + 'tunnels': ReportService.get_tunnels(), + 'scanned': ReportService.get_scanned(), + 'exploited': ReportService.get_exploited() } @staticmethod