Suspicious PowerShell Keywords

Detects keywords that could indicate the use of some PowerShell exploitation framework

Rule Content

- title: Suspicious PowerShell Keywords
  id: 1f49f2ab-26bc-48b3-96cc-dcffbc93eadf
  status: experimental
  description: Detects keywords that could indicate the use of some PowerShell exploitation
    framework
  date: 2019/02/11
  author: Florian Roth
  references:
  - https://posts.specterops.io/entering-a-covenant-net-command-and-control-e11038bcf462
  tags:
  - attack.execution
  - attack.t1086
  logsource:
    product: windows
    service: powershell
    definition: It is recommended to use the new "Script Block Logging" of PowerShell
      v5 https://adsecurity.org/?p=2277
    category: null
  detection:
    keywords:
      Message:
      - '*[System.Reflection.Assembly]::Load*'
    condition: keywords
  falsepositives:
  - Penetration tests
  level: high

Querying Elasticsearch

Import Libraries


In [ ]:
from elasticsearch import Elasticsearch
from elasticsearch_dsl import Search
import pandas as pd

Initialize Elasticsearch client


In [ ]:
es = Elasticsearch(['http://helk-elasticsearch:9200'])
searchContext = Search(using=es, index='logs-endpoint-winevent-powershell-*', doc_type='doc')

Run Elasticsearch Query


In [ ]:
s = searchContext.query('query_string', query='Message.keyword:(*\[System.Reflection.Assembly\]\:\:Load*)')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()