MMC Spawning Windows Shell

Detects a Windows command line executable started from MMC.

Rule Content

- title: MMC Spawning Windows Shell
  id: 05a2ab7e-ce11-4b63-86db-ab32e763e11d
  status: experimental
  description: Detects a Windows command line executable started from MMC.
  author: Karneades, Swisscom CSIRT
  tags:
  - attack.lateral_movement
  - attack.t1175
  logsource:
    category: process_creation
    product: windows
    service: null
  detection:
    selection:
      ParentImage: '*\mmc.exe'
      Image:
      - '*\cmd.exe'
      - '*\powershell.exe'
      - '*\wscript.exe'
      - '*\cscript.exe'
      - '*\sh.exe'
      - '*\bash.exe'
      - '*\reg.exe'
      - '*\regsvr32.exe'
      - '*\BITSADMIN*'
    condition: selection
  fields:
  - CommandLine
  - Image
  - ParentCommandLine
  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:*\\mmc.exe AND process_path.keyword:(*\\cmd.exe OR *\\powershell.exe OR *\\wscript.exe OR *\\cscript.exe OR *\\sh.exe OR *\\bash.exe OR *\\reg.exe OR *\\regsvr32.exe OR *\\BITSADMIN*))')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()