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

132 lines
3.0 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Interactive Logon to Server Systems\n",
"Detects interactive console logons to"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: Interactive Logon to Server Systems\n",
" id: 3ff152b2-1388-4984-9cd9-a323323fdadf\n",
" description: Detects interactive console logons to\n",
" author: Florian Roth\n",
" tags:\n",
" - attack.lateral_movement\n",
" - attack.t1078\n",
" logsource:\n",
" product: windows\n",
" service: security\n",
" category: null\n",
" detection:\n",
" selection:\n",
" EventID:\n",
" - 528\n",
" - 529\n",
" - 4624\n",
" - 4625\n",
" LogonType: 2\n",
" ComputerName:\n",
" - '%ServerSystems%'\n",
" - '%DomainControllers%'\n",
" filter:\n",
" LogonProcessName: Advapi\n",
" ComputerName: '%Workstations%'\n",
" condition: selection and not filter\n",
" falsepositives:\n",
" - Administrative activity via KVM or ILO board\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-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:(\"528\" OR \"529\" OR \"4624\" OR \"4625\") AND logon_type:\"2\" AND host_name:(\"%ServerSystems%\" OR \"%DomainControllers%\")) AND (NOT (logon_process_name:\"Advapi\" AND host_name:\"%Workstations%\")))')\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
}