Crypto Miner User Agent

Detects suspicious user agent strings used by crypto miners in proxy logs

Rule Content

- title: Crypto Miner User Agent
  id: fa935401-513b-467b-81f4-f9e77aa0dd78
  status: experimental
  description: Detects suspicious user agent strings used by crypto miners in proxy
    logs
  references:
  - https://github.com/xmrig/xmrig/blob/da22b3e6c45825f3ac1f208255126cb8585cd4fc/src/base/kernel/Platform_win.cpp#L65
  - https://github.com/xmrig/xmrig/blob/427b6516e0550200c17ca28675118f0fffcc323f/src/version.h
  author: Florian Roth
  date: 2019/10/21
  logsource:
    category: proxy
    product: null
    service: null
  detection:
    selection:
      c-useragent:
      - XMRig *
      - ccminer*
    condition: selection
  fields:
  - ClientIP
  - c-uri
  - c-useragent
  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-*', doc_type='doc')

Run Elasticsearch Query


In [ ]:
s = searchContext.query('query_string', query='c-useragent.keyword:(XMRig\ * OR ccminer*)')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()