Shellshock Expression

Detects shellshock expressions in log files

Rule Content

- title: Shellshock Expression
  id: c67e0c98-4d39-46ee-8f6b-437ebf6b950e
  description: Detects shellshock expressions in log files
  references:
  - http://rubular.com/r/zxBfjWfFYs
  logsource:
    product: linux
    service: null
    category: null
  detection:
    expression:
    - /\(\)\s*\t*\{.*;\s*\}\s*;/
    condition: expression
  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='\/\\\(\\\)\\s*\\t*\\\{.*;\\s*\\\}\\s*;\/')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()