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

129 lines
2.9 KiB
Plaintext
Raw Normal View History

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Service Execution\n",
"Detects manual service execution (start) via system utilities"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: Service Execution\n",
" id: 2a072a96-a086-49fa-bcb5-15cc5a619093\n",
" status: experimental\n",
" description: Detects manual service execution (start) via system utilities\n",
" author: Timur Zinniatullin, Daniil Yugoslavskiy, oscd.community\n",
" date: 2019/10/21\n",
" modified: 2019/11/04\n",
" references:\n",
" - https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1035/T1035.yaml\n",
" logsource:\n",
" category: process_creation\n",
" product: windows\n",
" service: null\n",
" detection:\n",
" selection:\n",
" Image|endswith:\n",
" - \\net.exe\n",
" - \\net1.exe\n",
" CommandLine|contains: ' start '\n",
" condition: selection\n",
" falsepositives:\n",
" - Legitimate administrator or user executes a service for legitimate reason\n",
" level: low\n",
" tags:\n",
" - attack.execution\n",
" - attack.t1035\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:(*\\\\net.exe OR *\\\\net1.exe) AND process_command_line.keyword:*\\ start\\ *)')\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
}