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

142 lines
3.6 KiB
Plaintext
Raw Normal View History

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Pass the Hash Activity\n",
"Detects the attack technique pass the hash which is used to move laterally inside the network"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: Pass the Hash Activity\n",
" id: f8d98d6c-7a07-4d74-b064-dd4a3c244528\n",
" status: experimental\n",
" description: Detects the attack technique pass the hash which is used to move laterally\n",
" inside the network\n",
" references:\n",
" - https://github.com/iadgov/Event-Forwarding-Guidance/tree/master/Events\n",
" author: Ilias el Matani (rule), The Information Assurance Directorate at the NSA\n",
" (method)\n",
" tags:\n",
" - attack.lateral_movement\n",
" - attack.t1075\n",
" - car.2016-04-004\n",
" logsource:\n",
" product: windows\n",
" service: security\n",
" definition: The successful use of PtH for lateral movement between workstations\n",
" would trigger event ID 4624, a failed logon attempt would trigger an event ID\n",
" 4625\n",
" category: null\n",
" detection:\n",
" selection:\n",
" - EventID: 4624\n",
" LogonType: '3'\n",
" LogonProcessName: NtLmSsp\n",
" WorkstationName: '%Workstations%'\n",
" ComputerName: '%Workstations%'\n",
" - EventID: 4625\n",
" LogonType: '3'\n",
" LogonProcessName: NtLmSsp\n",
" WorkstationName: '%Workstations%'\n",
" ComputerName: '%Workstations%'\n",
" filter:\n",
" AccountName: ANONYMOUS LOGON\n",
" condition: selection and not filter\n",
" falsepositives:\n",
" - Administrator activity\n",
" - Penetration tests\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-security-*', 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='((logon_type:\"3\" AND logon_process_name:\"NtLmSsp\" AND src_host_name:\"%Workstations%\" AND host_name:\"%Workstations%\" AND (event_id:\"4624\" OR event_id:\"4625\")) AND (NOT (user_name:\"ANONYMOUS\\ LOGON\")))')\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
}