mirror of https://github.com/infosecn1nja/HELK.git
145 lines
3.8 KiB
Plaintext
145 lines
3.8 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Query Registry\n",
|
|
"Adversaries may interact with the Windows Registry to gather information about the system, configuration, and installed software."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Rule Content\n",
|
|
"```\n",
|
|
"- title: Query Registry\n",
|
|
" id: 970007b7-ce32-49d0-a4a4-fbef016950bd\n",
|
|
" status: experimental\n",
|
|
" description: Adversaries may interact with the Windows Registry to gather information\n",
|
|
" about the system, configuration, and installed software.\n",
|
|
" author: Timur Zinniatullin, oscd.community\n",
|
|
" date: 2019/10/21\n",
|
|
" modified: 2019/11/04\n",
|
|
" references:\n",
|
|
" - https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1012/T1012.yaml\n",
|
|
" logsource:\n",
|
|
" category: process_creation\n",
|
|
" product: windows\n",
|
|
" service: null\n",
|
|
" detection:\n",
|
|
" selection:\n",
|
|
" Image|endswith: \\reg.exe\n",
|
|
" CommandLine|contains:\n",
|
|
" - currentVersion\\windows\n",
|
|
" - currentVersion\\runServicesOnce\n",
|
|
" - currentVersion\\runServices\n",
|
|
" - winlogon\\\n",
|
|
" - currentVersion\\shellServiceObjectDelayLoad\n",
|
|
" - currentVersion\\runOnce\n",
|
|
" - currentVersion\\runOnceEx\n",
|
|
" - currentVersion\\run\n",
|
|
" - currentVersion\\policies\\explorer\\run\n",
|
|
" - currentcontrolset\\services\n",
|
|
" condition: selection\n",
|
|
" fields:\n",
|
|
" - Image\n",
|
|
" - CommandLine\n",
|
|
" - User\n",
|
|
" - LogonGuid\n",
|
|
" - Hashes\n",
|
|
" - ParentProcessGuid\n",
|
|
" - ParentCommandLine\n",
|
|
" level: low\n",
|
|
" tags:\n",
|
|
" - attack.discovery\n",
|
|
" - attack.t1012\n",
|
|
" - attack.t1007\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='(process_path.keyword:*\\\\reg.exe AND process_command_line.keyword:(*currentVersion\\\\windows* OR *currentVersion\\\\runServicesOnce* OR *currentVersion\\\\runServices* OR *winlogon\\* OR *currentVersion\\\\shellServiceObjectDelayLoad* OR *currentVersion\\\\runOnce* OR *currentVersion\\\\runOnceEx* OR *currentVersion\\\\run* OR *currentVersion\\\\policies\\\\explorer\\\\run* OR *currentcontrolset\\\\services*))')\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
|
|
}
|