PowerShell Credential Prompt

Detects PowerShell calling a credential prompt

Rule Content

- title: PowerShell Credential Prompt
  id: ca8b77a9-d499-4095-b793-5d5f330d450e
  status: experimental
  description: Detects PowerShell calling a credential prompt
  references:
  - https://twitter.com/JohnLaTwC/status/850381440629981184
  - https://t.co/ezOTGy1a1G
  tags:
  - attack.execution
  - attack.credential_access
  - attack.t1086
  author: John Lambert (idea), Florian Roth (rule)
  logsource:
    product: windows
    service: powershell
    definition: Script block logging must be enabled
    category: null
  detection:
    selection:
      EventID: 4104
    keyword:
      Message:
      - '*PromptForCredential*'
    condition: all of them
  falsepositives:
  - Unknown
  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-endpoint-winevent-powershell-*', doc_type='doc')

Run Elasticsearch Query


In [ ]:
s = searchContext.query('query_string', query='(event_id:"4104" AND Message.keyword:(*PromptForCredential*))')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()