HELK/docker/helk-jupyter/notebooks/sigma/powershell_suspicious_keywo...

129 lines
2.9 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Suspicious PowerShell Keywords\n",
"Detects keywords that could indicate the use of some PowerShell exploitation framework"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: Suspicious PowerShell Keywords\n",
" id: 1f49f2ab-26bc-48b3-96cc-dcffbc93eadf\n",
" status: experimental\n",
" description: Detects keywords that could indicate the use of some PowerShell exploitation\n",
" framework\n",
" date: 2019/02/11\n",
" author: Florian Roth\n",
" references:\n",
" - https://posts.specterops.io/entering-a-covenant-net-command-and-control-e11038bcf462\n",
" tags:\n",
" - attack.execution\n",
" - attack.t1086\n",
" logsource:\n",
" product: windows\n",
" service: powershell\n",
" definition: It is recommended to use the new \"Script Block Logging\" of PowerShell\n",
" v5 https://adsecurity.org/?p=2277\n",
" category: null\n",
" detection:\n",
" keywords:\n",
" Message:\n",
" - '*[System.Reflection.Assembly]::Load*'\n",
" condition: keywords\n",
" falsepositives:\n",
" - Penetration tests\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-powershell-*', 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='Message.keyword:(*\\[System.Reflection.Assembly\\]\\:\\:Load*)')\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
}