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

127 lines
2.9 KiB
Plaintext
Raw Normal View History

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# StoneDrill Service Install\n",
"This method detects a service install of the malicious Microsoft Network Realtime Inspection Service service described in StoneDrill report by Kaspersky"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: StoneDrill Service Install\n",
" id: 9e987c6c-4c1e-40d8-bd85-dd26fba8fdd6\n",
" description: This method detects a service install of the malicious Microsoft Network\n",
" Realtime Inspection Service service described in StoneDrill report by Kaspersky\n",
" author: Florian Roth\n",
" references:\n",
" - https://securelist.com/blog/research/77725/from-shamoon-to-stonedrill/\n",
" tags:\n",
" - attack.persistence\n",
" - attack.g0064\n",
" - attack.t1050\n",
" logsource:\n",
" product: windows\n",
" service: system\n",
" category: null\n",
" detection:\n",
" selection:\n",
" EventID: 7045\n",
" ServiceName: NtsSrv\n",
" ServiceFileName: '* LocalService'\n",
" condition: selection\n",
" falsepositives:\n",
" - Unlikely\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-endpoint-winevent-system-*', 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:\"7045\" AND service_name:\"NtsSrv\" AND service_image_path.keyword:*\\ LocalService)')\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
}