Encoded FromBase64String

Detects a base64 encoded FromBase64String keyword in a process command line

Rule Content

- title: Encoded FromBase64String
  id: fdb62a13-9a81-4e5c-a38f-ea93a16f6d7c
  status: experimental
  description: Detects a base64 encoded FromBase64String keyword in a process command
    line
  author: Florian Roth
  date: 2019/08/24
  tags:
  - attack.t1086
  - attack.t1140
  - attack.execution
  - attack.defense_evasion
  logsource:
    category: process_creation
    product: windows
    service: null
  detection:
    selection:
      CommandLine|base64offset|contains: ::FromBase64String
    condition: selection
  fields:
  - CommandLine
  - ParentCommandLine
  falsepositives:
  - unknown
  level: critical

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='process_command_line.keyword:(*OjpGcm9tQmFzZTY0U3RyaW5n* OR *o6RnJvbUJhc2U2NFN0cmluZ* OR *6OkZyb21CYXNlNjRTdHJpbm*)')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()