Whoami Execution

Detects the execution of whoami, which is often used by attackers after exloitation / privilege escalation but rarely used by administrators

Rule Content

- title: Whoami Execution
  id: e28a5a99-da44-436d-b7a0-2afc20a5f413
  status: experimental
  description: Detects the execution of whoami, which is often used by attackers after
    exloitation / privilege escalation but rarely used by administrators
  references:
  - https://brica.de/alerts/alert/public/1247926/agent-tesla-keylogger-delivered-inside-a-power-iso-daa-archive/
  - https://app.any.run/tasks/7eaba74e-c1ea-400f-9c17-5e30eee89906/
  author: Florian Roth
  date: 2018/08/13
  tags:
  - attack.discovery
  - attack.t1033
  - car.2016-03-001
  logsource:
    category: process_creation
    product: windows
    service: null
  detection:
    selection:
      Image: '*\whoami.exe'
    selection2:
      OriginalFileName: whoami.exe
    condition: selection or selection2
  falsepositives:
  - Admin activity
  - Scripts and administrative tools used in the monitored environment
  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_path.keyword:*\\whoami.exe OR file_name_original:"whoami.exe")')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()