Suspicious access to sensitive file extensions

Detects known sensitive file extensions

Rule Content

- title: Suspicious access to sensitive file extensions
  id: 91c945bc-2ad1-4799-a591-4d00198a1215
  description: Detects known sensitive file extensions
  author: Samir Bousseaden
  tags:
  - attack.collection
  logsource:
    product: windows
    service: security
    category: null
  detection:
    selection:
      EventID:
      - 5145
      RelativeTargetName:
      - '*.pst'
      - '*.ost'
      - '*.msg'
      - '*.nst'
      - '*.oab'
      - '*.edb'
      - '*.nsf'
      - '*.bak'
      - '*.dmp'
      - '*.kirbi'
      - '*\ntds.dit'
      - '*\groups.xml'
      - '*.rdp'
    condition: selection
  falsepositives:
  - Help Desk operator doing backup or re-imaging end user machine or pentest or backup
    software
  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-security-*', doc_type='doc')

Run Elasticsearch Query


In [ ]:
s = searchContext.query('query_string', query='(event_id:("5145") AND share_relative_target_name.keyword:(*.pst OR *.ost OR *.msg OR *.nst OR *.oab OR *.edb OR *.nsf OR *.bak OR *.dmp OR *.kirbi OR *\\ntds.dit OR *\\groups.xml OR *.rdp))')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()