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

123 lines
2.5 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# JexBoss Command Sequence\n",
"Detects suspicious command sequence that JexBoss"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: JexBoss Command Sequence\n",
" id: 8ec2c8b4-557a-4121-b87c-5dfb3a602fae\n",
" description: Detects suspicious command sequence that JexBoss\n",
" references:\n",
" - https://www.us-cert.gov/ncas/analysis-reports/AR18-312A\n",
" author: Florian Roth\n",
" date: 2017/08/24\n",
" logsource:\n",
" product: linux\n",
" service: null\n",
" category: null\n",
" detection:\n",
" selection1:\n",
" - bash -c /bin/bash\n",
" selection2:\n",
" - '&/dev/tcp/'\n",
" condition: selection1 and selection2\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='\\*.keyword:(*bash\\ \\-c\\ \\/bin\\/bash* AND *&\\/dev\\/tcp\\/*)')\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
}