From f35340e7ae65be74812a27c70fca437ca2ac4769 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Mon, 4 Mar 2019 20:20:41 +0200 Subject: [PATCH] Cosmetic changes and small refactors --- monkey/infection_monkey/example.conf | 8 ++++---- monkey/infection_monkey/monkey.py | 4 ++++ monkey/monkey_island/cc/app.py | 2 +- .../cc/resources/{file_upload.py => pba_file_upload.py} | 1 - monkey/monkey_island/cc/services/config.py | 6 ++++-- monkey/monkey_island/cc/services/report.py | 4 ++-- .../cc/ui/src/components/pages/ReportPage.js | 2 +- .../cc/ui/src/components/report-components/PostBreach.js | 7 ------- 8 files changed, 16 insertions(+), 18 deletions(-) rename monkey/monkey_island/cc/resources/{file_upload.py => pba_file_upload.py} (98%) diff --git a/monkey/infection_monkey/example.conf b/monkey/infection_monkey/example.conf index 0e2fc79a9..760ed1139 100644 --- a/monkey/infection_monkey/example.conf +++ b/monkey/infection_monkey/example.conf @@ -100,9 +100,9 @@ "post_breach_actions" : [], "custom_post_breach" : { "linux": "", "windows": "", - "linux_file": "", - "windows_file": "", - "windows_file_info": {"name": "", "size": "0" }, - "linux_file_info": {"name": "", "size":"0"} + "linux_file": None, + "windows_file": None, + "windows_file_info": None, + "linux_file_info": None } } diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index 039052ad0..e80e15396 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -113,6 +113,10 @@ class InfectionMonkey(object): system_info = system_info_collector.get_info() ControlClient.send_telemetry("system_info_collection", system_info) + for action_class in WormConfiguration.post_breach_actions: + action = action_class() + action.act() + PostBreach().execute() if 0 == WormConfiguration.depth: diff --git a/monkey/monkey_island/cc/app.py b/monkey/monkey_island/cc/app.py index 91cf19b39..d43930206 100644 --- a/monkey/monkey_island/cc/app.py +++ b/monkey/monkey_island/cc/app.py @@ -29,7 +29,7 @@ from cc.resources.telemetry import Telemetry from cc.resources.telemetry_feed import TelemetryFeed from cc.resources.pba_file_download import PBAFileDownload from cc.services.config import ConfigService -from cc.resources.file_upload import FileUpload +from cc.resources.pba_file_upload import FileUpload __author__ = 'Barak' diff --git a/monkey/monkey_island/cc/resources/file_upload.py b/monkey/monkey_island/cc/resources/pba_file_upload.py similarity index 98% rename from monkey/monkey_island/cc/resources/file_upload.py rename to monkey/monkey_island/cc/resources/pba_file_upload.py index b8fcf9a90..29f5271f2 100644 --- a/monkey/monkey_island/cc/resources/file_upload.py +++ b/monkey/monkey_island/cc/resources/pba_file_upload.py @@ -4,7 +4,6 @@ from cc.services.config import ConfigService, WINDOWS_PBA_INFO, LINUX_PBA_INFO import os from werkzeug.utils import secure_filename import logging -from cc.database import mongo import copy LOG = logging.getLogger(__name__) diff --git a/monkey/monkey_island/cc/services/config.py b/monkey/monkey_island/cc/services/config.py index 61d081867..fbcf4d7a0 100644 --- a/monkey/monkey_island/cc/services/config.py +++ b/monkey/monkey_island/cc/services/config.py @@ -45,6 +45,7 @@ WINDOWS_PBA_INFO.append('windows_file_info') LINUX_PBA_INFO = copy.deepcopy(PBA_CONF_PATH) LINUX_PBA_INFO.append('linux_file_info') + class ConfigService: default_config = None @@ -157,7 +158,7 @@ class ConfigService: @staticmethod def update_config(config_json, should_encrypt): - # Island file upload on file_upload endpoint and sets correct config there + # Island file upload happens on pba_file_upload endpoint and config is set there ConfigService.keep_PBA_files(config_json) if should_encrypt: try: @@ -173,7 +174,7 @@ class ConfigService: def keep_PBA_files(config_json): """ file_upload endpoint handles file upload and sets config asynchronously. - This brings file info in config up to date. + This saves file info from being overridden. """ if ConfigService.get_config(): linux_info = ConfigService.get_config_value(LINUX_PBA_INFO) @@ -250,6 +251,7 @@ class ConfigService: @staticmethod def r_get_properties(schema): + """ Recursively gets all nested properties in schema""" if "default" in schema: return schema["default"] if "properties" in schema: diff --git a/monkey/monkey_island/cc/services/report.py b/monkey/monkey_island/cc/services/report.py index 71e443716..ed00b2fa0 100644 --- a/monkey/monkey_island/cc/services/report.py +++ b/monkey/monkey_island/cc/services/report.py @@ -132,7 +132,8 @@ class ReportService: (NodeService.get_displayed_node_by_id(edge['from'], True) for edge in EdgeService.get_displayed_edges_by_to(node['id'], True)))), 'services': node['services'], - 'domain_name': node['domain_name'] + 'domain_name': node['domain_name'], + 'pba_results': node['pba_results'] if 'pba_results' in node else 'None' }) logger.info('Scanned nodes generated for reporting') @@ -156,7 +157,6 @@ class ReportService: 'exploits': list(set( [ReportService.EXPLOIT_DISPLAY_DICT[exploit['exploiter']] for exploit in monkey['exploits'] if exploit['result']])), - 'pba_results': monkey['pba_results'] if 'pba_results' in monkey else 'None' } for monkey in exploited] diff --git a/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js b/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js index 643004bd3..938961c99 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js @@ -462,7 +462,7 @@ class ReportPageComponent extends AuthComponent {
- +
diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/PostBreach.js b/monkey/monkey_island/cc/ui/src/components/report-components/PostBreach.js index 55f556251..b6e36f902 100644 --- a/monkey/monkey_island/cc/ui/src/components/report-components/PostBreach.js +++ b/monkey/monkey_island/cc/ui/src/components/report-components/PostBreach.js @@ -21,13 +21,6 @@ let renderPostBreach = function (machine, pbaList) { } }; -let renderMachine = function (val) { - if (val.pba_results.length === 0){ - return - } - return
{val.label} {renderIpAddresses(val)}
-}; - const columns = [ { Header: 'Post breach actions',