HELK/docker/helk-jupyter/notebooks/sigma/win_susp_schtask_creation.i...

133 lines
2.9 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Scheduled Task Creation\n",
"Detects the creation of scheduled tasks in user session"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: Scheduled Task Creation\n",
" id: 92626ddd-662c-49e3-ac59-f6535f12d189\n",
" status: experimental\n",
" description: Detects the creation of scheduled tasks in user session\n",
" author: Florian Roth\n",
" logsource:\n",
" category: process_creation\n",
" product: windows\n",
" service: null\n",
" detection:\n",
" selection:\n",
" Image: '*\\schtasks.exe'\n",
" CommandLine: '* /create *'\n",
" filter:\n",
" User: NT AUTHORITY\\SYSTEM\n",
" condition: selection and not filter\n",
" fields:\n",
" - CommandLine\n",
" - ParentCommandLine\n",
" tags:\n",
" - attack.execution\n",
" - attack.persistence\n",
" - attack.privilege_escalation\n",
" - attack.t1053\n",
" - attack.s0111\n",
" - car.2013-08-001\n",
" falsepositives:\n",
" - Administrative activity\n",
" - Software installation\n",
" level: low\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:*\\\\schtasks.exe AND process_command_line.keyword:*\\ \\/create\\ *) AND (NOT (user_account:\"NT\\ AUTHORITY\\\\SYSTEM\")))')\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
}