Netsh Port Forwarding

Detects netsh commands that configure a port forwarding

Rule Content

- title: Netsh Port Forwarding
  id: 322ed9ec-fcab-4f67-9a34-e7c6aef43614
  description: Detects netsh commands that configure a port forwarding
  references:
  - https://www.fireeye.com/blog/threat-research/2019/01/bypassing-network-restrictions-through-rdp-tunneling.html
  date: 2019/01/29
  tags:
  - attack.lateral_movement
  - attack.command_and_control
  - attack.t1090
  status: experimental
  author: Florian Roth
  logsource:
    category: process_creation
    product: windows
    service: null
  detection:
    selection:
      CommandLine:
      - netsh interface portproxy add v4tov4 *
    condition: selection
  falsepositives:
  - Legitimate administration
  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\ interface\ portproxy\ add\ v4tov4\ *)')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()