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

136 lines
3.3 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Account Tampering - Suspicious Failed Logon Reasons\n",
"This method uses uncommon error codes on failed logons to determine suspicious activity and tampering with accounts that have been disabled or somehow restricted."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: Account Tampering - Suspicious Failed Logon Reasons\n",
" id: 9eb99343-d336-4020-a3cd-67f3819e68ee\n",
" description: This method uses uncommon error codes on failed logons to determine\n",
" suspicious activity and tampering with accounts that have been disabled or somehow\n",
" restricted.\n",
" author: Florian Roth\n",
" modified: 2019/03/01\n",
" references:\n",
" - https://twitter.com/SBousseaden/status/1101431884540710913\n",
" tags:\n",
" - attack.persistence\n",
" - attack.privilege_escalation\n",
" - attack.t1078\n",
" logsource:\n",
" product: windows\n",
" service: security\n",
" category: null\n",
" detection:\n",
" selection:\n",
" EventID:\n",
" - 4625\n",
" - 4776\n",
" Status:\n",
" - '0xC0000072'\n",
" - '0xC000006F'\n",
" - '0xC0000070'\n",
" - '0xC0000413'\n",
" - '0xC000018C'\n",
" - '0xC000015B'\n",
" condition: selection\n",
" falsepositives:\n",
" - User using a disabled account\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-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:(\"4625\" OR \"4776\") AND event_status:(\"0xC0000072\" OR \"0xC000006F\" OR \"0xC0000070\" OR \"0xC0000413\" OR \"0xC000018C\" OR \"0xC000015B\"))')\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
}