{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# WMI Event Subscription\n", "Detects creation of WMI event subscription persistence method" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Rule Content\n", "```\n", "- title: WMI Event Subscription\n", " id: 0f06a3a5-6a09-413f-8743-e6cf35561297\n", " status: experimental\n", " description: Detects creation of WMI event subscription persistence method\n", " references:\n", " - https://attack.mitre.org/techniques/T1084/\n", " tags:\n", " - attack.t1084\n", " - attack.persistence\n", " author: Tom Ueltschi (@c_APT_ure)\n", " date: 2019/01/12\n", " logsource:\n", " product: windows\n", " service: sysmon\n", " category: null\n", " detection:\n", " selector:\n", " EventID:\n", " - 19\n", " - 20\n", " - 21\n", " condition: selector\n", " falsepositives:\n", " - exclude legitimate (vetted) use of WMI event subscription in your network\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:(\"19\" OR \"20\" OR \"21\")')\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 }