{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Addition of Domain Trusts\n", "Addition of domains is seldom and should be verified for legitimacy." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Rule Content\n", "```\n", "- title: Addition of Domain Trusts\n", " id: 0255a820-e564-4e40-af2b-6ac61160335c\n", " status: stable\n", " description: Addition of domains is seldom and should be verified for legitimacy.\n", " author: Thomas Patzke\n", " tags:\n", " - attack.persistence\n", " logsource:\n", " product: windows\n", " service: security\n", " category: null\n", " detection:\n", " selection:\n", " EventID: 4706\n", " condition: selection\n", " falsepositives:\n", " - Legitimate extension of domain structure\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-endpoint-winevent-security-*', 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:\"4706\"')\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 }