{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Suspicious RUN Key from Download\n", "Detects the suspicious RUN keys created by software located in Download or temporary Outlook/Internet Explorer directories" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Rule Content\n", "```\n", "- title: Suspicious RUN Key from Download\n", " id: 9c5037d1-c568-49b3-88c7-9846a5bdc2be\n", " status: experimental\n", " description: Detects the suspicious RUN keys created by software located in Download\n", " or temporary Outlook/Internet Explorer directories\n", " references:\n", " - https://app.any.run/tasks/c5bef5b7-f484-4c43-9cf3-d5c5c7839def/\n", " author: Florian Roth\n", " date: 2019/10/01\n", " tags:\n", " - attack.persistence\n", " - attack.t1060\n", " logsource:\n", " product: windows\n", " service: sysmon\n", " category: null\n", " detection:\n", " selection:\n", " EventID: 13\n", " Image:\n", " - '*\\Downloads\\\\*'\n", " - '*\\Temporary Internet Files\\Content.Outlook\\\\*'\n", " - '*\\Local Settings\\Temporary Internet Files\\\\*'\n", " TargetObject: '*\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\\\*'\n", " condition: selection\n", " falsepositives:\n", " - Software installers downloaded and used by users\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:\"13\" AND process_path.keyword:(*\\\\Downloads\\\\* OR *\\\\Temporary\\ Internet\\ Files\\\\Content.Outlook\\\\* OR *\\\\Local\\ Settings\\\\Temporary\\ Internet\\ Files\\\\*) AND registry_key_path.keyword:*\\\\SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run\\\\*)')\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 }