Suspicious XOR Encoded PowerShell Command Line

Detects suspicious powershell process which includes bxor command, alternatvide obfuscation method to b64 encoded commands.

Rule Content

- title: Suspicious XOR Encoded PowerShell Command Line
  id: bb780e0c-16cf-4383-8383-1e5471db6cf9
  description: Detects suspicious powershell process which includes bxor command,
    alternatvide obfuscation method to b64 encoded commands.
  status: experimental
  author: Sami Ruohonen
  date: 2018/09/05
  tags:
  - attack.execution
  - attack.t1086
  detection:
    selection:
      CommandLine:
      - '* -bxor*'
    condition: selection
  falsepositives:
  - unknown
  level: medium
  logsource:
    category: process_creation
    product: windows
    service: null

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

Show Results


In [ ]:
df.head()