Protocol Tunneling
Detects adversaries tunneling network communications within a separate protocol to evade detection and bypass network filtering. This detection identifies common tunneling techniques including SSH port forwarding via Plink or OpenSSH (-L/-R/-D flags), dedicated tunneling utilities (Chisel, Iodine, ptunnel, dnscat2, socat), DNS-over-HTTPS (DoH) encapsulation for C2 traffic, and native Windows netsh portproxy tunneling. Protocol tunneling allows attackers to route blocked protocols (SMB, RDP) through permitted channels, establish covert C2 channels, and bypass network appliances — as observed in Magic Hound (Plink RDP tunneling), FIN6 (Plink SSH tunnels), and FIN13 (Java-based web shell tunneling).
let TunnelingTools = dynamic(["plink.exe", "plink", "chisel.exe", "chisel", "ligolo.exe", "ligolo", "iodine.exe", "iodine", "ptunnel.exe", "ptunnel", "dns2tcp", "dnscat", "dnscat2", "httptunnel", "htc", "hts", "socat"]);
let DoHProviders = dynamic(["cloudflare-dns.com", "dns.google", "doh.opendns.com", "dns.quad9.net", "mozilla.cloudflare-dns.com", "doh.dns.apple.com"]);
let BrowserProcesses = dynamic(["chrome.exe", "firefox.exe", "msedge.exe", "brave.exe", "opera.exe", "iexplore.exe", "safari", "vivaldi.exe", "chromium"]);
let SystemProcesses = dynamic(["svchost.exe", "MsMpEng.exe", "services.exe", "wininit.exe", "dnscrypt-proxy.exe", "stubby.exe"]);
// Branch 1: Known tunneling tool execution
let KnownTools = DeviceProcessEvents
| where TimeGenerated > ago(1d)
| where FileName in~ (TunnelingTools)
| extend DetectionBranch = "KnownTunnelingTool"
| project TimeGenerated, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine, FolderPath, DetectionBranch;
// Branch 2: SSH with port-forwarding flags (OpenSSH, Plink)
let SSHTunneling = DeviceProcessEvents
| where TimeGenerated > ago(1d)
| where FileName in~ ("ssh.exe", "ssh", "plink.exe", "plink")
and (
ProcessCommandLine has "-L " or
ProcessCommandLine has "-R " or
ProcessCommandLine has "-D " or
ProcessCommandLine has "-w " or
ProcessCommandLine has "LocalForward" or
ProcessCommandLine has "RemoteForward"
)
| extend DetectionBranch = "SSHPortForwarding"
| project TimeGenerated, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine, FolderPath, DetectionBranch;
// Branch 3: Netsh portproxy (native Windows tunneling)
let NetshProxy = DeviceProcessEvents
| where TimeGenerated > ago(1d)
| where FileName =~ "netsh.exe"
and ProcessCommandLine has "portproxy"
and ProcessCommandLine has "add"
| extend DetectionBranch = "NetshPortProxy"
| project TimeGenerated, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine, FolderPath, DetectionBranch;
// Branch 4: DoH from non-browser, non-system processes
let DoHConnections = DeviceNetworkEvents
| where TimeGenerated > ago(1d)
| where RemotePort == 443
and RemoteUrl has_any (DoHProviders)
and InitiatingProcessFileName !in~ (BrowserProcesses)
and InitiatingProcessFileName !in~ (SystemProcesses)
| extend DetectionBranch = "DNSoverHTTPS", AccountName = InitiatingProcessAccountName, FileName = InitiatingProcessFileName, ProcessCommandLine = InitiatingProcessCommandLine, InitiatingProcessFileName = "", InitiatingProcessCommandLine = ""
| project TimeGenerated, DeviceName, AccountName, FileName, ProcessCommandLine, InitiatingProcessFileName, InitiatingProcessCommandLine, FolderPath = RemoteUrl, DetectionBranch;
union KnownTools, SSHTunneling, NetshProxy, DoHConnections
| sort by TimeGenerated desc Data Sources
Required Tables
False Positives
- Legitimate SSH tunneling by system administrators for database access, jump-host traversal, or remote maintenance tasks
- IT automation tools (Ansible, Puppet, SaltStack) that use SSH tunnels for agent communication and configuration management
- Developers using SSH port forwarding to reach internal services, Kubernetes API servers, or staging databases
- Corporate DNS-over-HTTPS policy enforcement by approved endpoint agents or custom DNS clients
- VPN clients or network monitoring agents that legitimately encapsulate traffic within other protocols
References (9)
- https://attack.mitre.org/techniques/T1572/
- https://www.ssh.com/academy/ssh/tunneling
- https://github.com/jpillora/chisel
- https://github.com/L-codes/Neo-reGeorg
- https://www.bleepingcomputer.com/news/security/godlua-malware-uses-dns-over-https-to-hide-command-and-control-communications/
- https://www.mandiant.com/resources/blog/fin6-cybercrime-group-expands-operations
- https://sygnia.co/blog/sygnia-investigation-elephant-beetle
- https://www.sentinelone.com/labs/aoqin-dragon-spelunking-a-nearly-decade-old-campaign-targeting-southeast-asia/
- https://www.microsoft.com/en-us/security/blog/2021/11/16/evolving-trends-in-iranian-threat-actor-activity/
Unlock Pro Content
Get the full detection package for T1572 including response playbook, investigation guide, and atomic red team tests.