Detection rules › Elastic

Potential Protocol Tunneling via Legit Utilities

Source
github.com/elastic/protections-artifacts

Identifies the use of known legit utilities to potentially tunnel network traffic. This can be used by attackers to enable routing of network packets that would otherwise not reach their intended destination.

MITRE ATT&CK coverage

TacticTechniques
Command & Control

Rule body

[rule]
description = """
Identifies the use of known legit utilities to potentially tunnel network traffic. This can be used by attackers to
enable routing of network packets that would otherwise not reach their intended destination.
"""
id = "87aa3f52-3f7b-4d6e-aecc-101bb1275020"
license = "Elastic License v2"
name = "Potential Protocol Tunneling via Legit Utilities"
os_list = ["windows"]
reference = ["https://blog.netspi.com/how-to-access-rdp-over-a-reverse-ssh-tunnel/"]
version = "1.0.12"

query = '''
process where event.action == "start" and
 (
  /* RDP port and usual SSH tunneling related switches in command line */
  (process.command_line : "*:3389*" and process.args : ("-L", "-P", "-R", "-pw", "-ssh")) or

  (process.code_signature.subject_name : "ngrok, Inc." and process.args : ("http", "tcp", "tunnel", "tls", "start", "3389")) or

  (process.executable : "?:\\Windows\\System32\\OpenSSH\\ssh.exe" and process.command_line : ("*127.0.0.*", "*:localhost:*") and process.args : "-L") or

  (process.args : "client" and process.command_line : "* R*:socks*") or

  ((process.name : "curl.exe" or process.pe.original_file_name == "curl.exe") and process.command_line : ("*socks5h://127.0.0.*", "*socks5h:\\127.0.0.*"))
 )
and not (process.code_signature.subject_name : "ninjaRMM LLC" and process.code_signature.status : "trusted") and
not (process.name:"ssh.exe" and process.args in ("22000:127.0.0.1:1466", "localhost:8897:localhost:8897", "22000:127.0.0.1:1466",
                                                 "10005:localhost:5050", "localhost:8897:localhost:8897", "59000:localhost:5901",
                                                 "-L30000:localhost:30000", "7779:localhost:7779", "5000:localhost:5000",
                                                 "8888:localhost:8888")) and
not process.parent.command_line : ("C:\\windows\\system32\\cmd.exe /c \"\"C:\\Users\\*\\Desktop\\*.bat\" \"",
                                   "\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" ",
                                   "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe")
'''

min_endpoint_version = "7.15.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1572"
name = "Protocol Tunneling"
reference = "https://attack.mitre.org/techniques/T1572/"


[threat.tactic]
id = "TA0011"
name = "Command and Control"
reference = "https://attack.mitre.org/tactics/TA0011/"

[internal]
min_endpoint_version = "7.15.0"

Stages and Predicates

Stage 1: process

process where event.action == "start" and
 (
  (process.command_line : "*:3389*" and process.args : ("-L", "-P", "-R", "-pw", "-ssh")) or
  (process.code_signature.subject_name : "ngrok, Inc." and process.args : ("http", "tcp", "tunnel", "tls", "start", "3389")) or
  (process.executable : "?:\\Windows\\System32\\OpenSSH\\ssh.exe" and process.command_line : ("*127.0.0.*", "*:localhost:*") and process.args : "-L") or
  (process.args : "client" and process.command_line : "* R*:socks*") or
  ((process.name : "curl.exe" or process.pe.original_file_name == "curl.exe") and process.command_line : ("*socks5h://127.0.0.*", "*socks5h:\\127.0.0.*"))
 )
and not (process.code_signature.subject_name : "ninjaRMM LLC" and process.code_signature.status : "trusted") and
not (process.name:"ssh.exe" and process.args in ("22000:127.0.0.1:1466", "localhost:8897:localhost:8897", "22000:127.0.0.1:1466",
                                                 "10005:localhost:5050", "localhost:8897:localhost:8897", "59000:localhost:5901",
                                                 "-L30000:localhost:30000", "7779:localhost:7779", "5000:localhost:5000",
                                                 "8888:localhost:8888")) and
not process.parent.command_line : ("C:\\windows\\system32\\cmd.exe /c \"\"C:\\Users\\*\\Desktop\\*.bat\" \"",
                                   "\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" ",
                                   "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe")

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.argsin-L30000:localhost:30000, 10005:localhost:5050, 22000:127.0.0.1:1466, 5000:localhost:5000, 59000:localhost:5901, 7779:localhost:7779, 8888:localhost:8888, localhost:8897:localhost:8897excludes:process.args
process.nameeqssh.exeexcludes:process.name field:"process.name" value:"ssh.exe"
process.code_signature.statuseqtrustedexcludes:process.code_signature.status field:"process.code_signature.status" value:"trusted"
process.code_signature.subject_nameeqninjaRMM LLCexcludes:process.code_signature.subject_name field:"process.code_signature.subject_name" value:"ninjaRMM LLC"
process.parent.command_linewildcardC:\windows\system32\cmd.exe /c ""C:\Users\*\Desktop\*.bat" ", "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" , C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exeexcludes:process.parent.command_line

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • start corpus 391 (elastic 391)
field:"EventType" kind:eq value:"start"
process.argswildcard
  • -L corpus 17 (elastic 17)
  • -P corpus 5 (elastic 5)
  • -R corpus 19 (elastic 19)
  • -pw
  • -ssh
  • 3389
  • client corpus 2 (elastic 2)
  • http
  • start corpus 7 (elastic 7)
  • tcp
  • tls
  • tunnel corpus 6 (elastic 6)
field:"process.args" kind:wildcard
process.code_signature.subject_namewildcard
  • ngrok, Inc.
field:"Signature" kind:wildcard value:"ngrok, Inc."
process.command_linewildcard
  • * R*:socks*
  • *127.0.0.*
  • *:3389* corpus 4 (sigma 3, elastic 1)
  • *:localhost:*
  • *socks5h://127.0.0.*
  • *socks5h:\127.0.0.*
field:"CommandLine" kind:wildcard
process.executablewildcard
  • ?:\Windows\System32\OpenSSH\ssh.exe corpus 3 (elastic 3)
field:"Image" kind:wildcard value:"?:\Windows\System32\OpenSSH\ssh.exe"
process.namewildcard
  • curl.exe corpus 34 (elastic 31, splunk 3)
field:"process_name" kind:wildcard value:"curl.exe"
process.pe.original_file_nameeq
  • curl.exe corpus 24 (sigma 13, elastic 8, splunk 3)
field:"OriginalFileName" kind:eq value:"curl.exe"