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

142 lines
3.7 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# WScript or CScript Dropper\n",
"Detects wscript/cscript executions of scripts located in user directories"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: WScript or CScript Dropper\n",
" id: cea72823-df4d-4567-950c-0b579eaf0846\n",
" status: experimental\n",
" description: Detects wscript/cscript executions of scripts located in user directories\n",
" author: Margaritis Dimitrios (idea), Florian Roth (rule)\n",
" tags:\n",
" - attack.defense_evasion\n",
" - attack.execution\n",
" - attack.t1064\n",
" logsource:\n",
" category: process_creation\n",
" product: windows\n",
" service: null\n",
" detection:\n",
" selection:\n",
" Image:\n",
" - '*\\wscript.exe'\n",
" - '*\\cscript.exe'\n",
" CommandLine:\n",
" - '* C:\\Users\\\\*.jse *'\n",
" - '* C:\\Users\\\\*.vbe *'\n",
" - '* C:\\Users\\\\*.js *'\n",
" - '* C:\\Users\\\\*.vba *'\n",
" - '* C:\\Users\\\\*.vbs *'\n",
" - '* C:\\ProgramData\\\\*.jse *'\n",
" - '* C:\\ProgramData\\\\*.vbe *'\n",
" - '* C:\\ProgramData\\\\*.js *'\n",
" - '* C:\\ProgramData\\\\*.vba *'\n",
" - '* C:\\ProgramData\\\\*.vbs *'\n",
" falsepositive:\n",
" ParentImage: '*\\winzip*'\n",
" condition: selection and not falsepositive\n",
" fields:\n",
" - CommandLine\n",
" - ParentCommandLine\n",
" falsepositives:\n",
" - Winzip\n",
" - Other self-extractors\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:(*\\\\wscript.exe OR *\\\\cscript.exe) AND process_command_line.keyword:(*\\ C\\:\\\\Users\\\\*.jse\\ * OR *\\ C\\:\\\\Users\\\\*.vbe\\ * OR *\\ C\\:\\\\Users\\\\*.js\\ * OR *\\ C\\:\\\\Users\\\\*.vba\\ * OR *\\ C\\:\\\\Users\\\\*.vbs\\ * OR *\\ C\\:\\\\ProgramData\\\\*.jse\\ * OR *\\ C\\:\\\\ProgramData\\\\*.vbe\\ * OR *\\ C\\:\\\\ProgramData\\\\*.js\\ * OR *\\ C\\:\\\\ProgramData\\\\*.vba\\ * OR *\\ C\\:\\\\ProgramData\\\\*.vbs\\ *)) AND (NOT (process_parent_path.keyword:*\\\\winzip*)))')\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
}