HELK/docker/helk-jupyter/notebooks/sigma/win_etw_trace_evasion.ipynb

132 lines
3.3 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Disable of ETW Trace\n",
"Detects a command that clears or disables any ETW trace log which could indicate a logging evasion."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: Disable of ETW Trace\n",
" id: a238b5d0-ce2d-4414-a676-7a531b3d13d6\n",
" description: Detects a command that clears or disables any ETW trace log which could\n",
" indicate a logging evasion.\n",
" references:\n",
" - https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/wevtutil\n",
" - https://github.com/Neo23x0/sigma/blob/master/rules/windows/process_creation/win_mal_lockergoga.yml\n",
" - https://abuse.io/lockergoga.txt\n",
" author: '@neu5ron, Florian Roth'\n",
" date: 2019/03/22\n",
" tags:\n",
" - attack.execution\n",
" - attack.t1070\n",
" - car.2016-04-002\n",
" level: high\n",
" logsource:\n",
" category: process_creation\n",
" product: windows\n",
" service: null\n",
" detection:\n",
" selection_clear_1:\n",
" CommandLine: '* cl */Trace*'\n",
" selection_clear_2:\n",
" CommandLine: '* clear-log */Trace*'\n",
" selection_disable_1:\n",
" CommandLine: '* sl* /e:false*'\n",
" selection_disable_2:\n",
" CommandLine: '* set-log* /e:false*'\n",
" condition: selection_clear_1 or selection_clear_2 or selection_disable_1 or selection_disable_2\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:*\\ cl\\ *\\/Trace* OR process_command_line.keyword:*\\ clear\\-log\\ *\\/Trace* OR process_command_line.keyword:*\\ sl*\\ \\/e\\:false* OR process_command_line.keyword:*\\ set\\-log*\\ \\/e\\:false*)')\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
}