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

130 lines
3.0 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Suspicious Calculator Usage\n",
"Detects suspicious use of calc.exe with command line parameters or in a suspicious directory, which is likely caused by some PoC or detection evasion"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: Suspicious Calculator Usage\n",
" id: 737e618a-a410-49b5-bec3-9e55ff7fbc15\n",
" description: Detects suspicious use of calc.exe with command line parameters or\n",
" in a suspicious directory, which is likely caused by some PoC or detection evasion\n",
" status: experimental\n",
" references:\n",
" - https://twitter.com/ItsReallyNick/status/1094080242686312448\n",
" author: Florian Roth\n",
" date: 2019/02/09\n",
" tags:\n",
" - attack.defense_evasion\n",
" - attack.t1036\n",
" logsource:\n",
" category: process_creation\n",
" product: windows\n",
" service: null\n",
" detection:\n",
" selection1:\n",
" CommandLine: '*\\calc.exe *'\n",
" selection2:\n",
" Image: '*\\calc.exe'\n",
" filter2:\n",
" Image: '*\\Windows\\Sys*'\n",
" condition: selection1 or ( selection2 and not filter2 )\n",
" falsepositives:\n",
" - Unknown\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_command_line.keyword:*\\\\calc.exe\\ * OR (process_path.keyword:*\\\\calc.exe AND (NOT (process_path.keyword:*\\\\Windows\\\\Sys*))))')\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
}