PowerShell called from an Executable Version Mismatch

Detects PowerShell called from an executable by the version mismatch method

Rule Content

- title: PowerShell called from an Executable Version Mismatch
  id: c70e019b-1479-4b65-b0cc-cd0c6093a599
  status: experimental
  description: Detects PowerShell called from an executable by the version mismatch
    method
  references:
  - https://adsecurity.org/?p=2921
  tags:
  - attack.defense_evasion
  - attack.execution
  - attack.t1086
  author: Sean Metcalf (source), Florian Roth (rule)
  logsource:
    product: windows
    service: powershell-classic
    category: null
  detection:
    selection1:
      EventID: 400
      EngineVersion:
      - 2.*
      - 4.*
      - 5.*
      HostVersion: 3.*
    condition: selection1
  falsepositives:
  - Penetration Tests
  - Unknown
  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:"400" AND powershell.engine.version.keyword:(2.* OR 4.* OR 5.*) AND powershell.host.version.keyword:3.*)')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()