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

144 lines
3.5 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Malicious Named Pipe\n",
"Detects the creation of a named pipe used by known APT malware"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: Malicious Named Pipe\n",
" id: fe3ac066-98bb-432a-b1e7-a5229cb39d4a\n",
" status: experimental\n",
" description: Detects the creation of a named pipe used by known APT malware\n",
" references:\n",
" - Various sources\n",
" date: 2017/11/06\n",
" author: Florian Roth\n",
" logsource:\n",
" product: windows\n",
" service: sysmon\n",
" definition: Note that you have to configure logging for PipeEvents in Symson config\n",
" category: null\n",
" detection:\n",
" selection:\n",
" EventID:\n",
" - 17\n",
" - 18\n",
" PipeName:\n",
" - \\isapi_http\n",
" - \\isapi_dg\n",
" - \\isapi_dg2\n",
" - \\sdlrpc\n",
" - \\ahexec\n",
" - \\winsession\n",
" - \\lsassw\n",
" - \\46a676ab7f179e511e30dd2dc41bd388\n",
" - \\9f81f59bc58452127884ce513865ed20\n",
" - \\e710f28d59aa529d6792ca6ff0ca1b34\n",
" - \\rpchlp_3\n",
" - \\NamePipe_MoreWindows\n",
" - \\pcheap_reuse\n",
" - \\msagent_*\n",
" condition: selection\n",
" tags:\n",
" - attack.defense_evasion\n",
" - attack.privilege_escalation\n",
" - attack.t1055\n",
" falsepositives:\n",
" - Unkown\n",
" level: critical\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:(\"17\" OR \"18\") AND pipe_name.keyword:(\\\\isapi_http OR \\\\isapi_dg OR \\\\isapi_dg2 OR \\\\sdlrpc OR \\\\ahexec OR \\\\winsession OR \\\\lsassw OR \\\\46a676ab7f179e511e30dd2dc41bd388 OR \\\\9f81f59bc58452127884ce513865ed20 OR \\\\e710f28d59aa529d6792ca6ff0ca1b34 OR \\\\rpchlp_3 OR \\\\NamePipe_MoreWindows OR \\\\pcheap_reuse OR \\\\msagent_*))')\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
}