Antivirus Web Shell Detection

Detects a highly relevant Antivirus alert that reports a web shell

Rule Content

- title: Antivirus Web Shell Detection
  id: fdf135a2-9241-4f96-a114-bb404948f736
  description: Detects a highly relevant Antivirus alert that reports a web shell
  date: 2018/09/09
  modified: 2019/10/04
  author: Florian Roth
  references:
  - https://www.nextron-systems.com/2018/09/08/antivirus-event-analysis-cheat-sheet-v1-4/
  tags:
  - attack.persistence
  - attack.t1100
  logsource:
    product: antivirus
    service: null
    category: null
  detection:
    selection:
      Signature:
      - PHP/Backdoor*
      - JSP/Backdoor*
      - ASP/Backdoor*
      - Backdoor.PHP*
      - Backdoor.JSP*
      - Backdoor.ASP*
      - '*Webshell*'
    condition: selection
  fields:
  - FileName
  - User
  falsepositives:
  - Unlikely
  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='signature.keyword:(PHP\/Backdoor* OR JSP\/Backdoor* OR ASP\/Backdoor* OR Backdoor.PHP* OR Backdoor.JSP* OR Backdoor.ASP* OR *Webshell*)')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()