{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Emotet Process Creation\n", "Detects all Emotet like process executions that are not covered by the more generic rules" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Rule Content\n", "```\n", "- title: Emotet Process Creation\n", " id: d02e8cf5-6099-48cf-9bfc-1eec2d0c7b18\n", " status: experimental\n", " description: Detects all Emotet like process executions that are not covered by\n", " the more generic rules\n", " author: Florian Roth\n", " date: 2019/09/30\n", " modified: 2019/10/16\n", " references:\n", " - https://app.any.run/tasks/e13ab713-64cf-4b23-ad93-6dceaa5429ac/\n", " - https://app.any.run/tasks/81f3c28c-c686-425d-8a2b-a98198d244e1/\n", " - https://app.any.run/tasks/97f875e8-0e08-4328-815f-055e971ba754/\n", " logsource:\n", " category: process_creation\n", " product: windows\n", " service: null\n", " detection:\n", " selection:\n", " CommandLine:\n", " - '* -e* PAA*'\n", " - '*JABlAG4AdgA6AHUAcwBlAHIAcAByAG8AZgBpAGwAZQ*'\n", " - '*QAZQBuAHYAOgB1AHMAZQByAHAAcgBvAGYAaQBsAGUA*'\n", " - '*kAGUAbgB2ADoAdQBzAGUAcgBwAHIAbwBmAGkAbABlA*'\n", " - '*IgAoACcAKgAnACkAOwAkA*'\n", " - '*IAKAAnACoAJwApADsAJA*'\n", " - '*iACgAJwAqACcAKQA7ACQA*'\n", " condition: selection\n", " fields:\n", " - CommandLine\n", " - ParentCommandLine\n", " falsepositives:\n", " - Unlikely\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-*', 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='process_command_line.keyword:(*\\ \\-e*\\ PAA* OR *JABlAG4AdgA6AHUAcwBlAHIAcAByAG8AZgBpAGwAZQ* OR *QAZQBuAHYAOgB1AHMAZQByAHAAcgBvAGYAaQBsAGUA* OR *kAGUAbgB2ADoAdQBzAGUAcgBwAHIAbwBmAGkAbABlA* OR *IgAoACcAKgAnACkAOwAkA* OR *IAKAAnACoAJwApADsAJA* OR *iACgAJwAqACcAKQA7ACQA*)')\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 }