diff --git a/monkey/infection_monkey/dropper.py b/monkey/infection_monkey/dropper.py index 02bd649c2..cc065a745 100644 --- a/monkey/infection_monkey/dropper.py +++ b/monkey/infection_monkey/dropper.py @@ -51,7 +51,6 @@ class MonkeyDrops(object): LOG.debug("Dropper is running with config:\n%s", pprint.pformat(self._config)) def start(self): - if self._config['destination_path'] is None: LOG.error("No destination path specified") return False diff --git a/monkey/infection_monkey/main.py b/monkey/infection_monkey/main.py index 6e06d4aa6..b8e292243 100644 --- a/monkey/infection_monkey/main.py +++ b/monkey/infection_monkey/main.py @@ -98,6 +98,7 @@ def main(): except OSError: pass LOG_CONFIG['handlers']['file']['filename'] = log_path + # noinspection PyUnresolvedReferences LOG_CONFIG['root']['handlers'].append('file') else: del LOG_CONFIG['handlers']['file'] diff --git a/monkey/monkey_island/cc/resources/monkey.py b/monkey/monkey_island/cc/resources/monkey.py index 7eb7ecc69..057ebf149 100644 --- a/monkey/monkey_island/cc/resources/monkey.py +++ b/monkey/monkey_island/cc/resources/monkey.py @@ -2,11 +2,12 @@ import json from datetime import datetime import dateutil.parser -from flask import request import flask_restful +from flask import request from monkey_island.cc.database import mongo from monkey_island.cc.services.config import ConfigService +from monkey_island.cc.services.monkey_timeout import start_timer_decorator from monkey_island.cc.services.node import NodeService __author__ = 'Barak' @@ -17,6 +18,7 @@ __author__ = 'Barak' class Monkey(flask_restful.Resource): # Used by monkey. can't secure. + @start_timer_decorator def get(self, guid=None, **kw): NodeService.update_dead_monkeys() # refresh monkeys status if not guid: @@ -88,7 +90,7 @@ class Monkey(flask_restful.Resource): parent_to_add = (exploit_telem[0].get('monkey_guid'), exploit_telem[0].get('data').get('exploiter')) else: parent_to_add = (parent, None) - elif (not parent or parent == monkey_json.get('guid')) and 'ip_addresses' in monkey_json: + elif (not parent or parent == monkey_json.get('guid')) and 'ip_addresses' in monkey_json: exploit_telem = [x for x in mongo.db.telemetry.find({'telem_type': {'$eq': 'exploit'}, 'data.result': {'$eq': True}, 'data.machine.ip_addr': {'$in': monkey_json['ip_addresses']}})] diff --git a/monkey/monkey_island/cc/services/monkey_timeout.py b/monkey/monkey_island/cc/services/monkey_timeout.py new file mode 100644 index 000000000..2c3bf4637 --- /dev/null +++ b/monkey/monkey_island/cc/services/monkey_timeout.py @@ -0,0 +1,22 @@ +import functools +import pprint + + +def start_timer_decorator(func): + @functools.wraps(func) + def wrapper_decorator(*args, **kwargs): + print("ib4get - start the timer, folks. \nargs:") + pprint.pprint(args) + print("kwargs: ") + pprint.pprint(kwargs) + value = func(*args, **kwargs) + print("after party woohoo") + + try: + print("Starting timer on " + kwargs['guid']) + except KeyError as e: + print("NO GUID AVAILABLE") + + return value + + return wrapper_decorator