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

131 lines
3.1 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Whoami Execution\n",
"Detects the execution of whoami, which is often used by attackers after exloitation / privilege escalation but rarely used by administrators"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: Whoami Execution\n",
" id: e28a5a99-da44-436d-b7a0-2afc20a5f413\n",
" status: experimental\n",
" description: Detects the execution of whoami, which is often used by attackers after\n",
" exloitation / privilege escalation but rarely used by administrators\n",
" references:\n",
" - https://brica.de/alerts/alert/public/1247926/agent-tesla-keylogger-delivered-inside-a-power-iso-daa-archive/\n",
" - https://app.any.run/tasks/7eaba74e-c1ea-400f-9c17-5e30eee89906/\n",
" author: Florian Roth\n",
" date: 2018/08/13\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: '*\\whoami.exe'\n",
" selection2:\n",
" OriginalFileName: whoami.exe\n",
" condition: selection or selection2\n",
" falsepositives:\n",
" - Admin activity\n",
" - Scripts and administrative tools used in the monitored environment\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='(process_path.keyword:*\\\\whoami.exe OR file_name_original:\"whoami.exe\")')\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
}