External Disk Drive or USB Storage Device

Detects external diskdrives or plugged in USB devices

Rule Content

- title: External Disk Drive or USB Storage Device
  id: f69a87ea-955e-4fb4-adb2-bb9fd6685632
  description: Detects external diskdrives or plugged in USB devices
  status: experimental
  author: Keith Wright
  date: 2019/11/20
  tags:
  - attack.t1091
  - attack.t1200
  - attack.lateral_movement
  - attack.initial_access
  logsource:
    product: windows
    service: security
    category: null
  detection:
    selection:
      EventID:
      - 6416
      DeviceClassName: DiskDrive
    selection2:
      DeviceDescription: USB Mass Storage Device
    condition: selection or selection2
  falsepositives:
  - Legitimate administrative activity
  level: low

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-endpoint-winevent-security-*', doc_type='doc')

Run Elasticsearch Query


In [ ]:
s = searchContext.query('query_string', query='((event_id:("6416") AND DeviceClassName:"DiskDrive") OR DeviceDescription:"USB\ Mass\ Storage\ Device")')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()