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

173 lines
5.1 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Hack Tool User Agent\n",
"Detects suspicious user agent strings user by hack tools in proxy logs"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: Hack Tool User Agent\n",
" id: c42a3073-30fb-48ae-8c99-c23ada84b103\n",
" status: experimental\n",
" description: Detects suspicious user agent strings user by hack tools in proxy logs\n",
" references:\n",
" - https://github.com/fastly/waf_testbed/blob/master/templates/default/scanners-user-agents.data.erb\n",
" - http://rules.emergingthreats.net/open/snort-2.9.0/rules/emerging-user_agents.rules\n",
" author: Florian Roth\n",
" logsource:\n",
" category: proxy\n",
" product: null\n",
" service: null\n",
" detection:\n",
" selection:\n",
" c-useragent:\n",
" - '*(hydra)*'\n",
" - '* arachni/*'\n",
" - '* BFAC *'\n",
" - '* brutus *'\n",
" - '* cgichk *'\n",
" - '*core-project/1.0*'\n",
" - '* crimscanner/*'\n",
" - '*datacha0s*'\n",
" - '*dirbuster*'\n",
" - '*domino hunter*'\n",
" - '*dotdotpwn*'\n",
" - FHScan Core\n",
" - '*floodgate*'\n",
" - '*get-minimal*'\n",
" - '*gootkit auto-rooter scanner*'\n",
" - '*grendel-scan*'\n",
" - '* inspath *'\n",
" - '*internet ninja*'\n",
" - '*jaascois*'\n",
" - '* zmeu *'\n",
" - '*masscan*'\n",
" - '* metis *'\n",
" - '*morfeus fucking scanner*'\n",
" - '*n-stealth*'\n",
" - '*nsauditor*'\n",
" - '*pmafind*'\n",
" - '*security scan*'\n",
" - '*springenwerk*'\n",
" - '*teh forest lobster*'\n",
" - '*toata dragostea*'\n",
" - '* vega/*'\n",
" - '*voideye*'\n",
" - '*webshag*'\n",
" - '*webvulnscan*'\n",
" - '* whcc/*'\n",
" - '* Havij'\n",
" - '*absinthe*'\n",
" - '*bsqlbf*'\n",
" - '*mysqloit*'\n",
" - '*pangolin*'\n",
" - '*sql power injector*'\n",
" - '*sqlmap*'\n",
" - '*sqlninja*'\n",
" - '*uil2pn*'\n",
" - ruler\n",
" - Mozilla/5.0 (Windows; U; Windows NT 5.1; pt-PT; rv:1.9.1.2) Gecko/20090729\n",
" Firefox/3.5.2 (.NET CLR 3.5.30729)\n",
" condition: selection\n",
" fields:\n",
" - ClientIP\n",
" - c-uri\n",
" - c-useragent\n",
" falsepositives:\n",
" - Unknown\n",
" level: high\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='c-useragent.keyword:(*\\(hydra\\)* OR *\\ arachni\\/* OR *\\ BFAC\\ * OR *\\ brutus\\ * OR *\\ cgichk\\ * OR *core\\-project\\/1.0* OR *\\ crimscanner\\/* OR *datacha0s* OR *dirbuster* OR *domino\\ hunter* OR *dotdotpwn* OR FHScan\\ Core OR *floodgate* OR *get\\-minimal* OR *gootkit\\ auto\\-rooter\\ scanner* OR *grendel\\-scan* OR *\\ inspath\\ * OR *internet\\ ninja* OR *jaascois* OR *\\ zmeu\\ * OR *masscan* OR *\\ metis\\ * OR *morfeus\\ fucking\\ scanner* OR *n\\-stealth* OR *nsauditor* OR *pmafind* OR *security\\ scan* OR *springenwerk* OR *teh\\ forest\\ lobster* OR *toata\\ dragostea* OR *\\ vega\\/* OR *voideye* OR *webshag* OR *webvulnscan* OR *\\ whcc\\/* OR *\\ Havij OR *absinthe* OR *bsqlbf* OR *mysqloit* OR *pangolin* OR *sql\\ power\\ injector* OR *sqlmap* OR *sqlninja* OR *uil2pn* OR ruler OR Mozilla\\/5.0\\ \\(Windows;\\ U;\\ Windows\\ NT\\ 5.1;\\ pt\\-PT;\\ rv\\:1.9.1.2\\)\\ Gecko\\/20090729\\ Firefox\\/3.5.2\\ \\(.NET\\ CLR\\ 3.5.30729\\))')\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
}