Suspicious VSFTPD Error Messages

Detects suspicious VSFTPD error messages that indicate a fatal or suspicious error that could be caused by exploiting attempts

Rule Content

- title: Suspicious VSFTPD Error Messages
  id: 377f33a1-4b36-4ee1-acee-1dbe4b43cfbe
  description: Detects suspicious VSFTPD error messages that indicate a fatal or suspicious
    error that could be caused by exploiting attempts
  references:
  - https://github.com/dagwieers/vsftpd/
  author: Florian Roth
  date: 2017/07/05
  logsource:
    product: linux
    service: vsftpd
    category: null
  detection:
    keywords:
    - 'Connection refused: too many sessions for this address.'
    - 'Connection refused: tcp_wrappers denial.'
    - Bad HTTP verb.
    - port and pasv both active
    - pasv and port both active
    - Transfer done (but failed to open directory).
    - Could not set file modification time.
    - 'bug: pid active in ptrace_sandbox_free'
    - PTRACE_SETOPTIONS failure
    - 'weird status:'
    - couldn't handle sandbox event
    - syscall * out of bounds
    - 'syscall not permitted:'
    - 'syscall validate failed:'
    - Input line too long.
    - poor buffer accounting in str_netfd_alloc
    - vsf_sysutil_read_loop
    condition: keywords
  falsepositives:
  - Unknown
  level: medium

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='\*.keyword:(*Connection\ refused\:\ too\ many\ sessions\ for\ this\ address.* OR *Connection\ refused\:\ tcp_wrappers\ denial.* OR *Bad\ HTTP\ verb.* OR *port\ and\ pasv\ both\ active* OR *pasv\ and\ port\ both\ active* OR *Transfer\ done\ \(but\ failed\ to\ open\ directory\).* OR *Could\ not\ set\ file\ modification\ time.* OR *bug\:\ pid\ active\ in\ ptrace_sandbox_free* OR *PTRACE_SETOPTIONS\ failure* OR *weird\ status\:* OR *couldn't\ handle\ sandbox\ event* OR *syscall\ *\ out\ of\ bounds* OR *syscall\ not\ permitted\:* OR *syscall\ validate\ failed\:* OR *Input\ line\ too\ long.* OR *poor\ buffer\ accounting\ in\ str_netfd_alloc* OR *vsf_sysutil_read_loop*)')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()