mirror of https://github.com/infosecn1nja/HELK.git
138 lines
4.0 KiB
Plaintext
138 lines
4.0 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Suspicious VSFTPD Error Messages\n",
|
|
"Detects suspicious VSFTPD error messages that indicate a fatal or suspicious error that could be caused by exploiting attempts"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Rule Content\n",
|
|
"```\n",
|
|
"- title: Suspicious VSFTPD Error Messages\n",
|
|
" id: 377f33a1-4b36-4ee1-acee-1dbe4b43cfbe\n",
|
|
" description: Detects suspicious VSFTPD error messages that indicate a fatal or suspicious\n",
|
|
" error that could be caused by exploiting attempts\n",
|
|
" references:\n",
|
|
" - https://github.com/dagwieers/vsftpd/\n",
|
|
" author: Florian Roth\n",
|
|
" date: 2017/07/05\n",
|
|
" logsource:\n",
|
|
" product: linux\n",
|
|
" service: vsftpd\n",
|
|
" category: null\n",
|
|
" detection:\n",
|
|
" keywords:\n",
|
|
" - 'Connection refused: too many sessions for this address.'\n",
|
|
" - 'Connection refused: tcp_wrappers denial.'\n",
|
|
" - Bad HTTP verb.\n",
|
|
" - port and pasv both active\n",
|
|
" - pasv and port both active\n",
|
|
" - Transfer done (but failed to open directory).\n",
|
|
" - Could not set file modification time.\n",
|
|
" - 'bug: pid active in ptrace_sandbox_free'\n",
|
|
" - PTRACE_SETOPTIONS failure\n",
|
|
" - 'weird status:'\n",
|
|
" - couldn't handle sandbox event\n",
|
|
" - syscall * out of bounds\n",
|
|
" - 'syscall not permitted:'\n",
|
|
" - 'syscall validate failed:'\n",
|
|
" - Input line too long.\n",
|
|
" - poor buffer accounting in str_netfd_alloc\n",
|
|
" - vsf_sysutil_read_loop\n",
|
|
" condition: keywords\n",
|
|
" falsepositives:\n",
|
|
" - Unknown\n",
|
|
" level: medium\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='\\*.keyword:(*Connection\\ refused\\:\\ too\\ many\\ sessions\\ for\\ this\\ address.* OR *Connection\\ refused\\:\\ tcp_wrappers\\ denial.* OR *Bad\\ HTTP\\ verb.* OR *port\\ and\\ pasv\\ both\\ active* OR *pasv\\ and\\ port\\ both\\ active* OR *Transfer\\ done\\ \\(but\\ failed\\ to\\ open\\ directory\\).* OR *Could\\ not\\ set\\ file\\ modification\\ time.* OR *bug\\:\\ pid\\ active\\ in\\ ptrace_sandbox_free* OR *PTRACE_SETOPTIONS\\ failure* OR *weird\\ status\\:* OR *couldn't\\ handle\\ sandbox\\ event* OR *syscall\\ *\\ out\\ of\\ bounds* OR *syscall\\ not\\ permitted\\:* OR *syscall\\ validate\\ failed\\:* OR *Input\\ line\\ too\\ long.* OR *poor\\ buffer\\ accounting\\ in\\ str_netfd_alloc* OR *vsf_sysutil_read_loop*)')\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
|
|
}
|