Netsh RDP Port Forwarding

Detects netsh commands that configure a port forwarding of port 3389 used for RDP

Rule Content

- title: Netsh RDP Port Forwarding
  id: 782d6f3e-4c5d-4b8c-92a3-1d05fed72e63
  description: Detects netsh commands that configure a port forwarding of port 3389
    used for RDP
  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.t1021
  - car.2013-07-002
  status: experimental
  author: Florian Roth
  logsource:
    category: process_creation
    product: windows
    service: null
  detection:
    selection:
      CommandLine:
      - netsh i* p*=3389 c*
    condition: selection
  falsepositives:
  - Legitimate administration
  level: high

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\ i*\ p*\=3389\ c*)')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()