HELK/docker/helk-jupyter/notebooks/sigma/sysmon_rundll32_net_connect...

150 lines
3.7 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Rundll32 Internet Connection\n",
"Detects a rundll32 that communicates with public IP addresses"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: Rundll32 Internet Connection\n",
" id: cdc8da7d-c303-42f8-b08c-b4ab47230263\n",
" status: experimental\n",
" description: Detects a rundll32 that communicates with public IP addresses\n",
" references:\n",
" - https://www.hybrid-analysis.com/sample/759fb4c0091a78c5ee035715afe3084686a8493f39014aea72dae36869de9ff6?environmentId=100\n",
" author: Florian Roth\n",
" date: 2017/11/04\n",
" tags:\n",
" - attack.t1085\n",
" - attack.defense_evasion\n",
" - attack.execution\n",
" logsource:\n",
" product: windows\n",
" service: sysmon\n",
" category: null\n",
" detection:\n",
" selection:\n",
" EventID: 3\n",
" Image: '*\\rundll32.exe'\n",
" Initiated: 'true'\n",
" filter:\n",
" DestinationIp:\n",
" - 10.*\n",
" - 192.168.*\n",
" - 172.16.*\n",
" - 172.17.*\n",
" - 172.18.*\n",
" - 172.19.*\n",
" - 172.20.*\n",
" - 172.21.*\n",
" - 172.22.*\n",
" - 172.23.*\n",
" - 172.24.*\n",
" - 172.25.*\n",
" - 172.26.*\n",
" - 172.27.*\n",
" - 172.28.*\n",
" - 172.29.*\n",
" - 172.30.*\n",
" - 172.31.*\n",
" - 127.*\n",
" condition: selection and not filter\n",
" falsepositives:\n",
" - Communication to other corporate systems that use IP addresses from public address\n",
" spaces\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-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:\"3\" AND process_path.keyword:*\\\\rundll32.exe AND network_initiated:\"true\") AND (NOT (dst_ip_addr.keyword:(10.* OR 192.168.* OR 172.16.* OR 172.17.* OR 172.18.* OR 172.19.* OR 172.20.* OR 172.21.* OR 172.22.* OR 172.23.* OR 172.24.* OR 172.25.* OR 172.26.* OR 172.27.* OR 172.28.* OR 172.29.* OR 172.30.* OR 172.31.* OR 127.*))))')\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
}