Webshell Remote Command Execution

Detects posible command execution by web application/web shell

Rule Content

- title: Webshell Remote Command Execution
  id: c0d3734d-330f-4a03-aae2-65dacc6a8222
  status: experimental
  description: Detects posible command execution by web application/web shell
  tags:
  - attack.persistence
  - attack.t1100
  references:
  - personal experience
  author: Ilyas Ochkov, Beyu Denis, oscd.community
  date: 2019/10/12
  modified: 2019/11/04
  logsource:
    product: linux
    service: auditd
    category: null
  detection:
    selection:
      type: SYSCALL
      SYSCALL: execve
      key: detect_execve_www
    condition: selection
  falsepositives:
  - Admin activity
  - Crazy web applications
  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='(type:"SYSCALL" AND SYSCALL:"execve" AND key:"detect_execve_www")')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()