mirror of https://github.com/infosecn1nja/HELK.git
166 lines
5.0 KiB
Plaintext
166 lines
5.0 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Suspicious PowerShell Parameter Substring\n",
|
||
|
"Detects suspicious PowerShell invocation with a parameter substring"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Rule Content\n",
|
||
|
"```\n",
|
||
|
"- title: Suspicious PowerShell Parameter Substring\n",
|
||
|
" id: 36210e0d-5b19-485d-a087-c096088885f0\n",
|
||
|
" status: experimental\n",
|
||
|
" description: Detects suspicious PowerShell invocation with a parameter substring\n",
|
||
|
" references:\n",
|
||
|
" - http://www.danielbohannon.com/blog-1/2017/3/12/powershell-execution-argument-obfuscation-how-it-can-make-detection-easier\n",
|
||
|
" tags:\n",
|
||
|
" - attack.execution\n",
|
||
|
" - attack.t1086\n",
|
||
|
" author: Florian Roth (rule), Daniel Bohannon (idea), Roberto Rodriguez (Fix)\n",
|
||
|
" logsource:\n",
|
||
|
" category: process_creation\n",
|
||
|
" product: windows\n",
|
||
|
" service: null\n",
|
||
|
" detection:\n",
|
||
|
" selection:\n",
|
||
|
" Image:\n",
|
||
|
" - '*\\Powershell.exe'\n",
|
||
|
" CommandLine:\n",
|
||
|
" - ' -windowstyle h '\n",
|
||
|
" - ' -windowstyl h'\n",
|
||
|
" - ' -windowsty h'\n",
|
||
|
" - ' -windowst h'\n",
|
||
|
" - ' -windows h'\n",
|
||
|
" - ' -windo h'\n",
|
||
|
" - ' -wind h'\n",
|
||
|
" - ' -win h'\n",
|
||
|
" - ' -wi h'\n",
|
||
|
" - ' -win h '\n",
|
||
|
" - ' -win hi '\n",
|
||
|
" - ' -win hid '\n",
|
||
|
" - ' -win hidd '\n",
|
||
|
" - ' -win hidde '\n",
|
||
|
" - ' -NoPr '\n",
|
||
|
" - ' -NoPro '\n",
|
||
|
" - ' -NoProf '\n",
|
||
|
" - ' -NoProfi '\n",
|
||
|
" - ' -NoProfil '\n",
|
||
|
" - ' -nonin '\n",
|
||
|
" - ' -nonint '\n",
|
||
|
" - ' -noninte '\n",
|
||
|
" - ' -noninter '\n",
|
||
|
" - ' -nonintera '\n",
|
||
|
" - ' -noninterac '\n",
|
||
|
" - ' -noninteract '\n",
|
||
|
" - ' -noninteracti '\n",
|
||
|
" - ' -noninteractiv '\n",
|
||
|
" - ' -ec '\n",
|
||
|
" - ' -encodedComman '\n",
|
||
|
" - ' -encodedComma '\n",
|
||
|
" - ' -encodedComm '\n",
|
||
|
" - ' -encodedCom '\n",
|
||
|
" - ' -encodedCo '\n",
|
||
|
" - ' -encodedC '\n",
|
||
|
" - ' -encoded '\n",
|
||
|
" - ' -encode '\n",
|
||
|
" - ' -encod '\n",
|
||
|
" - ' -enco '\n",
|
||
|
" - ' -en '\n",
|
||
|
" condition: selection\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-*', 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:(*\\\\Powershell.exe) AND process_command_line:(\"\\ \\-windowstyle\\ h\\ \" OR \"\\ \\-windowstyl\\ h\" OR \"\\ \\-windowsty\\ h\" OR \"\\ \\-windowst\\ h\" OR \"\\ \\-windows\\ h\" OR \"\\ \\-windo\\ h\" OR \"\\ \\-wind\\ h\" OR \"\\ \\-win\\ h\" OR \"\\ \\-wi\\ h\" OR \"\\ \\-win\\ h\\ \" OR \"\\ \\-win\\ hi\\ \" OR \"\\ \\-win\\ hid\\ \" OR \"\\ \\-win\\ hidd\\ \" OR \"\\ \\-win\\ hidde\\ \" OR \"\\ \\-NoPr\\ \" OR \"\\ \\-NoPro\\ \" OR \"\\ \\-NoProf\\ \" OR \"\\ \\-NoProfi\\ \" OR \"\\ \\-NoProfil\\ \" OR \"\\ \\-nonin\\ \" OR \"\\ \\-nonint\\ \" OR \"\\ \\-noninte\\ \" OR \"\\ \\-noninter\\ \" OR \"\\ \\-nonintera\\ \" OR \"\\ \\-noninterac\\ \" OR \"\\ \\-noninteract\\ \" OR \"\\ \\-noninteracti\\ \" OR \"\\ \\-noninteractiv\\ \" OR \"\\ \\-ec\\ \" OR \"\\ \\-encodedComman\\ \" OR \"\\ \\-encodedComma\\ \" OR \"\\ \\-encodedComm\\ \" OR \"\\ \\-encodedCom\\ \" OR \"\\ \\-encodedCo\\ \" OR \"\\ \\-encodedC\\ \" OR \"\\ \\-encoded\\ \" OR \"\\ \\-encode\\ \" OR \"\\ \\-encod\\ \" OR \"\\ \\-enco\\ \" OR \"\\ \\-en\\ \"))')\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
|
||
|
}
|