{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Apache Threading Error\n", "Detects an issue in apache logs that reports threading related errors" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Rule Content\n", "```\n", "- title: Apache Threading Error\n", " id: e9a2b582-3f6a-48ac-b4a1-6849cdc50b3c\n", " status: experimental\n", " description: Detects an issue in apache logs that reports threading related errors\n", " author: Florian Roth\n", " date: 2019/01/22\n", " references:\n", " - https://github.com/hannob/apache-uaf/blob/master/README.md\n", " logsource:\n", " product: apache\n", " service: null\n", " category: null\n", " detection:\n", " keywords:\n", " - '__pthread_tpp_change_priority: Assertion `new_prio == -1 || (new_prio >= fifo_min_prio\n", " && new_prio <= fifo_max_prio)'\n", " condition: keywords\n", " falsepositives:\n", " - https://bz.apache.org/bugzilla/show_bug.cgi?id=46185\n", " level: medium\n", "\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Querying Elasticsearch" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Import Libraries" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from elasticsearch import Elasticsearch\n", "from elasticsearch_dsl import Search\n", "import pandas as pd" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Initialize Elasticsearch client" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "es = Elasticsearch(['http://helk-elasticsearch:9200'])\n", "searchContext = Search(using=es, index='logs-*', doc_type='doc')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Run Elasticsearch Query" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "s = searchContext.query('query_string', query='__pthread_tpp_change_priority\\:\\ Assertion\\ `new_prio\\ \\=\\=\\ \\-1\\ \\||\\ \\(new_prio\\ \\=\\ fifo_min_prio\\ \\&&\\ new_prio\\ \\=\\ fifo_max_prio\\)')\n", "response = s.execute()\n", "if response.success():\n", " df = pd.DataFrame((d.to_dict() for d in s.scan()))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Show Results" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df.head()" ] } ], "metadata": {}, "nbformat": 4, "nbformat_minor": 4 }