mirror of https://github.com/infosecn1nja/HELK.git
131 lines
3.1 KiB
Plaintext
131 lines
3.1 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# System Owner or User Discovery\n",
|
|
"Adversaries may use the information from System Owner/User Discovery during automated discovery to shape follow-on behaviors, including whether or not the adversary fully infects the target and/or attempts specific actions."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Rule Content\n",
|
|
"```\n",
|
|
"- title: System Owner or User Discovery\n",
|
|
" id: 9a0d8ca0-2385-4020-b6c6-cb6153ca56f3\n",
|
|
" status: experimental\n",
|
|
" description: Adversaries may use the information from System Owner/User Discovery\n",
|
|
" during automated discovery to shape follow-on behaviors, including whether or\n",
|
|
" not the adversary fully infects the target and/or attempts specific actions.\n",
|
|
" author: Timur Zinniatullin, oscd.community\n",
|
|
" date: 2019/10/21\n",
|
|
" references:\n",
|
|
" - https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1033/T1033.yaml\n",
|
|
" logsource:\n",
|
|
" product: linux\n",
|
|
" service: auditd\n",
|
|
" category: null\n",
|
|
" detection:\n",
|
|
" selection:\n",
|
|
" type: EXECVE\n",
|
|
" a0:\n",
|
|
" - users\n",
|
|
" - w\n",
|
|
" - who\n",
|
|
" condition: selection\n",
|
|
" falsepositives:\n",
|
|
" - Admin activity\n",
|
|
" level: low\n",
|
|
" tags:\n",
|
|
" - attack.discovery\n",
|
|
" - attack.t1033\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='(type:\"EXECVE\" AND a0:(\"users\" OR \"w\" OR \"who\"))')\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
|
|
}
|