Suspicious DNS Query with B64 Encoded String

Detects suspicious DNS queries using base64 encoding

Rule Content

- title: Suspicious DNS Query with B64 Encoded String
  id: 4153a907-2451-4e4f-a578-c52bb6881432
  status: experimental
  description: Detects suspicious DNS queries using base64 encoding
  references:
  - https://github.com/krmaxwell/dns-exfiltration
  author: Florian Roth
  date: 2018/05/10
  logsource:
    category: dns
    product: null
    service: null
  detection:
    selection:
      query:
      - '*==.*'
    condition: selection
  falsepositives:
  - Unknown
  level: medium

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='query.keyword:(*\=\=.*)')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()