Windows Kernel and 3rd-party drivers exploits. Token stealing

Detection of child processes spawned with SYSTEM privileges by parents with non-SYSTEM privileges and Medium integrity level

Rule Content

- title: Windows Kernel and 3rd-party drivers exploits. Token stealing
  id: 8065b1b4-1778-4427-877f-6bf948b26d38
  description: Detection of child processes spawned with SYSTEM privileges by parents
    with non-SYSTEM privileges and Medium integrity level
  references:
  - https://www.slideshare.net/heirhabarov/hunting-for-privilege-escalation-in-windows-environment
  tags:
  - attack.privilege_escalation
  - attack.t1068
  status: experimental
  author: Teymur Kheirkhabarov (source), Daniil Yugoslavskiy (rule)
  date: 2019/06/03
  logsource:
    category: process_creation
    product: windows
    service: null
  detection:
    selection:
      ParentIntegrityLevel: Medium
      IntegrityLevel: System
      User: NT AUTHORITY\SYSTEM
    condition: selection
  falsepositives:
  - Unknown
  level: critical
  enrichment:
  - EN_0001_cache_sysmon_event_id_1_info
  - EN_0002_enrich_sysmon_event_id_1_with_parent_info

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='(ParentIntegrityLevel:"Medium" AND IntegrityLevel:"System" AND user_account:"NT\ AUTHORITY\\SYSTEM")')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()