Renamed PowerShell

Detects the execution of a renamed PowerShell often used by attackers or malware

Rule Content

- title: Renamed PowerShell
  id: d178a2d7-129a-4ba4-8ee6-d6e1fecd5d20
  status: experimental
  description: Detects the execution of a renamed PowerShell often used by attackers
    or malware
  references:
  - https://twitter.com/christophetd/status/1164506034720952320
  author: Florian Roth
  date: 2019/08/22
  tags:
  - car.2013-05-009
  logsource:
    product: windows
    service: sysmon
    category: null
  detection:
    selection:
      Description: Windows PowerShell
      Company: Microsoft Corporation
    filter:
      Image:
      - '*\powershell.exe'
      - '*\powershell_ise.exe'
    condition: selection and not filter
  falsepositives:
  - Unknown
  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-endpoint-winevent-sysmon-*', doc_type='doc')

Run Elasticsearch Query


In [ ]:
s = searchContext.query('query_string', query='((file_description:"Windows\ PowerShell" AND file_company:"Microsoft\ Corporation") AND (NOT (process_path.keyword:(*\\powershell.exe OR *\\powershell_ise.exe))))')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()