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

127 lines
2.9 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Whoami as LOCAL_SYSTEM\n",
"Detects the execution of whoami as LOCAL_SYSTEM, often used after privilege escalation by attackers who want to evaluate the new user context"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: Whoami as LOCAL_SYSTEM\n",
" id: 1453b1a4-261b-4daf-afe1-2a400a838b5c\n",
" status: experimental\n",
" description: Detects the execution of whoami as LOCAL_SYSTEM, often used after privilege\n",
" escalation by attackers who want to evaluate the new user context\n",
" author: Florian Roth\n",
" date: 2019/12/22\n",
" tags:\n",
" - attack.discovery\n",
" - attack.t1033\n",
" - car.2016-03-001\n",
" logsource:\n",
" category: process_creation\n",
" product: windows\n",
" service: null\n",
" detection:\n",
" selection:\n",
" Image|contains: \\whoami.exe\n",
" User: NT AUTHORITY\\SYSTEM\n",
" condition: selection\n",
" falsepositives:\n",
" - Admin activity\n",
" - Scripts and administrative tools used in the monitored environment\n",
" level: critical\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='(process_path.keyword:*\\\\whoami.exe* AND user_account:\"NT\\ AUTHORITY\\\\SYSTEM\")')\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
}