WMIExec VBS Script

Detects suspicious file execution by wscript and cscript

Rule Content

- title: WMIExec VBS Script
  id: 966e4016-627f-44f7-8341-f394905c361f
  description: Detects suspicious file execution by wscript and cscript
  author: Florian Roth
  references:
  - https://www.pwc.co.uk/cyber-security/pdf/cloud-hopper-annex-b-final.pdf
  tags:
  - attack.execution
  - attack.g0045
  - attack.t1064
  logsource:
    category: process_creation
    product: windows
    service: null
  detection:
    selection:
      Image: '*\cscript.exe'
      CommandLine: '*.vbs /shell *'
    condition: selection
  fields:
  - CommandLine
  - ParentCommandLine
  falsepositives:
  - Unlikely
  level: critical

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_path.keyword:*\\cscript.exe AND process_command_line.keyword:*.vbs\ \/shell\ *)')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()