HELK/docker/helk-jupyter/notebooks/sigma/appframework_spring_excepti...

128 lines
3.0 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Spring framework exceptions\n",
"Detects suspicious Spring framework exceptions that could indicate exploitation attempts"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: Spring framework exceptions\n",
" id: ae48ab93-45f7-4051-9dfe-5d30a3f78e33\n",
" description: Detects suspicious Spring framework exceptions that could indicate\n",
" exploitation attempts\n",
" author: Thomas Patzke\n",
" references:\n",
" - https://docs.spring.io/spring-security/site/docs/current/apidocs/overview-tree.html\n",
" logsource:\n",
" category: application\n",
" product: spring\n",
" service: null\n",
" detection:\n",
" keywords:\n",
" - AccessDeniedException\n",
" - CsrfException\n",
" - InvalidCsrfTokenException\n",
" - MissingCsrfTokenException\n",
" - CookieTheftException\n",
" - InvalidCookieException\n",
" - RequestRejectedException\n",
" condition: keywords\n",
" falsepositives:\n",
" - Application bugs\n",
" - Penetration testing\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:(*AccessDeniedException* OR *CsrfException* OR *InvalidCsrfTokenException* OR *MissingCsrfTokenException* OR *CookieTheftException* OR *InvalidCookieException* OR *RequestRejectedException*)')\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
}