Detect Exfiltration Over C2 Channel in Splunk
Adversaries may steal data by exfiltrating it over an existing command and control channel. Stolen data is encoded into the normal communications channel using the same protocol as command and control communications. This technique is particularly challenging to detect because exfiltration traffic is indistinguishable from regular C2 beaconing — adversaries embed collected data inside HTTP POST bodies, DNS query labels, custom binary protocol frames, or other C2 protocol fields. Detection requires correlating large outbound data volumes, repeated connection patterns, and sensitive file access rather than inspecting payload content. Real-world actors observed using this technique include Scattered Spider (VMware vCenter via Teleport), OilRig/APT34 (OneDrive-based C2), and malware families PoetRAT, Machete, Shark, StrelaStealer, BeaverTail, SLOTHFULMEDIA, Sagerunex, and Bandook. The technique spans Windows, Linux, macOS, and ESXi platforms and commonly exploits encrypted C2 channels (HTTPS, DNS-over-HTTPS) to blend with legitimate traffic.
MITRE ATT&CK
- Tactic
- Exfiltration
- Technique
- T1041 Exfiltration Over C2 Channel
- Canonical reference
- https://attack.mitre.org/techniques/T1041/
SPL Detection Query
index=wineventlog sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=3 Initiated="true"
NOT (DestinationIp="10.*" OR DestinationIp="172.16.*" OR DestinationIp="172.17.*"
OR DestinationIp="172.18.*" OR DestinationIp="172.19.*" OR DestinationIp="172.20.*"
OR DestinationIp="172.21.*" OR DestinationIp="172.22.*" OR DestinationIp="172.23.*"
OR DestinationIp="172.24.*" OR DestinationIp="172.25.*" OR DestinationIp="172.26.*"
OR DestinationIp="172.27.*" OR DestinationIp="172.28.*" OR DestinationIp="172.29.*"
OR DestinationIp="172.30.*" OR DestinationIp="172.31.*"
OR DestinationIp="192.168.*" OR DestinationIp="127.*" OR DestinationIp="::1")
(Image="*\\powershell.exe" OR Image="*\\pwsh.exe" OR Image="*\\cmd.exe"
OR Image="*\\wscript.exe" OR Image="*\\cscript.exe" OR Image="*\\mshta.exe"
OR Image="*\\rundll32.exe" OR Image="*\\regsvr32.exe" OR Image="*\\certutil.exe"
OR Image="*\\curl.exe" OR Image="*\\python.exe" OR Image="*\\python3.exe"
OR Image="*\\bitsadmin.exe" OR Image="*\\nc.exe" OR Image="*\\ncat.exe")
| stats
count as ConnectionCount,
dc(DestinationIp) as UniqueRemoteIPs,
values(DestinationIp) as RemoteIPList,
values(DestinationPort) as RemotePorts,
earliest(_time) as FirstSeen,
latest(_time) as LastSeen
by host, User, Image, CommandLine
| where ConnectionCount > 10
| eval SessionDurationSec = LastSeen - FirstSeen
| eval AvgBeaconIntervalSec = if(ConnectionCount > 1 AND SessionDurationSec > 0,
round(SessionDurationSec / (ConnectionCount - 1), 0), null())
| eval IsRegularBeacon = if(AvgBeaconIntervalSec > 0 AND AvgBeaconIntervalSec < 300, 1, 0)
| eval IsHighFrequency = if(ConnectionCount > 50, 1, 0)
| eval IsSingleDestination = if(UniqueRemoteIPs == 1, 1, 0)
| eval ExfilScore = IsRegularBeacon + IsHighFrequency + IsSingleDestination
| where ExfilScore >= 2
| eval FirstSeen=strftime(FirstSeen, "%Y-%m-%d %H:%M:%S")
| eval LastSeen=strftime(LastSeen, "%Y-%m-%d %H:%M:%S")
| table _time, host, User, Image, CommandLine, RemoteIPList, UniqueRemoteIPs, RemotePorts,
ConnectionCount, AvgBeaconIntervalSec, IsRegularBeacon, IsHighFrequency, IsSingleDestination, ExfilScore
| sort - ExfilScore, - ConnectionCount Detects exfiltration over C2 channels using Sysmon Event ID 3 (Network Connection) to identify processes making high-frequency repeated outbound connections to public IP addresses. Computes an average beacon interval from connection timing to identify regular C2 check-in patterns consistent with embedded data transfers. Three scoring dimensions — regular beacon interval (< 5 minutes), high connection count (> 50), and single destination IP — produce a composite ExfilScore. Note: Sysmon Event ID 3 does not capture byte volumes, so this query focuses on connection frequency and pattern regularity rather than data volume. Combine with proxy or network flow logs for byte-level analysis.
Data Sources
Required Sourcetypes
False Positives & Tuning
- Backup agents performing scheduled backups using scripting engines will generate high-frequency regular connections to backup infrastructure
- Log shippers and telemetry agents (Splunk UF, Elastic Agent) making frequent regular connections to their indexers — often exhibit perfect beacon-like regularity
- Endpoint management tools (SCCM, Tanium, BigFix) checking in regularly from scripting engine processes create identical patterns to C2 beaconing
- Security monitoring agents doing frequent heartbeat connections to management infrastructure
- CI/CD pipeline runners and automation scripts making repeated API calls to cloud services
Other platforms for T1041
Testing Methodology
Validate this detection against 4 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1PowerShell HTTP POST Exfiltration Over Simulated C2 Channel
Expected signal: Sysmon Event ID 1: Process Create — powershell.exe with CommandLine containing Invoke-WebRequest, -Method POST, and http://127.0.0.1:8080/beacon. Sysmon Event ID 3: Network Connection — powershell.exe connecting to 127.0.0.1:8080. PowerShell ScriptBlock Log Event ID 4104 capturing the full script including the base64-encoded data construction. DeviceNetworkEvents in MDE: ConnectionSuccess or ConnectionFailed (depending on listener) with InitiatingProcessFileName=powershell.exe, RemoteIP=127.0.0.1, RemotePort=8080.
- Test 2curl Multi-Connection Data Exfiltration Beaconing Pattern
Expected signal: 25x Sysmon Event ID 3: Network Connection events with Image=curl.exe (or full path), DestinationIp=127.0.0.1, DestinationPort=8080, Initiated=true. DeviceNetworkEvents: 25 ConnectionSuccess/ConnectionFailed records for curl.exe to 127.0.0.1:8080. The aggregate ConnectionCount of 25 crosses the MinConnectionCount=20 threshold in the KQL detection query. SPL ExfilScore increases as IsHighFrequency becomes 1 once count exceeds 20.
- Test 3DNS Data Exfiltration via Encoded Subdomain Labels
Expected signal: Sysmon Event ID 22 (DNS Query): 10 DNS query events with QueryName containing 40-55 character first labels encoding the Base64 data, initiated by nslookup.exe. The DNS hunting query triggers on LongestLabel > 40 and QueryCount > 5 from the same process. Windows DNS Client Event Log may also record the queries. The queries will fail to resolve (no listener on 127.0.0.1:53) but the Sysmon Event ID 22 fires on the query attempt regardless.
- Test 4Linux curl Data Exfiltration via HTTP POST
Expected signal: auditd: SYSCALL records for execve (curl), connect() calls to 127.0.0.1:8080, and read() on /etc/hostname and /proc. Sysmon for Linux Event ID 3: Network Connection events for curl process. Linux audit log (if auditd configured with network rules): socket()/connect() syscalls from curl with destination 127.0.0.1:8080. CommonSecurityLog or Syslog in Sentinel if auditd logs are forwarded: 15 connection records with consistent user-agent string indicating automated beaconing. The deceptive Windows user-agent string on a Linux process is itself anomalous.
References (12)
- https://attack.mitre.org/techniques/T1041/
- https://www.mandiant.com/resources/blog/scattered-spider-vmware-vsphere
- https://www.welivesecurity.com/2023/12/14/eset-apt-activity-report-t22023/
- https://blog.talosintelligence.com/talos-poet-rat/
- https://www.clearskysec.com/siamesekitten/
- https://learn.microsoft.com/en-us/defender-endpoint/advanced-hunting-devicenetworkevents-table
- https://learn.microsoft.com/en-us/defender-endpoint/advanced-hunting-devicefileevents-table
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1041/T1041.md
- https://github.com/SigmaHQ/sigma/tree/master/rules/windows/network_connection
- https://arxiv.org/ftp/arxiv/papers/1408/1408.1136.pdf
- https://www.cisa.gov/sites/default/files/publications/MAR-10303405-1.v1.WHITE.pdf
- https://unit42.paloaltonetworks.com/mechaFlounder/
Unlock Pro Content
Get the full detection package for T1041 including response playbook, investigation guide, and atomic red team tests.