mirror of https://github.com/infosecn1nja/HELK.git
140 lines
3.4 KiB
Plaintext
140 lines
3.4 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# AD Privileged Users or Groups Reconnaissance\n",
|
|
"Detect priv users or groups recon based on 4661 eventid and known privileged users or groups SIDs"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Rule Content\n",
|
|
"```\n",
|
|
"- title: AD Privileged Users or Groups Reconnaissance\n",
|
|
" id: 35ba1d85-724d-42a3-889f-2e2362bcaf23\n",
|
|
" description: Detect priv users or groups recon based on 4661 eventid and known privileged\n",
|
|
" users or groups SIDs\n",
|
|
" references:\n",
|
|
" - https://blog.menasec.net/2019/02/threat-hunting-5-detecting-enumeration.html\n",
|
|
" tags:\n",
|
|
" - attack.discovery\n",
|
|
" - attack.t1087\n",
|
|
" status: experimental\n",
|
|
" author: Samir Bousseaden\n",
|
|
" logsource:\n",
|
|
" product: windows\n",
|
|
" service: security\n",
|
|
" definition: 'Requirements: enable Object Access SAM on your Domain Controllers'\n",
|
|
" category: null\n",
|
|
" detection:\n",
|
|
" selection:\n",
|
|
" EventID: 4661\n",
|
|
" ObjectType:\n",
|
|
" - SAM_USER\n",
|
|
" - SAM_GROUP\n",
|
|
" ObjectName:\n",
|
|
" - '*-512'\n",
|
|
" - '*-502'\n",
|
|
" - '*-500'\n",
|
|
" - '*-505'\n",
|
|
" - '*-519'\n",
|
|
" - '*-520'\n",
|
|
" - '*-544'\n",
|
|
" - '*-551'\n",
|
|
" - '*-555'\n",
|
|
" - '*admin*'\n",
|
|
" condition: selection\n",
|
|
" falsepositives:\n",
|
|
" - if source account name is not an admin then its super suspicious\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-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='(event_id:\"4661\" AND object_type:(\"SAM_USER\" OR \"SAM_GROUP\") AND object_name.keyword:(*\\-512 OR *\\-502 OR *\\-500 OR *\\-505 OR *\\-519 OR *\\-520 OR *\\-544 OR *\\-551 OR *\\-555 OR *admin*))')\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
|
|
}
|