USB Device Plugged

Detects plugged USB devices

Rule Content

- title: USB Device Plugged
  id: 1a4bd6e3-4c6e-405d-a9a3-53a116e341d4
  description: Detects plugged USB devices
  references:
  - https://df-stream.com/2014/01/the-windows-7-event-log-and-usb-device/
  - https://www.techrepublic.com/article/how-to-track-down-usb-flash-drive-usage-in-windows-10s-event-viewer/
  status: experimental
  author: Florian Roth
  tags:
  - attack.initial_access
  - attack.t1200
  logsource:
    product: windows
    service: driver-framework
    category: null
  detection:
    selection:
      EventID:
      - 2003
      - 2100
      - 2102
    condition: selection
  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-*', doc_type='doc')

Run Elasticsearch Query


In [ ]:
s = searchContext.query('query_string', query='event_id:("2003" OR "2100" OR "2102")')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()