Exemplo n.º 1
0
    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})
Exemplo n.º 2
0
    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