Hijack legit RDP session to move laterally

Detects the usage of tsclient share to place a backdoor on the RDP source machine's startup folder

Rule Content

- title: Hijack legit RDP session to move laterally
  id: 52753ea4-b3a0-4365-910d-36cff487b789
  status: experimental
  description: Detects the usage of tsclient share to place a backdoor on the RDP
    source machine's startup folder
  date: 2019/02/21
  author: Samir Bousseaden
  logsource:
    product: windows
    service: sysmon
    category: null
  detection:
    selection:
      EventID: 11
      Image: '*\mstsc.exe'
      TargetFileName: '*\Microsoft\Windows\Start Menu\Programs\Startup\\*'
    condition: selection
  falsepositives:
  - unknown
  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-endpoint-winevent-sysmon-*', doc_type='doc')

Run Elasticsearch Query


In [ ]:
s = searchContext.query('query_string', query='(event_id:"11" AND process_path.keyword:*\\mstsc.exe AND TargetFileName.keyword:*\\Microsoft\\Windows\\Start\ Menu\\Programs\\Startup\\*)')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()