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

151 lines
3.6 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Antivirus Relevant File Paths Alerts\n",
"Detects an Antivirus alert in a highly relevant file path or with a relevant file name"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: Antivirus Relevant File Paths Alerts\n",
" id: c9a88268-0047-4824-ba6e-4d81ce0b907c\n",
" description: Detects an Antivirus alert in a highly relevant file path or with a\n",
" relevant file name\n",
" date: 2018/09/09\n",
" modified: 2019/10/04\n",
" author: Florian Roth\n",
" references:\n",
" - https://www.nextron-systems.com/2018/09/08/antivirus-event-analysis-cheat-sheet-v1-4/\n",
" logsource:\n",
" product: antivirus\n",
" service: null\n",
" category: null\n",
" detection:\n",
" selection:\n",
" FileName:\n",
" - C:\\Windows\\Temp\\\\*\n",
" - C:\\Temp\\\\*\n",
" - '*\\\\Client\\\\*'\n",
" - C:\\PerfLogs\\\\*\n",
" - C:\\Users\\Public\\\\*\n",
" - C:\\Users\\Default\\\\*\n",
" - '*.ps1'\n",
" - '*.vbs'\n",
" - '*.bat'\n",
" - '*.chm'\n",
" - '*.xml'\n",
" - '*.txt'\n",
" - '*.jsp'\n",
" - '*.jspx'\n",
" - '*.asp'\n",
" - '*.aspx'\n",
" - '*.php'\n",
" - '*.war'\n",
" - '*.hta'\n",
" - '*.lnk'\n",
" - '*.scf'\n",
" - '*.sct'\n",
" - '*.vbe'\n",
" - '*.wsf'\n",
" - '*.wsh'\n",
" condition: selection\n",
" fields:\n",
" - Signature\n",
" - User\n",
" falsepositives:\n",
" - Unlikely\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='file_name.keyword:(C\\:\\\\Windows\\\\Temp\\\\* OR C\\:\\\\Temp\\\\* OR *\\\\Client\\\\* OR C\\:\\\\PerfLogs\\\\* OR C\\:\\\\Users\\\\Public\\\\* OR C\\:\\\\Users\\\\Default\\\\* OR *.ps1 OR *.vbs OR *.bat OR *.chm OR *.xml OR *.txt OR *.jsp OR *.jspx OR *.asp OR *.aspx OR *.php OR *.war OR *.hta OR *.lnk OR *.scf OR *.sct OR *.vbe OR *.wsf OR *.wsh)')\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
}