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

127 lines
3.0 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Terminal Service Process Spawn\n",
"Detects a process spawned by the terminal service server process (this could be an indicator for an exploitation of CVE-2019-0708)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: Terminal Service Process Spawn\n",
" id: 1012f107-b8f1-4271-af30-5aed2de89b39\n",
" status: experimental\n",
" description: Detects a process spawned by the terminal service server process (this\n",
" could be an indicator for an exploitation of CVE-2019-0708)\n",
" references:\n",
" - https://securingtomorrow.mcafee.com/other-blogs/mcafee-labs/rdp-stands-for-really-do-patch-understanding-the-wormable-rdp-vulnerability-cve-2019-0708/\n",
" author: Florian Roth\n",
" date: 2019/05/22\n",
" tags:\n",
" - car.2013-07-002\n",
" logsource:\n",
" product: windows\n",
" category: process_creation\n",
" service: null\n",
" detection:\n",
" selection:\n",
" ParentCommandLine: '*\\svchost.exe*termsvcs'\n",
" filter:\n",
" Image: '*\\rdpclip.exe'\n",
" condition: selection and not filter\n",
" falsepositives:\n",
" - Unknown\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_parent_command_line.keyword:*\\\\svchost.exe*termsvcs AND (NOT (process_path.keyword:*\\\\rdpclip.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
}