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

133 lines
3.6 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Suspicious SSHD Error\n",
"Detects suspicious SSH / SSHD 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 SSHD Error\n",
" id: e76b413a-83d0-4b94-8e4c-85db4a5b8bdc\n",
" description: Detects suspicious SSH / SSHD error messages that indicate a fatal\n",
" or suspicious error that could be caused by exploiting attempts\n",
" references:\n",
" - https://github.com/openssh/openssh-portable/blob/master/ssherr.c\n",
" - https://github.com/ossec/ossec-hids/blob/master/etc/rules/sshd_rules.xml\n",
" author: Florian Roth\n",
" date: 2017/06/30\n",
" logsource:\n",
" product: linux\n",
" service: sshd\n",
" category: null\n",
" detection:\n",
" keywords:\n",
" - '*unexpected internal error*'\n",
" - '*unknown or unsupported key type*'\n",
" - '*invalid certificate signing key*'\n",
" - '*invalid elliptic curve value*'\n",
" - '*incorrect signature*'\n",
" - '*error in libcrypto*'\n",
" - '*unexpected bytes remain after decoding*'\n",
" - '*fatal: buffer_get_string: bad string*'\n",
" - '*Local: crc32 compensation attack*'\n",
" - '*bad client public DH value*'\n",
" - '*Corrupted MAC on input*'\n",
" condition: keywords\n",
" falsepositives:\n",
" - Unknown\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='\\*.keyword:(*unexpected\\ internal\\ error* OR *unknown\\ or\\ unsupported\\ key\\ type* OR *invalid\\ certificate\\ signing\\ key* OR *invalid\\ elliptic\\ curve\\ value* OR *incorrect\\ signature* OR *error\\ in\\ libcrypto* OR *unexpected\\ bytes\\ remain\\ after\\ decoding* OR *fatal\\:\\ buffer_get_string\\:\\ bad\\ string* OR *Local\\:\\ crc32\\ compensation\\ attack* OR *bad\\ client\\ public\\ DH\\ value* OR *Corrupted\\ MAC\\ on\\ input*)')\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
}