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

129 lines
3.0 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Windows Registry Persistence - COM key linking\n",
"Detects COM object hijacking via TreatAs subkey"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: Windows Registry Persistence - COM key linking\n",
" id: 9b0f8a61-91b2-464f-aceb-0527e0a45020\n",
" status: experimental\n",
" description: Detects COM object hijacking via TreatAs subkey\n",
" references:\n",
" - https://bohops.com/2018/08/18/abusing-the-com-registry-structure-part-2-loading-techniques-for-evasion-and-persistence/\n",
" author: Kutepov Anton, oscd.community\n",
" date: 2019/10/23\n",
" modified: 2019/11/07\n",
" tags:\n",
" - attack.persistence\n",
" - attack.t1122\n",
" logsource:\n",
" product: windows\n",
" service: sysmon\n",
" category: null\n",
" detection:\n",
" selection:\n",
" EventID: 12\n",
" TargetObject|startswith: HKU\\\n",
" TargetObject|contains: _Classes\\CLSID\\\n",
" TargetObject|endswith: \\TreatAs\n",
" condition: selection\n",
" falsepositives:\n",
" - Maybe some system utilities in rare cases use linking keys for backward compability\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-sysmon-*', 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:\"12\" AND registry_key_path:\"HKU\\*\" AND registry_key_path.keyword:*_Classes\\\\CLSID\\* AND registry_key_path.keyword:*\\\\TreatAs)')\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
}