From 308a1e354772907361c0e0d813f262f5d3344fe4 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Tue, 5 Mar 2019 10:22:45 +0200 Subject: [PATCH] Added simple telemetry feed --- monkey/infection_monkey/post_breach/pba.py | 7 ++++++- monkey/infection_monkey/post_breach/post_breach_handler.py | 2 +- monkey/monkey_island/cc/resources/telemetry_feed.py | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/monkey/infection_monkey/post_breach/pba.py b/monkey/infection_monkey/post_breach/pba.py index e8954fb87..32284acb4 100644 --- a/monkey/infection_monkey/post_breach/pba.py +++ b/monkey/infection_monkey/post_breach/pba.py @@ -1,6 +1,7 @@ import logging from infection_monkey.control import ControlClient import subprocess +import socket LOG = logging.getLogger(__name__) @@ -20,9 +21,13 @@ class PBA(object): command = self.windows_command exec_funct = self.execute_win if command: + hostname = socket.gethostname() ControlClient.send_telemetry('post_breach', {'command': command, 'output': exec_funct(), - 'name': self.name}) + 'name': self.name, + 'hostname': hostname, + 'ip': socket.gethostbyname(hostname) + }) def execute_linux(self): # Default linux PBA execution function. Override if additional functionality is needed diff --git a/monkey/infection_monkey/post_breach/post_breach_handler.py b/monkey/infection_monkey/post_breach/post_breach_handler.py index af494256a..c94ed1bc5 100644 --- a/monkey/infection_monkey/post_breach/post_breach_handler.py +++ b/monkey/infection_monkey/post_breach/post_breach_handler.py @@ -34,7 +34,7 @@ class PostBreach(object): def get_custom(config): custom_list = [] file_pba = FileExecution() - command_pba = PBA(name="Custom post breach action") + command_pba = PBA(name="Custom") post_breach = config.custom_post_breach linux_command = post_breach['linux'] windows_command = post_breach['windows'] diff --git a/monkey/monkey_island/cc/resources/telemetry_feed.py b/monkey/monkey_island/cc/resources/telemetry_feed.py index 05ed841a6..8286bba00 100644 --- a/monkey/monkey_island/cc/resources/telemetry_feed.py +++ b/monkey/monkey_island/cc/resources/telemetry_feed.py @@ -82,7 +82,9 @@ class TelemetryFeed(flask_restful.Resource): @staticmethod def get_post_breach_telem_brief(telem): - pass + return '%s post breach action executed on %s (%s) machine' % (telem['data']['name'], + telem['data']['hostname'], + telem['data']['ip']) TELEM_PROCESS_DICT = \