def post(self): telemetry_json = json.loads(request.data) telemetry_json['data'] = json.loads(telemetry_json['data']) telemetry_json['timestamp'] = datetime.now() telemetry_json['command_control_channel'] = {'src': request.remote_addr, 'dst': request.host} # Monkey communicated, so it's alive. Update the TTL. Monkey.get_single_monkey_by_guid(telemetry_json['monkey_guid']).renew_ttl() monkey = NodeService.get_monkey_by_guid(telemetry_json['monkey_guid']) NodeService.update_monkey_modify_time(monkey["_id"]) process_telemetry(telemetry_json) telem_id = mongo.db.telemetry.insert(telemetry_json) return mongo.db.telemetry.find_one_or_404({"_id": telem_id})
def process_aws_telemetry(collector_results, monkey_guid): relevant_monkey = Monkey.get_single_monkey_by_guid(monkey_guid) if "instance_id" in collector_results: instance_id = collector_results["instance_id"] relevant_monkey.aws_instance_id = instance_id relevant_monkey.save() logger.debug("Updated Monkey {} with aws instance id {}".format( str(relevant_monkey), instance_id))
def post(self): telemetry_json = json.loads(request.data) telemetry_json["data"] = json.loads(telemetry_json["data"]) telemetry_json["timestamp"] = datetime.now() telemetry_json["command_control_channel"] = { "src": request.remote_addr, "dst": request.host, } # Monkey communicated, so it's alive. Update the TTL. Monkey.get_single_monkey_by_guid( telemetry_json["monkey_guid"]).renew_ttl() monkey = NodeService.get_monkey_by_guid(telemetry_json["monkey_guid"]) NodeService.update_monkey_modify_time(monkey["_id"]) process_telemetry(telemetry_json) save_telemetry(telemetry_json) return {}, 201
def process_hostname_telemetry(collector_results, monkey_guid): Monkey.get_single_monkey_by_guid(monkey_guid).set_hostname(collector_results["hostname"])
def process_environment_telemetry(collector_results, monkey_guid): relevant_monkey = Monkey.get_single_monkey_by_guid(monkey_guid) relevant_monkey.environment = collector_results["environment"] relevant_monkey.save() logger.debug("Updated Monkey {} with env {}".format( str(relevant_monkey), collector_results))