mirror of https://github.com/infosecn1nja/HELK.git
143 lines
3.6 KiB
Plaintext
143 lines
3.6 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Malicious Service Installations\n",
|
||
|
"Detects known malicious service installs that only appear in cases of lateral movement, credential dumping and other suspicious activity"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Rule Content\n",
|
||
|
"```\n",
|
||
|
"- title: Malicious Service Installations\n",
|
||
|
" id: 5a105d34-05fc-401e-8553-272b45c1522d\n",
|
||
|
" description: Detects known malicious service installs that only appear in cases\n",
|
||
|
" of lateral movement, credential dumping and other suspicious activity\n",
|
||
|
" author: Florian Roth\n",
|
||
|
" tags:\n",
|
||
|
" - attack.persistence\n",
|
||
|
" - attack.privilege_escalation\n",
|
||
|
" - attack.t1050\n",
|
||
|
" - car.2013-09-005\n",
|
||
|
" logsource:\n",
|
||
|
" product: windows\n",
|
||
|
" service: system\n",
|
||
|
" category: null\n",
|
||
|
" detection:\n",
|
||
|
" selection:\n",
|
||
|
" EventID: 7045\n",
|
||
|
" malsvc_wce:\n",
|
||
|
" ServiceName:\n",
|
||
|
" - WCESERVICE\n",
|
||
|
" - WCE SERVICE\n",
|
||
|
" malsvc_paexec:\n",
|
||
|
" ServiceFileName: '*\\PAExec*'\n",
|
||
|
" malsvc_winexe:\n",
|
||
|
" ServiceFileName: winexesvc.exe*\n",
|
||
|
" malsvc_pwdumpx:\n",
|
||
|
" ServiceFileName: '*\\DumpSvc.exe'\n",
|
||
|
" malsvc_wannacry:\n",
|
||
|
" ServiceName: mssecsvc2.0\n",
|
||
|
" malsvc_persistence:\n",
|
||
|
" ServiceFileName: '* net user *'\n",
|
||
|
" malsvc_others:\n",
|
||
|
" ServiceName:\n",
|
||
|
" - pwdump*\n",
|
||
|
" - gsecdump*\n",
|
||
|
" - cachedump*\n",
|
||
|
" condition: selection and 1 of malsvc_*\n",
|
||
|
" falsepositives:\n",
|
||
|
" - Penetration testing\n",
|
||
|
" level: critical\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-system-*', 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='(event_id:\"7045\" AND (service_name:(\"WCESERVICE\" OR \"WCE\\ SERVICE\") OR service_image_path.keyword:*\\\\PAExec* OR service_image_path.keyword:winexesvc.exe* OR service_image_path.keyword:*\\\\DumpSvc.exe OR service_name:\"mssecsvc2.0\" OR service_image_path.keyword:*\\ net\\ user\\ * OR service_name.keyword:(pwdump* OR gsecdump* OR cachedump*)))')\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
|
||
|
}
|