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

127 lines
2.7 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Access to ADMIN$ Share\n",
"Detects access to $ADMIN share"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: Access to ADMIN$ Share\n",
" id: 098d7118-55bc-4912-a836-dc6483a8d150\n",
" description: Detects access to $ADMIN share\n",
" tags:\n",
" - attack.lateral_movement\n",
" - attack.t1077\n",
" status: experimental\n",
" author: Florian Roth\n",
" logsource:\n",
" product: windows\n",
" service: security\n",
" definition: The advanced audit policy setting \"Object Access > Audit File Share\"\n",
" must be configured for Success/Failure\n",
" category: null\n",
" detection:\n",
" selection:\n",
" EventID: 5140\n",
" ShareName: Admin$\n",
" filter:\n",
" SubjectUserName: '*$'\n",
" condition: selection and not filter\n",
" falsepositives:\n",
" - Legitimate administrative activity\n",
" level: low\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-endpoint-winevent-security-*', 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='((event_id:\"5140\" AND share_name:\"Admin$\") AND (NOT (user_name.keyword:*$)))')\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
}