HELK/docker/helk-jupyter/notebooks/sigma/win_process_creation_bitsad...

138 lines
3.1 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Bitsadmin Download\n",
"Detects usage of bitsadmin downloading a file"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Rule Content\n",
"```\n",
"- title: Bitsadmin Download\n",
" id: d059842b-6b9d-4ed1-b5c3-5b89143c6ede\n",
" status: experimental\n",
" description: Detects usage of bitsadmin downloading a file\n",
" references:\n",
" - https://blog.netspi.com/15-ways-to-download-a-file/#bitsadmin\n",
" - https://isc.sans.edu/diary/22264\n",
" tags:\n",
" - attack.defense_evasion\n",
" - attack.persistence\n",
" - attack.t1197\n",
" - attack.s0190\n",
" date: 2017/03/09\n",
" modified: 2019/12/06\n",
" author: Michael Haag\n",
" logsource:\n",
" category: process_creation\n",
" product: windows\n",
" service: null\n",
" detection:\n",
" selection1:\n",
" Image:\n",
" - '*\\bitsadmin.exe'\n",
" CommandLine:\n",
" - '* /transfer *'\n",
" selection2:\n",
" CommandLine:\n",
" - '*copy bitsadmin.exe*'\n",
" condition: selection1 or selection2\n",
" fields:\n",
" - CommandLine\n",
" - ParentCommandLine\n",
" falsepositives:\n",
" - Some legitimate apps use this, but limited.\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-*', 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:(*\\\\bitsadmin.exe) AND process_command_line.keyword:(*\\ \\/transfer\\ *)) OR process_command_line.keyword:(*copy\\ bitsadmin.exe*))')\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
}