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

155 lines
3.8 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Pandemic Registry Key\n",
"Detects Pandemic Windows Implant"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- action: global\n",
" title: Pandemic Registry Key\n",
" id: 47e0852a-cf81-4494-a8e6-31864f8c86ed\n",
" status: experimental\n",
" description: Detects Pandemic Windows Implant\n",
" references:\n",
" - https://wikileaks.org/vault7/#Pandemic\n",
" - https://twitter.com/MalwareJake/status/870349480356454401\n",
" tags:\n",
" - attack.lateral_movement\n",
" - attack.t1105\n",
" author: Florian Roth\n",
" detection:\n",
" condition: 1 of them\n",
" fields:\n",
" - EventID\n",
" - CommandLine\n",
" - ParentCommandLine\n",
" - Image\n",
" - User\n",
" - TargetObject\n",
" falsepositives:\n",
" - unknown\n",
" level: critical\n",
"- logsource:\n",
" product: windows\n",
" service: sysmon\n",
" detection:\n",
" selection1:\n",
" EventID: 13\n",
" TargetObject:\n",
" - \\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\services\\null\\Instance*\n",
" - \\REGISTRY\\MACHINE\\SYSTEM\\ControlSet001\\services\\null\\Instance*\n",
" - \\REGISTRY\\MACHINE\\SYSTEM\\ControlSet002\\services\\null\\Instance*\n",
"- logsource:\n",
" category: process_creation\n",
" product: windows\n",
" detection:\n",
" selection2:\n",
" Command: loaddll -a *\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='(event_id:\"13\" AND registry_key_path.keyword:(\\\\REGISTRY\\\\MACHINE\\\\SYSTEM\\\\CurrentControlSet\\\\services\\\\null\\\\Instance* OR \\\\REGISTRY\\\\MACHINE\\\\SYSTEM\\\\ControlSet001\\\\services\\\\null\\\\Instance* OR \\\\REGISTRY\\\\MACHINE\\\\SYSTEM\\\\ControlSet002\\\\services\\\\null\\\\Instance*))')\n",
"response = s.execute()\n",
"if response.success():\n",
" df = pd.DataFrame((d.to_dict() for d in s.scan()))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"s = searchContext.query('query_string', query='Command.keyword:loaddll\\ \\-a\\ *')\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
}