{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Suspicious Process Start Locations\n", "Detects suspicious process run from unusual locations" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Rule Content\n", "```\n", "- title: Suspicious Process Start Locations\n", " id: 15b75071-74cc-47e0-b4c6-b43744a62a2b\n", " description: Detects suspicious process run from unusual locations\n", " status: experimental\n", " references:\n", " - https://car.mitre.org/wiki/CAR-2013-05-002\n", " author: juju4\n", " tags:\n", " - attack.defense_evasion\n", " - attack.t1036\n", " - car.2013-05-002\n", " logsource:\n", " category: process_creation\n", " product: windows\n", " service: null\n", " detection:\n", " selection:\n", " Image:\n", " - '*:\\RECYCLER\\\\*'\n", " - '*:\\SystemVolumeInformation\\\\*'\n", " - C:\\\\Windows\\\\Tasks\\\\*\n", " - C:\\\\Windows\\\\debug\\\\*\n", " - C:\\\\Windows\\\\fonts\\\\*\n", " - C:\\\\Windows\\\\help\\\\*\n", " - C:\\\\Windows\\\\drivers\\\\*\n", " - C:\\\\Windows\\\\addins\\\\*\n", " - C:\\\\Windows\\\\cursors\\\\*\n", " - C:\\\\Windows\\\\system32\\tasks\\\\*\n", " condition: selection\n", " falsepositives:\n", " - False positives depend on scripts and administrative tools used in the monitored\n", " environment\n", " level: medium\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_path.keyword:(*\\:\\\\RECYCLER\\\\* OR *\\:\\\\SystemVolumeInformation\\\\* OR C\\:\\\\Windows\\\\Tasks\\\\* OR C\\:\\\\Windows\\\\debug\\\\* OR C\\:\\\\Windows\\\\fonts\\\\* OR C\\:\\\\Windows\\\\help\\\\* OR C\\:\\\\Windows\\\\drivers\\\\* OR C\\:\\\\Windows\\\\addins\\\\* OR C\\:\\\\Windows\\\\cursors\\\\* OR C\\:\\\\Windows\\\\system32\\\\tasks\\\\*)')\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 }