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

134 lines
3.2 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# CACTUSTORCH Remote Thread Creation\n",
"Detects remote thread creation from CACTUSTORCH as described in references."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: CACTUSTORCH Remote Thread Creation\n",
" id: 2e4e488a-6164-4811-9ea1-f960c7359c40\n",
" description: Detects remote thread creation from CACTUSTORCH as described in references.\n",
" references:\n",
" - https://twitter.com/SBousseaden/status/1090588499517079552\n",
" - https://github.com/mdsecactivebreach/CACTUSTORCH\n",
" status: experimental\n",
" author: '@SBousseaden (detection), Thomas Patzke (rule)'\n",
" logsource:\n",
" product: windows\n",
" service: sysmon\n",
" category: null\n",
" detection:\n",
" selection:\n",
" EventID: 8\n",
" SourceImage:\n",
" - '*\\System32\\cscript.exe'\n",
" - '*\\System32\\wscript.exe'\n",
" - '*\\System32\\mshta.exe'\n",
" - '*\\winword.exe'\n",
" - '*\\excel.exe'\n",
" TargetImage: '*\\SysWOW64\\\\*'\n",
" StartModule: null\n",
" condition: selection\n",
" tags:\n",
" - attack.execution\n",
" - attack.t1055\n",
" - attack.t1064\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-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:\"8\" AND process_path.keyword:(*\\\\System32\\\\cscript.exe OR *\\\\System32\\\\wscript.exe OR *\\\\System32\\\\mshta.exe OR *\\\\winword.exe OR *\\\\excel.exe) AND target_process_path.keyword:*\\\\SysWOW64\\\\* AND NOT _exists_:thread_start_module)')\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
}