Detect Exfiltration Over Physical Medium in Splunk
Adversaries may attempt to exfiltrate data via a physical medium, such as a removable drive. In certain circumstances, such as an air-gapped network compromise, exfiltration could occur via a physical medium or device introduced by a user. Such media could be an external hard drive, USB drive, cellular phone, MP3 player, or other removable storage and processing device. The physical medium or device could be used as the final exfiltration point or to hop between otherwise disconnected systems.
MITRE ATT&CK
- Tactic
- Exfiltration
- Technique
- T1052 Exfiltration Over Physical Medium
- Canonical reference
- https://attack.mitre.org/techniques/T1052/
SPL Detection Query
index=wineventlog sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=11
| eval DriveLetter=upper(substr(TargetFilename, 1, 2))
| where match(DriveLetter, "^[D-Z]:$")
| eval FileExt=lower(mvindex(split(TargetFilename, "."), -1))
| eval IsSensitive=if(match(FileExt, "^(zip|rar|7z|tar|gz|docx?|xlsx?|pdf|pst|ost|db|sql|bak|key|pfx|p12|rdp|kdbx|csv|json|xml|eml|mdb|accdb)$"), 1, 0)
| eval ProcessName=mvindex(split(Image, "\\"), -1)
| eval IsKnownExfilTool=if(match(lower(ProcessName), "^(xcopy|robocopy|7z|winzip|winrar|rclone|rsync|cp|dd)\.exe$"), 1, 0)
| bucket _time span=1h
| stats
count as FileWriteCount,
sum(IsSensitive) as SensitiveFileCount,
sum(IsKnownExfilTool) as ExfilToolEvents,
dc(FileExt) as UniqueExtensions,
dc(Image) as UniqueProcesses,
values(eval(if(IsSensitive=1, TargetFilename, null()))) as SensitiveFiles,
values(Image) as WritingProcesses,
earliest(_time) as FirstWrite,
latest(_time) as LastWrite
by _time, host, User, DriveLetter
| where FileWriteCount > 5 OR SensitiveFileCount > 0 OR ExfilToolEvents > 0
| eval RiskScore=(SensitiveFileCount * 5) + (ExfilToolEvents * 3) + FileWriteCount
| eval RiskTier=case(
RiskScore >= 50, "Critical",
RiskScore >= 20, "High",
RiskScore >= 10, "Medium",
true(), "Low"
)
| sort - RiskScore
| table _time, host, User, DriveLetter, FileWriteCount, SensitiveFileCount, ExfilToolEvents, UniqueExtensions, WritingProcesses, SensitiveFiles, FirstWrite, LastWrite, RiskScore, RiskTier Detects bulk file writes to non-system drive letters using Sysmon Event ID 11 (File Create). Identifies sensitive file types (archives, Office documents, credential stores, database files) written to removable drive paths, and flags processes known to be used for data transfer (xcopy, robocopy, 7z, rclone). Assigns a cumulative risk score based on sensitive file count, known exfiltration tools detected, and overall write volume. Buckets events by 1-hour windows to surface concentrated transfer activity.
Data Sources
Required Sourcetypes
False Positives & Tuning
- IT administrators performing legitimate data backups to external drives as part of scheduled maintenance procedures
- Employees transferring personal files to USB drives at the end of their workday for personal use
- Software developers deploying compiled builds or configuration files to USB drives for air-gapped test environments
- Help desk technicians using bootable USB drives (Ventoy, Rufus) triggering file write events during OS imaging
- Authorized data migration projects transferring large volumes under change management
Other platforms for T1052
Testing Methodology
Validate this detection against 5 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 1Windows - Copy sensitive documents to USB drive using xcopy
Expected signal: Sysmon Event ID 11: FileCreate events with TargetFilename matching 'E:\staged_exfil\*' written by process 'xcopy.exe'. MDE DeviceFileEvents with ActionType=FileCreated and FolderPath starting with 'E:\staged_exfil'. Sysmon Event ID 1: Process Create for xcopy.exe with CommandLine containing '/S /Y'. Prefetch file created at C:\Windows\Prefetch\XCOPY.EXE-*.pf.
- Test 2Windows - Archive sensitive files and copy to USB using 7-Zip
Expected signal: Sysmon Event ID 11: FileCreate for archive_exfil.zip in %TEMP% (staging) then another FileCreate for archive_exfil.zip on E: (exfil). Sysmon Event ID 1: Process Create for 7z.exe with command line showing source directories. MDE DeviceFileEvents with FileName=archive_exfil.zip and FolderPath=E:\. Prefetch for 7Z.EXE-*.pf created.
- Test 3Windows - Bulk robocopy transfer to USB with logging
Expected signal: Sysmon Event ID 1: Process Create for robocopy.exe with full command line including source, destination, and flags. Sysmon Event ID 11: Multiple FileCreate events on E:\desktop_copy\ for each file transferred, plus FileCreate for robocopy_exfil.log in C:\Windows\Temp. MDE DeviceFileEvents showing bulk writes to E: drive. Prefetch file ROBOCOPY.EXE-*.pf with referenced volume for E:.
- Test 4Linux - Copy credentials and config files to mounted USB
Expected signal: Linux auditd syscall events: openat/read on /etc/passwd, /etc/shadow, ~/.ssh/id_rsa; write syscalls to /media/*/exfil/ paths. Syslog entries showing USB mount event (kernel: usb, scsi: sd). auditd EVENT_TYPE=PATH records for each file accessed. If auditd WATCH rules are configured on /etc/shadow and ~/.ssh/id_rsa, dedicated alerts fire for those accesses.
- Test 5Windows - PowerShell recursive file copy to USB simulating data collection script
Expected signal: Sysmon Event ID 1: powershell.exe with CommandLine containing '-ExecutionPolicy Bypass', 'Get-ChildItem', 'Copy-Item', and target drive 'E:\'. PowerShell ScriptBlock Logging Event ID 4104 with full deobfuscated script content. Sysmon Event ID 11: Multiple FileCreate events on E:\ps_exfil\ for each copied file. MDE DeviceFileEvents with ActionType=FileCreated on DriveLetter=E:.
References (12)
- https://attack.mitre.org/techniques/T1052/
- https://attack.mitre.org/techniques/T1052/001/
- https://learn.microsoft.com/en-us/defender-endpoint/device-control-removable-storage-access-control
- https://learn.microsoft.com/en-us/defender-endpoint/advanced-hunting-deviceevents-table
- https://learn.microsoft.com/en-us/defender-endpoint/advanced-hunting-devicefileevents-table
- https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4663
- https://www.cisa.gov/sites/default/files/publications/fact-sheet-removable-media-508.pdf
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1052.001/T1052.001.md
- https://github.com/SigmaHQ/sigma/tree/master/rules/windows/file
- https://www.mandiant.com/resources/blog/insider-threats-data-exfiltration
- https://www.sans.org/white-papers/33492/
- https://docs.microsoft.com/en-us/sysinternals/downloads/sysmon
Unlock Pro Content
Get the full detection package for T1052 including response playbook, investigation guide, and atomic red team tests.