Detection rules › Elastic
Potential Protocol Tunneling via Legit Utilities
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
| Tactic | Techniques |
|---|---|
| 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.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.args | in | -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:8897 | excludes:process.args |
process.name | eq | ssh.exe | excludes:process.name field:"process.name" value:"ssh.exe" |
process.code_signature.status | eq | trusted | excludes:process.code_signature.status field:"process.code_signature.status" value:"trusted" |
process.code_signature.subject_name | eq | ninjaRMM LLC | excludes:process.code_signature.subject_name field:"process.code_signature.subject_name" value:"ninjaRMM LLC" |
process.parent.command_line | wildcard | 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 | excludes:process.parent.command_line |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
event.action | eq |
| field:"EventType" kind:eq value:"start" |
process.args | wildcard |
| field:"process.args" kind:wildcard |
process.code_signature.subject_name | wildcard |
| field:"Signature" kind:wildcard value:"ngrok, Inc." |
process.command_line | wildcard |
| field:"CommandLine" kind:wildcard |
process.executable | wildcard |
| field:"Image" kind:wildcard value:"?:\Windows\System32\OpenSSH\ssh.exe" |
process.name | wildcard |
| field:"process_name" kind:wildcard value:"curl.exe" |
process.pe.original_file_name | eq |
| field:"OriginalFileName" kind:eq value:"curl.exe" |