NTFS Alternate Data Stream

Detects writing data into NTFS alternate data streams from powershell. Needs Script Block Logging.

Rule Content

- title: NTFS Alternate Data Stream
  id: 8c521530-5169-495d-a199-0a3a881ad24e
  status: experimental
  description: Detects writing data into NTFS alternate data streams from powershell.
    Needs Script Block Logging.
  references:
  - http://www.powertheshell.com/ntfsstreams/
  tags:
  - attack.defense_evasion
  - attack.t1096
  author: Sami Ruohonen
  logsource:
    product: windows
    service: powershell
    definition: It is recommended to use the new "Script Block Logging" of PowerShell
      v5 https://adsecurity.org/?p=2277
    category: null
  detection:
    keyword1:
    - set-content
    keyword2:
    - -stream
    condition: keyword1 and keyword2
  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='\*.keyword:(*set\-content* AND *\-stream*)')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()