WMI Spawning Windows PowerShell

Detects WMI spawning PowerShell

Rule Content

- title: WMI Spawning Windows PowerShell
  id: 692f0bec-83ba-4d04-af7e-e884a96059b6
  status: experimental
  description: Detects WMI spawning PowerShell
  references:
  - https://github.com/Neo23x0/sigma/blob/master/rules/windows/process_creation/win_shell_spawn_susp_program.yml
  - https://any.run/report/68bc255f9b0db6a0d30a8f2dadfbee3256acfe12497bf93943bc1eab0735e45e/a2385d6f-34f7-403c-90d3-b1f9d2a90a5e
  author: Markus Neis / @Karneades
  date: 2019/04/03
  tags:
  - attack.execution
  - attack.defense_evasion
  - attack.t1064
  logsource:
    category: process_creation
    product: windows
    service: null
  detection:
    selection:
      ParentImage:
      - '*\wmiprvse.exe'
      Image:
      - '*\powershell.exe'
    condition: selection
  falsepositives:
  - AppvClient
  - CCM
  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-*', doc_type='doc')

Run Elasticsearch Query


In [ ]:
s = searchContext.query('query_string', query='(process_parent_path.keyword:(*\\wmiprvse.exe) AND process_path.keyword:(*\\powershell.exe))')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()