{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Executable in ADS\n", "Detects the creation of an ADS data stream that contains an executable (non-empty imphash)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Rule Content\n", "```\n", "- title: Executable in ADS\n", " id: b69888d4-380c-45ce-9cf9-d9ce46e67821\n", " status: experimental\n", " description: Detects the creation of an ADS data stream that contains an executable\n", " (non-empty imphash)\n", " references:\n", " - https://twitter.com/0xrawsec/status/1002478725605273600?s=21\n", " tags:\n", " - attack.defense_evasion\n", " - attack.t1027\n", " - attack.s0139\n", " author: Florian Roth, @0xrawsec\n", " date: 2018/06/03\n", " logsource:\n", " product: windows\n", " service: sysmon\n", " definition: 'Requirements: Sysmon config with Imphash logging activated'\n", " category: null\n", " detection:\n", " selection:\n", " EventID: 15\n", " filter:\n", " Imphash: '00000000000000000000000000000000'\n", " condition: selection and not filter\n", " fields:\n", " - TargetFilename\n", " - Image\n", " falsepositives:\n", " - unknown\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:\"15\" AND (NOT (hash_imphash:\"00000000000000000000000000000000\")))')\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 }