Пример #1
0
    async def handle_event(self, request):
        data = await request.read()
        try:
            data = json.loads(data.decode('utf-8'))
            path = yarl.unquote(data['path'])
        except (TypeError, ValueError, KeyError) as error:
            self.logger.error('error parsing request: %s', data)
            response_msg = self._make_response(msg=type(error).__name__)
        else:
            session = await self.session_manager.add_or_update_session(
                data, self.redis_client)
            self.logger.info('Requested path %s', path)
            await self.dorks.extract_path(path, self.redis_client)
            detection = await self.base_handler.handle(data, session)
            session.set_attack_type(path, detection["name"])

            response_msg = self._make_response(
                msg=dict(detection=detection, sess_uuid=session.get_uuid()))
            self.logger.info('TANNER response %s', response_msg)

            session_data = data
            session_data['response_msg'] = response_msg

            # Log to Mongo
            if TannerConfig.get('MONGO', 'enabled') == 'True':
                db = mongo_report()
                session_id = db.create_session(session_data)
                self.logger.info(
                    "Writing session to DB: {}".format(session_id))

            if TannerConfig.get('LOCALLOG', 'enabled') == 'True':
                lr = local_report()
                lr.create_session(session_data)
        return web.json_response(response_msg)
Пример #2
0
    def handle_event(self, data, redis_client):
        try:
            data = json.loads(data.decode("utf-8"))
            path = unquote(data["path"])
        except (TypeError, ValueError, KeyError) as error:
            self.logger.error("error parsing request: %s", data)
            response_msg = self._make_response(msg=type(error).__name__)
        else:
            session = yield from HttpRequestHandler.session_manager.add_or_update_session(data, self.redis_client)
            self.logger.info("Requested path %s", path)
            yield from self.dorks.extract_path(path, redis_client)
            detection = yield from self.base_handler.handle(data, session, path)
            session.set_attack_type(path, detection["name"])
            response_msg = self._make_response(msg=dict(detection=detection))
            self.logger.info("TANNER response %s", response_msg)

            session_data = data
            session_data["response_msg"] = response_msg

            # Log to Mongo
            if config.TannerConfig.config["MONGO"]["enabled"] == "True":

                db = mongo_report()
                session_id = db.create_session(session_data)
                self.logger.info("Writing session to DB: {}".format(session_id))

            if config.TannerConfig.config["LOCALLOG"]["enabled"] == "True":
                lr = local_report()
                lr.create_session(session_data)

            return response_msg
Пример #3
0
    async def handle_event(self, request):
        data = await request.read()
        try:
            data = json.loads(data.decode("utf-8"))
            path = yarl.URL(data["path"]).human_repr()
        except (TypeError, ValueError, KeyError) as error:
            self.logger.exception("error parsing request: %s", data)
            response_msg = self._make_response(msg=type(error).__name__)
        else:
            session, _ = await self.session_manager.add_or_update_session(
                data, self.redis_client)
            self.logger.info("Requested path %s", path)
            await self.dorks.extract_path(path, self.redis_client)
            detection = await self.base_handler.handle(data, session)
            session.set_attack_type(path, detection["name"])

            response_msg = self._make_response(
                msg=dict(detection=detection, sess_uuid=session.get_uuid()))
            self.logger.info("TANNER response %s", response_msg)

            session_data = data
            session_data["response_msg"] = response_msg

            # Log to Mongo
            if TannerConfig.get("MONGO", "enabled") is True:
                db = mongo_report()
                session_id = db.create_session(session_data)
                self.logger.info(
                    "Writing session to DB: {}".format(session_id))

            # Log to hpfeeds
            if TannerConfig.get("HPFEEDS", "enabled") is True:
                if self.hpf.connected():
                    self.hpf.create_session(session_data)

            if TannerConfig.get("LOCALLOG", "enabled") is True:
                lr = local_report()
                lr.create_session(session_data)

        return web.json_response(response_msg)
Пример #4
0
    async def handle_event(self, request):
        data = await request.read()
        try:
            data = json.loads(data.decode('utf-8'))
            path = yarl.URL(data['path']).human_repr()
        except (TypeError, ValueError, KeyError) as error:
            self.logger.exception('error parsing request: %s', data)
            response_msg = self._make_response(msg=type(error).__name__)
        else:
            session = await self.session_manager.add_or_update_session(
                data, self.redis_client
            )
            self.logger.info('Requested path %s', path)
            await self.dorks.extract_path(path, self.redis_client)
            detection = await self.base_handler.handle(data, session)
            session.set_attack_type(path, detection["name"])

            response_msg = self._make_response(msg=dict(detection=detection, sess_uuid=session.get_uuid()))
            self.logger.info('TANNER response %s', response_msg)

            session_data = data
            session_data['response_msg'] = response_msg

            # Log to Mongo
            if TannerConfig.get('MONGO', 'enabled') is True:
                db = mongo_report()
                session_id = db.create_session(session_data)
                self.logger.info("Writing session to DB: {}".format(session_id))

            # Log to hpfeeds
            if TannerConfig.get('HPFEEDS', 'enabled') is True:
                if self.hpf.connected():
                    self.hpf.create_session(session_data)

            if TannerConfig.get('LOCALLOG', 'enabled') is True:
                lr = local_report()
                lr.create_session(session_data)

        return web.json_response(response_msg)