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

129 lines
2.7 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Webshell Remote Command Execution\n",
"Detects posible command execution by web application/web shell"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: Webshell Remote Command Execution\n",
" id: c0d3734d-330f-4a03-aae2-65dacc6a8222\n",
" status: experimental\n",
" description: Detects posible command execution by web application/web shell\n",
" tags:\n",
" - attack.persistence\n",
" - attack.t1100\n",
" references:\n",
" - personal experience\n",
" author: Ilyas Ochkov, Beyu Denis, oscd.community\n",
" date: 2019/10/12\n",
" modified: 2019/11/04\n",
" logsource:\n",
" product: linux\n",
" service: auditd\n",
" category: null\n",
" detection:\n",
" selection:\n",
" type: SYSCALL\n",
" SYSCALL: execve\n",
" key: detect_execve_www\n",
" condition: selection\n",
" falsepositives:\n",
" - Admin activity\n",
" - Crazy web applications\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-*', 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='(type:\"SYSCALL\" AND SYSCALL:\"execve\" AND key:\"detect_execve_www\")')\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
}