HELK/docker/helk-jupyter/notebooks/sigma/lnx_susp_named.ipynb

125 lines
2.9 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Suspicious Named Error\n",
"Detects suspicious DNS error messages that indicate a fatal or suspicious error that could be caused by exploiting attempts"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: Suspicious Named Error\n",
" id: c8e35e96-19ce-4f16-aeb6-fd5588dc5365\n",
" status: experimental\n",
" description: Detects suspicious DNS error messages that indicate a fatal or suspicious\n",
" error that could be caused by exploiting attempts\n",
" references:\n",
" - https://github.com/ossec/ossec-hids/blob/master/etc/rules/named_rules.xml\n",
" author: Florian Roth\n",
" date: 2018/02/20\n",
" logsource:\n",
" product: linux\n",
" service: syslog\n",
" category: null\n",
" detection:\n",
" keywords:\n",
" - '* dropping source port zero packet from *'\n",
" - '* denied AXFR from *'\n",
" - '* exiting (due to fatal error)*'\n",
" condition: keywords\n",
" falsepositives:\n",
" - Unknown\n",
" level: high\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='\\*.keyword:(*\\ dropping\\ source\\ port\\ zero\\ packet\\ from\\ * OR *\\ denied\\ AXFR\\ from\\ * OR *\\ exiting\\ \\(due\\ to\\ fatal\\ error\\)*)')\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
}