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

131 lines
2.8 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Control Panel Items\n",
"Detects the use of a control panel item (.cpl) outside of the System32 folder"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: Control Panel Items\n",
" id: 0ba863e6-def5-4e50-9cea-4dd8c7dc46a4\n",
" status: experimental\n",
" description: Detects the use of a control panel item (.cpl) outside of the System32\n",
" folder\n",
" reference:\n",
" - https://attack.mitre.org/techniques/T1196/\n",
" tags:\n",
" - attack.execution\n",
" - attack.t1196\n",
" - attack.defense_evasion\n",
" author: Kyaw Min Thein\n",
" date: 2019/08/27\n",
" level: critical\n",
" logsource:\n",
" product: windows\n",
" category: process_creation\n",
" service: null\n",
" detection:\n",
" selection:\n",
" CommandLine: '*.cpl'\n",
" filter:\n",
" CommandLine:\n",
" - '*\\System32\\\\*'\n",
" - '*%System%*'\n",
" condition: selection and not filter\n",
" falsepositives:\n",
" - Unknown\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_command_line.keyword:*.cpl AND (NOT (process_command_line.keyword:(*\\\\System32\\\\* OR *%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
}