Detection rules › Splunk

Visual Studio Code Tunnel Execution (Sysmon)

Group by
_time, host
Source
github.com/anvilogic-forge/armory

Adversaries may communicate using application layer protocols associated with web traffic to avoid detection/network filtering by blending in with existing traffic. Commands to the remote system, and often the results of those commands, will be embedded within the protocol traffic between the client and server. This use case detects the execution of Visual Studio Code tunnel in attempt to establish a C2 channel, accounting for instances where the binary has been renamed.

MITRE ATT&CK coverage

References

Telemetry coverage

ProviderRecord / event type
SysmonEvent ID 1: Process creation

Rule body

id: '40420.73844'
title: Visual Studio Code Tunnel Execution
description: Adversaries may communicate using application layer protocols associated
  with web traffic to avoid detection/network filtering by blending in with existing
  traffic. Commands to the remote system, and often the results of those commands,
  will be embedded within the protocol traffic between the client and server. This
  use case detects the execution of Visual Studio Code tunnel in attempt to establish
  a C2 channel, accounting for instances where the binary has been renamed.
logic_format: Splunk
logic: ' `get_endpoint_data` `get_endpoint_data_sysmon` (TERM(EventCode=1) OR "<EventID>1<")
  (".exe" "tunnel") OR (".exe" "tunnel" "--name " "--accept-server-license-terms")
  OR (" tunnel" "cmd.exe" "/d" "/c" "\servers\Stable-" "code-server.cmd") | where
  match(process, "(?i)\.exe\s+tunnel$") or (match(process, "(?i)\.exe\s+tunnel") and
  match(process, "(?i)--name\s+") and match(process, "(?i)--accept-server-license-terms"))
  or (match(parent_process, "(?i)\stunnel$") and match(process_name, "(?i)cmd\.exe")
  and match(process, "\s/d\s") and match(process, "\s/c\s") and match(process, "(?i)\x5cservers\x5cStable-")
  and match(process, "(?i)code-server\.cmd")) | table _time, host, user, process,
  process_*, parent_* | bin span=1s | stats values(*) as * by _time, host '
techniques:
- command-and-control:application layer protocol:web protocols
technique_id:
- T1071.001
data_category:
- Windows Sysmon
references:
- https://detection.fyi/sigmahq/sigma/windows/process_creation/proc_creation_win_vscode_tunnel_execution/
- https://attack.mitre.org/techniques/T1071/001/
- https://www.sentinelone.com/labs/operation-digital-eye-chinese-apt-compromises-critical-digital-infrastructure-via-visual-studio-code-tunnels/

Stages and Predicates

Stage 1: search

`get_endpoint_data` `get_endpoint_data_sysmon` (TERM(EventCode=1) OR "<EventID>1<") (".exe" "tunnel") OR (".exe" "tunnel" "--name " "--accept-server-license-terms") OR (" tunnel" "cmd.exe" "/d" "/c" "\servers\Stable-" "code-server.cmd")

Stage 2: where

| where match(process, "(?i)\.exe\s+tunnel$") or (match(process, "(?i)\.exe\s+tunnel") and match(process, "(?i)--name\s+") and match(process, "(?i)--accept-server-license-terms")) or (match(parent_process, "(?i)\stunnel$") and match(process_name, "(?i)cmd\.exe") and match(process, "\s/d\s") and match(process, "\s/c\s") and match(process, "(?i)\x5cservers\x5cStable-") and match(process, "(?i)code-server\.cmd"))

Stage 3: table

| table _time, host, user, process, process_*, parent_*

Stage 4: bucket

| bin span=1s

Stage 5: stats

| stats values(*) as * by _time, host

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
EventCodeeq
  • 1 corpus 241 (splunk 225, kusto 15, elastic 1)
field:"EventID" kind:eq value:"1"
parent_processregex_match
  • "(?i)\stunnel$"
field:"ParentCommandLine" kind:regex_match
processregex_match
  • "(?i)--accept-server-license-terms"
  • "(?i)--name\s+"
  • "(?i).exe\s+tunnel"
  • "(?i).exe\s+tunnel$"
  • "(?i)\x5cservers\x5cStable-"
  • "(?i)code-server.cmd"
  • "\s/c\s"
  • "\s/d\s"
field:"CommandLine" kind:regex_match
process_nameregex_match
  • "(?i)cmd.exe" corpus 3 (splunk 3)
field:"process_name" kind:regex_match

Search terms

These SPL tokens match against raw event text.

StageTerm
1"<EventID>1<"
1".exe"
1"tunnel"
1".exe"
1"tunnel"
1"--name "
1"--accept-server-license-terms"
1" tunnel"
1"cmd.exe"
1"/d"
1"/c"
1"\servers\Stable-"
1"code-server.cmd"