mirror of https://github.com/infosecn1nja/HELK.git
149 lines
3.8 KiB
Plaintext
149 lines
3.8 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Windows webshell creation\n",
|
|
"Posible webshell file creation on a static web site"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Rule Content\n",
|
|
"```\n",
|
|
"- title: Windows webshell creation\n",
|
|
" id: 39f1f9f2-9636-45de-98f6-a4046aa8e4b9\n",
|
|
" status: experimental\n",
|
|
" description: Posible webshell file creation on a static web site\n",
|
|
" references:\n",
|
|
" - PT ESC rule and personal experience\n",
|
|
" author: Beyu Denis, oscd.community\n",
|
|
" date: 2019/10/22\n",
|
|
" modified: 2019/11/04\n",
|
|
" tags:\n",
|
|
" - attack.persistence\n",
|
|
" - attack.t1100\n",
|
|
" level: critical\n",
|
|
" logsource:\n",
|
|
" product: windows\n",
|
|
" service: sysmon\n",
|
|
" category: null\n",
|
|
" detection:\n",
|
|
" selection_1:\n",
|
|
" EventID: 11\n",
|
|
" selection_2:\n",
|
|
" TargetFilename|contains: \\inetpub\\wwwroot\\\n",
|
|
" selection_3:\n",
|
|
" TargetFilename|contains:\n",
|
|
" - .asp\n",
|
|
" - .ashx\n",
|
|
" - .ph\n",
|
|
" selection_4:\n",
|
|
" TargetFilename|contains:\n",
|
|
" - \\www\\\n",
|
|
" - \\htdocs\\\n",
|
|
" - \\html\\\n",
|
|
" selection_5:\n",
|
|
" TargetFilename|contains: .ph\n",
|
|
" selection_6:\n",
|
|
" - TargetFilename|contains|all:\n",
|
|
" - \\\n",
|
|
" - .jsp\n",
|
|
" - TargetFilename|contains|all:\n",
|
|
" - \\cgi-bin\\\n",
|
|
" - .pl\n",
|
|
" condition: selection_1 and ( selection_2 and selection_3 ) or selection_1 and\n",
|
|
" ( selection_4 and selection_5 ) or selection_1 and selection_6\n",
|
|
" falsepositives:\n",
|
|
" - Legitimate administrator or developer creating legitimate executable files in\n",
|
|
" a web application folder\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-sysmon-*', 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:\"11\" AND ((file_name.keyword:*\\\\inetpub\\\\wwwroot\\* AND file_name.keyword:(*.asp* OR *.ashx* OR *.ph*)) OR (file_name.keyword:(*\\\\www\\* OR *\\\\htdocs\\* OR *\\\\html\\*) AND file_name.keyword:*.ph*) OR (file_name.keyword:*\\* AND file_name.keyword:*.jsp*) OR (file_name.keyword:*\\\\cgi\\-bin\\* AND file_name.keyword:*.pl*)))')\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
|
|
}
|