Whoami as LOCAL_SYSTEM

Detects the execution of whoami as LOCAL_SYSTEM, often used after privilege escalation by attackers who want to evaluate the new user context

Rule Content

- title: Whoami as LOCAL_SYSTEM
  id: 1453b1a4-261b-4daf-afe1-2a400a838b5c
  status: experimental
  description: Detects the execution of whoami as LOCAL_SYSTEM, often used after privilege
    escalation by attackers who want to evaluate the new user context
  author: Florian Roth
  date: 2019/12/22
  tags:
  - attack.discovery
  - attack.t1033
  - car.2016-03-001
  logsource:
    category: process_creation
    product: windows
    service: null
  detection:
    selection:
      Image|contains: \whoami.exe
      User: NT AUTHORITY\SYSTEM
    condition: selection
  falsepositives:
  - Admin activity
  - Scripts and administrative tools used in the monitored environment
  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:*\\whoami.exe* 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()