PowerShell PSAttack

Detects the use of PSAttack PowerShell hack tool

Rule Content

- title: PowerShell PSAttack
  id: b7ec41a4-042c-4f31-a5db-d0fcde9fa5c5
  status: experimental
  description: Detects the use of PSAttack PowerShell hack tool
  references:
  - https://adsecurity.org/?p=2921
  tags:
  - attack.execution
  - attack.t1086
  author: Sean Metcalf (source), Florian Roth (rule)
  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:
    selection:
      EventID: 4103
    keyword:
    - PS ATTACK!!!
    condition: all of them
  falsepositives:
  - Pentesters
  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='(event_id:"4103" AND "PS\ ATTACK\!\!\!")')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()