HELK/docker/helk-jupyter/notebooks/sigma/sysmon_rdp_reverse_tunnel.i...

134 lines
3.0 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# RDP over Reverse SSH Tunnel\n",
"Detects svchost hosting RDP termsvcs communicating with the loopback address and on TCP port 3389"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: RDP over Reverse SSH Tunnel\n",
" id: 5f699bc5-5446-4a4a-a0b7-5ef2885a3eb4\n",
" status: experimental\n",
" description: Detects svchost hosting RDP termsvcs communicating with the loopback\n",
" address and on TCP port 3389\n",
" references:\n",
" - https://twitter.com/SBousseaden/status/1096148422984384514\n",
" author: Samir Bousseaden\n",
" date: 2019/02/16\n",
" tags:\n",
" - attack.defense_evasion\n",
" - attack.command_and_control\n",
" - attack.t1076\n",
" - car.2013-07-002\n",
" logsource:\n",
" product: windows\n",
" service: sysmon\n",
" category: null\n",
" detection:\n",
" selection:\n",
" EventID: 3\n",
" Image: '*\\svchost.exe'\n",
" Initiated: 'true'\n",
" SourcePort: 3389\n",
" DestinationIp:\n",
" - 127.*\n",
" - ::1\n",
" condition: selection\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-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:*\\\\svchost.exe AND network_initiated:\"true\" AND src_port:\"3389\" AND dst_ip_addr.keyword:(127.* OR \\:\\:1))')\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
}