Capture a Network Trace with netsh.exe

Detects capture a network trace via netsh.exe trace functionality

Rule Content

- title: Capture a Network Trace with netsh.exe
  id: d3c3861d-c504-4c77-ba55-224ba82d0118
  status: experimental
  description: Detects capture a network trace via netsh.exe trace functionality
  references:
  - https://blogs.msdn.microsoft.com/canberrapfe/2012/03/30/capture-a-network-trace-without-installing-anything-capture-a-network-trace-of-a-reboot/
  author: Kutepov Anton, oscd.community
  date: 2019/10/24
  tags:
  - attack.discovery
  - attack.t1040
  logsource:
    category: process_creation
    product: windows
    service: null
  detection:
    selection:
      CommandLine|contains|all:
      - netsh
      - trace
      - start
    condition: selection
  falsepositives:
  - Legitimate administrator or user uses netsh.exe trace functionality for legitimate
    reason
  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='(process_command_line.keyword:*netsh* AND process_command_line.keyword:*trace* AND process_command_line.keyword:*start*)')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()