T1125

Video Capture

Collection Last updated:

Adversaries may leverage a computer's peripheral devices (e.g., integrated cameras or webcams) or applications (e.g., video call services) to capture video recordings for the purpose of gathering information. Images may also be captured from devices or applications, potentially in specified intervals, in lieu of video files. Malware or scripts may interact with webcam devices through OS or application APIs such as the Windows Video Capture API (avicap32.dll), DirectShow, Windows Media Foundation, or platform-specific libraries on macOS and Linux. Captured video or image files may be written to disk and exfiltrated later. Threat actors including Transparent Tribe (Crimson RAT), Silence Group, and tools such as Empire, NanoCore, Agent Tesla, and PoetRAT have demonstrated active use of this technique.

What is T1125 Video Capture?

Video Capture (T1125) maps to the Collection tactic — the adversary is trying to gather data of interest to their goal in MITRE ATT&CK.

This page provides production-ready detection logic for Video Capture, covering the data sources and telemetry it touches: Driver: Driver Load, Process: Process Creation, File: File Creation, Windows Registry: Windows Registry Key Access, Microsoft Defender for Endpoint. The queries below are rated high severity at medium confidence, and ship for 7 SIEM platforms — KQL, SPL, Elastic, QRadar, Sumo, YARA-L, LogScale.

MITRE ATT&CK

Tactic
Collection
Technique
T1125 Video Capture
Canonical reference
https://attack.mitre.org/techniques/T1125/
Microsoft Sentinel / Defender
kusto
let KnownMediaApps = dynamic([
  "Teams.exe", "zoom.exe", "Skype.exe", "slack.exe", "webex.exe",
  "chrome.exe", "msedge.exe", "firefox.exe", "obs64.exe", "obs32.exe",
  "CameraApp.exe", "VideoCapture.exe", "vlc.exe", "ffmpeg.exe",
  "WindowsCamera.exe", "SnippingTool.exe", "mspaint.exe"
]);
let SuspiciousVideoPaths = dynamic([
  "\\AppData\\Local\\Temp\\", "\\AppData\\Roaming\\",
  "\\ProgramData\\", "\\Users\\Public\\",
  "\\Windows\\Temp\\", "\\Temp\\"
]);
let VideoExtensions = dynamic([".avi", ".mp4", ".wmv", ".mkv", ".mov", ".flv", ".m4v"]);
// Branch 1: Suspicious DLL image load of avicap32.dll by non-media processes
let AvicapLoads = DeviceImageLoadEvents
| where Timestamp > ago(24h)
| where FileName =~ "avicap32.dll" or FileName =~ "vfw32.dll"
| where not(InitiatingProcessFileName has_any (KnownMediaApps))
| project Timestamp, DeviceName, AccountName,
         InitiatingProcessFileName, InitiatingProcessCommandLine,
         InitiatingProcessParentFileName, FileName,
         DetectionSource = "AvicapDLLLoad";
// Branch 2: Video file creation in suspicious paths by non-media processes
let VideoFileCreation = DeviceFileEvents
| where Timestamp > ago(24h)
| where ActionType == "FileCreated"
| where FileName has_any (VideoExtensions)
| where FolderPath has_any (SuspiciousVideoPaths)
| where not(InitiatingProcessFileName has_any (KnownMediaApps))
| project Timestamp, DeviceName, AccountName,
         InitiatingProcessFileName, InitiatingProcessCommandLine,
         InitiatingProcessParentFileName,
         FileName = strcat(FolderPath, "\\", FileName),
         DetectionSource = "SuspiciousVideoFileCreation";
// Branch 3: Process accessing camera device objects (via registry device enumeration)
let CameraRegistryAccess = DeviceRegistryEvents
| where Timestamp > ago(24h)
| where RegistryKey has_any ("KSCATEGORY_VIDEO_CAMERA", "KSCATEGORY_CAPTURE",
                               "USB\\VID_", "Image\\Windows\\CurrentVersion\\Uninstall")
| where RegistryKey has "Camera" or RegistryKey has "Webcam" or RegistryKey has "VideoCapture"
| where not(InitiatingProcessFileName has_any (KnownMediaApps))
| where not(InitiatingProcessFileName has_any ("svchost.exe", "System", "WmiPrvSE.exe", "DeviceEnumerator.exe"))
| project Timestamp, DeviceName, AccountName,
         InitiatingProcessFileName, InitiatingProcessCommandLine,
         InitiatingProcessParentFileName,
         FileName = RegistryKey,
         DetectionSource = "CameraRegistryAccess";
union AvicapLoads, VideoFileCreation, CameraRegistryAccess
| sort by Timestamp desc

Detects webcam and video capture activity by non-media applications using three complementary approaches: (1) loading of avicap32.dll or vfw32.dll (legacy Windows Video Capture API) by processes not associated with legitimate media software; (2) creation of video files (AVI, MP4, WMV, etc.) in suspicious directories such as Temp, AppData, or ProgramData by non-media processes; (3) registry key access to camera device categories (KSCATEGORY_VIDEO_CAMERA, KSCATEGORY_CAPTURE) by unexpected processes. Known legitimate media applications (Teams, Zoom, Skype, OBS, browser processes) are excluded to reduce false positives.

high severity medium confidence

Data Sources

Driver: Driver Load Process: Process Creation File: File Creation Windows Registry: Windows Registry Key Access Microsoft Defender for Endpoint

Required Tables

DeviceImageLoadEvents DeviceFileEvents DeviceRegistryEvents

False Positives

  • Legitimate video conferencing applications (Zoom, Teams, Webex, Skype) that may not be in the exclusion list if installed to non-default paths
  • Screen recording and productivity tools (OBS Studio, Camtasia, Loom, ShareX) used by developers or content creators
  • IT asset management or device inventory tools that enumerate camera hardware through registry keys
  • Security camera management software or driver update utilities that interact with webcam device APIs
  • Development/testing environments where developers are building applications that interact with webcam APIs

Sigma rule & cross-platform mapping

The detection logic for Video Capture (T1125) above is provided in a vendor-neutral form so you can deploy it on any SIEM. The same logic is shipped here as native KQL (Microsoft Sentinel / Defender), SPL (Splunk), Elastic (Elastic Security (EQL)), QRadar (IBM QRadar (AQL)), Sumo (Sumo Logic CSE), YARA-L (Google Chronicle / SecOps), LogScale (CrowdStrike LogScale (CQL)) queries. In Sigma terms, this detection targets the following logsource:

logsource:
  category: process_creation
  product: windows

Browse the community-maintained Sigma rules for this technique:


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.

  1. Test 1Webcam Access via avicap32.dll (Windows Legacy API)

    Expected signal: Sysmon Event ID 7 (Image Load): Image=powershell.exe, ImageLoaded=C:\Windows\System32\avicap32.dll. Sysmon Event ID 1 (Process Create): CommandLine will contain 'avicap32.dll' and 'capCreateCaptureWindowA'. PowerShell Script Block Log Event ID 4104 with the full P/Invoke code.

  2. Test 2Video File Creation in Temp Directory Simulation

    Expected signal: Sysmon Event ID 11 (File Create): Image=powershell.exe, TargetFilename=C:\Users\<user>\AppData\Local\Temp\capture_<timestamp>.avi. File will contain RIFF header bytes matching AVI format. Sysmon Event ID 1 (Process Create) for the PowerShell process.

  3. Test 3Webcam Capture via Python OpenCV (Cross-Platform)

    Expected signal: Sysmon Event ID 1 (Process Create): Image=python3.exe (or python.exe), CommandLine contains 'cv2.VideoCapture' and 'imwrite'. Sysmon Event ID 7 (Image Load): opencv_videoio*.dll or _cv2.pyd loaded by python3.exe. Sysmon Event ID 11 (File Create): TargetFilename matching frame_<timestamp>.jpg in %TEMP%.

  4. Test 4Webcam Capture Using ffmpeg (Common RAT Dependency)

    Expected signal: Sysmon Event ID 1 (Process Create): Image=ffmpeg.exe, CommandLine contains '-f dshow' and '-i video=' and the output .mp4 path in %TEMP%. Sysmon Event ID 11 (File Create): TargetFilename matching *.mp4 in %TEMP% with Image=ffmpeg.exe. DeviceNetworkEvents (KQL) should be clean for this test — ffmpeg does not make network connections in offline capture mode.


Response Playbook

Triage

  1. Identify the process that triggered the alert — check the full executable path, parent process, and whether it has a valid digital signature. Unsigned or unusually-named executables (random strings, misleading names like 'svchost32.exe') are high-priority indicators.
  2. Determine if the process has a legitimate reason to access the webcam — is it a known application installed via the software inventory? Cross-reference with your CMDB or endpoint management platform (Intune, SCCM). If the process is not in software inventory, treat as high suspicion.
  3. Check the parent process chain — was this process spawned by a browser, Office application, scripting engine (wscript.exe, powershell.exe), or email client? Parent processes like winword.exe or outlook.exe spawning a webcam-accessing process is a strong indicator of malware.
  4. Review file creation artifacts — if a video file was created, check the file size (0-byte files may indicate failed capture), file creation timestamp, and whether the file was subsequently accessed by a network-capable process (potential exfiltration preparation).
  5. Check for concurrent network activity — did the process make outbound network connections during or after webcam access? Use DeviceNetworkEvents filtered by the same process and time window. Any connection to external IPs coinciding with video file creation strongly indicates active exfiltration.
  6. Examine the timeline — was webcam access preceded by suspicious process execution or followed by archive/compression activity (7z.exe, zip.exe)? This sequence matches the collection-then-exfiltration pattern seen in RAT families like Crimson, Agent Tesla, and NanoCore.
  7. Check for persistence mechanisms — RATs that use webcam capabilities typically establish persistence. Review scheduled tasks, registry run keys, and services created around the same time as the alert.

Containment

  1. If malicious access is confirmed: immediately isolate the endpoint using EDR network isolation to prevent any video data from being exfiltrated. Preserve all evidence before remediation.
  2. Terminate the offending process and any child processes. Do not simply close the application window — use EDR kill process functionality to ensure the process tree is fully terminated.
  3. If video files were created on disk: preserve copies to a forensic share before deletion. Calculate SHA256 hashes for evidence. Then securely delete the video files to protect the victim's privacy.
  4. If a user account may be compromised (RAT delivered via phishing): disable the account, revoke active tokens/sessions in Azure AD/Entra ID, and notify the user through an out-of-band channel (phone call, not email which may be monitored).
  5. Block the C2 infrastructure at the network perimeter — extract any contacted IP addresses and domains from process network logs and add to firewall blocklists and DNS sinkholes.
  6. Disable the physical webcam via Group Policy (Device Installation Restrictions) on affected and similar endpoints as a temporary protective measure until investigation is complete.

Evidence Collection

  1. Sysmon Event ID 7 (Image Load) logs — capture all DLL loads by the offending process, especially avicap32.dll, vfw32.dll, and Media Foundation DLLs, to establish the camera API access timeline.
  2. Sysmon Event ID 11 (File Create) — collect all files created by the process to identify video/image outputs and any dropped payloads or configuration files.
  3. Sysmon Event ID 3 (Network Connection) — collect all network connections from the process to identify C2 servers and data exfiltration endpoints.
  4. Video and image files on disk — preserve with metadata intact. Use 'fsutil file queryFileFID' and forensic imaging to capture creation timestamps, last access times, and file contents. Hash all files for evidence chain.
  5. Process memory dump — if the process is still running, capture a full process memory dump using ProcDump: 'procdump.exe -ma <PID> <output_path>'. This may contain unencrypted video frames, API keys, or C2 configuration.
  6. Registry hives — export HKLM\SYSTEM\CurrentControlSet\Enum\USB and HKLM\SYSTEM\CurrentControlSet\Control\Class\{6bdd1fc6-810f-11d0-bec7-08002be2092f} (camera device class) to document camera device state.
  7. Prefetch files — collect C:\Windows\Prefetch\<PROCESS_NAME>-*.pf to establish execution history and loaded DLL timestamps.
  8. Windows Event Log — collect Microsoft-Windows-DriverFrameworks-UserMode/Operational for webcam device plug/unplug events that may correspond with malware access timing.

Escalation Criteria

  • ! Video files created by a process with no legitimate media purpose — especially if files are created in hidden directories, named with random strings, or created outside business hours.
  • ! Webcam API access followed by outbound network connections to non-corporate IPs — this indicates active exfiltration of captured video data.
  • ! Process is a known RAT family — NanoCore, Agent Tesla, Crimson RAT, NjRAT, DarkComet, Cobian RAT, Revenge RAT, or PoetRAT. Immediate escalation to incident response.
  • ! Multiple endpoints showing the same suspicious webcam access pattern within a short time window — indicates automated deployment or lateral movement of a RAT across the environment.
  • ! Executive or privileged user endpoint affected — video capture of a CISO, CEO, or anyone with access to sensitive meetings represents a critical data exposure risk.
  • ! Evidence of audio capture (T1123) alongside video capture — combined A/V surveillance indicates a sophisticated, targeted threat actor with persistent access.
  • ! Any evidence that the malware has camera indicator light suppression capabilities — some advanced RATs can activate the webcam while suppressing the LED indicator.

Investigation Guide

Forensic Artifacts

  • > File System: Any .avi, .mp4, .wmv, or .jpg files in %TEMP%, %APPDATA%, %PROGRAMDATA%, or C:\Users\Public\ created by non-media processes — these are primary evidence of successful capture.
  • > File System: C:\Windows\Prefetch\<MALWARE_NAME>-*.pf — confirms execution timestamps and lists DLLs loaded including avicap32.dll.
  • > Registry: HKLM\SYSTEM\CurrentControlSet\Control\Class\{6bdd1fc6-810f-11d0-bec7-08002be2092f} — enumerates installed camera devices and can reveal if device was recently accessed.
  • > Registry: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options — check for debugger entries targeting media apps (defense evasion).
  • > Event Log: Microsoft-Windows-DriverFrameworks-UserMode/Operational (Event IDs 2003, 2004, 2100, 2101) — records when USB camera devices are connected/initialized by processes.
  • > Event Log: Microsoft-Windows-Kernel-PnP/Operational — device plug events for USB webcams.
  • > Memory: Process heap of offending process may contain BITMAPINFOHEADER structures, DirectShow filter graph objects, or encoded JPEG/AVI frame data.
  • > Network: PCAP analysis for video-sized data transfers to external IPs. AVI/H264 streams have recognizable byte patterns (0x00000001 NAL units for H264, RIFF....AVI header for AVI).
  • > macOS: /var/log/system.log and unified log entries from com.apple.avfoundation for unauthorized camera access. TCC.db (~/Library/Application Support/com.apple.TCC/TCC.db) records which apps have been granted camera permission.
  • > Linux: /proc/<PID>/maps for loaded libraries including libv4l, libopencv, or gstreamer plugins that indicate webcam access.

Tuning Guidance

The primary challenge with T1125 detection is the broad legitimate use of webcam APIs by conferencing, streaming, and productivity software. Begin by inventorying all software in your environment that legitimately accesses webcam hardware — expand the KnownMediaApps exclusion list accordingly. Pay particular attention to non-default installation paths (some applications install to %APPDATA% rather than %ProgramFiles%), as these will not be caught by filename-only exclusions; consider expanding to include folder path patterns. For the avicap32.dll detection specifically: this is a legacy API that modern applications (Teams, Zoom, WebRTC-based tools) typically do not use — Microsoft Media Foundation and DirectShow are preferred. An alert on avicap32.dll loading by a process that is NOT an obviously legacy application warrants immediate investigation regardless of other context. For the video file creation branch: tune by adding specific exclusion patterns for your endpoint management tools and monitoring agents. If your environment uses screen recording for compliance purposes (session recording), ensure those paths are excluded. Consider adding file size thresholds — files under 5KB are likely thumbnails or test frames from initialization rather than actual surveillance footage. For high-noise environments, consider requiring two branches to fire simultaneously (e.g., DLL load AND file creation, or DLL load AND network connection) before alerting, using the hunting queries as your primary detection logic.


Hunting Queries

Hunt for any process loading legacy Windows Video Capture API DLLs (avicap32.dll, vfw32.dll) that are not associated with known media applications. A single process loading these DLLs across multiple hosts is a strong indicator of a deployed RAT with webcam functionality.

Hunting — KQL
kql
DeviceImageLoadEvents
| where Timestamp > ago(7d)
| where FileName in~ ("avicap32.dll", "vfw32.dll", "kswdmcap.ax", "mf.dll")
| summarize LoadCount=count(),
            DeviceCount=dcount(DeviceName),
            Accounts=make_set(AccountName),
            Earliest=min(Timestamp),
            Latest=max(Timestamp)
  by InitiatingProcessFileName, InitiatingProcessFolderPath
| where not(InitiatingProcessFileName has_any ("Teams", "zoom", "Skype", "slack",
            "chrome", "msedge", "firefox", "obs", "vlc", "ffmpeg",
            "WindowsCamera", "webex", "CameraApp", "SnippingTool"))
| sort by DeviceCount desc, LoadCount desc
Hunting — SPL
spl
index=wineventlog sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=7
  ImageLoaded IN ("*\\avicap32.dll", "*\\vfw32.dll", "*\\kswdmcap.ax")
  NOT Image IN ("*\\Teams.exe","*\\zoom.exe","*\\Skype.exe","*\\slack.exe",
                "*\\chrome.exe","*\\msedge.exe","*\\firefox.exe",
                "*\\obs64.exe","*\\vlc.exe","*\\ffmpeg.exe","*\\WindowsCamera.exe")
| stats count as LoadCount, dc(host) as DeviceCount, values(host) as Hosts,
        earliest(_time) as Earliest, latest(_time) as Latest by Image, ImageLoaded
| sort - DeviceCount LoadCount

Hunt for video and image files created in staging directories (Temp, AppData, ProgramData, Public) by non-media processes. Multiple video file creations from the same process, or the same process creating files across multiple hosts, is highly indicative of automated RAT-based webcam surveillance.

Hunting — KQL
kql
DeviceFileEvents
| where Timestamp > ago(7d)
| where ActionType == "FileCreated"
| where FileName endswith ".avi" or FileName endswith ".mp4"
    or FileName endswith ".wmv" or FileName endswith ".jpg"
    or FileName endswith ".jpeg"
| where FolderPath has_any ("\\Temp\\", "\\AppData\\", "\\ProgramData\\", "\\Public\\")
| where not(InitiatingProcessFileName has_any ("Teams", "zoom", "Skype", "slack",
            "chrome", "msedge", "firefox", "obs", "vlc", "ffmpeg",
            "WindowsCamera", "webex", "ShareX", "Snagit", "Camtasia"))
| summarize FileCount=count(),
            Files=make_set(FileName, 10),
            TotalSizeMB=sum(FileSize) / 1048576,
            DeviceCount=dcount(DeviceName)
  by InitiatingProcessFileName, InitiatingProcessFolderPath, bin(Timestamp, 1h)
| where FileCount >= 2 or TotalSizeMB > 1
| sort by Timestamp desc
Hunting — SPL
spl
index=wineventlog sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=11
  (TargetFilename="*.avi" OR TargetFilename="*.mp4" OR TargetFilename="*.wmv"
   OR TargetFilename="*.jpg" OR TargetFilename="*.jpeg")
  (TargetFilename="*\\Temp\\*" OR TargetFilename="*\\AppData\\*"
   OR TargetFilename="*\\ProgramData\\*" OR TargetFilename="*\\Public\\*")
  NOT Image IN ("*\\Teams.exe","*\\zoom.exe","*\\Skype.exe","*\\slack.exe",
                "*\\chrome.exe","*\\msedge.exe","*\\firefox.exe",
                "*\\obs64.exe","*\\vlc.exe","*\\ffmpeg.exe","*\\WindowsCamera.exe")
| stats count as FileCount, values(TargetFilename) as Files,
        dc(host) as DeviceCount by Image, ParentImage
| where FileCount >= 2 OR DeviceCount > 1
| sort - DeviceCount FileCount

Correlate webcam API access with outbound public network connections within the same process and 30-minute window. This join-based hunt identifies the most dangerous scenario: a process that accessed the camera AND made outbound connections to external IPs — the hallmark of an active data exfiltration event.

Hunting — KQL
kql
let VideoCaptureProcs = DeviceImageLoadEvents
| where Timestamp > ago(7d)
| where FileName in~ ("avicap32.dll", "vfw32.dll")
| where not(InitiatingProcessFileName has_any ("Teams", "zoom", "Skype", "obs", "vlc",
            "chrome", "msedge", "firefox", "WindowsCamera", "webex"))
| project DeviceName, InitiatingProcessId, InitiatingProcessFileName, CaptureTime=Timestamp;
VideoCaptureProcs
| join kind=inner (
    DeviceNetworkEvents
    | where Timestamp > ago(7d)
    | where RemoteIPType == "Public"
    | project DeviceName, InitiatingProcessId, RemoteIP, RemotePort, NetworkTime=Timestamp
) on DeviceName, InitiatingProcessId
| where abs(datetime_diff('minute', NetworkTime, CaptureTime)) < 30
| project CaptureTime, NetworkTime, DeviceName, InitiatingProcessFileName,
         RemoteIP, RemotePort
| sort by CaptureTime desc
Hunting — SPL
spl
index=wineventlog sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational"
| eval EventType=case(EventCode=7 AND match(ImageLoaded,"avicap32|vfw32"), "CameraAPILoad",
                      EventCode=3 AND NOT match(DestinationIp,"^(10\.|172\.1[6-9]\.|172\.2[0-9]\.|172\.3[0-1]\.|192\.168\.|127\.)"), "PublicNetConn",
                      true(), null())
| where isnotnull(EventType)
| eval ProcKey=host."|".(coalesce(ProcessId, SourceProcessId))
| transaction ProcKey maxspan=30m
| where mvcount(EventType) > 1
  AND mvfind(EventType, "CameraAPILoad") >= 0
  AND mvfind(EventType, "PublicNetConn") >= 0
| table _time, host, Image, DestinationIp, DestinationPort, ImageLoaded
| sort - _time

Atomic Red Team Tests

Test 1 Webcam Access via avicap32.dll (Windows Legacy API)
windows

Uses PowerShell to load avicap32.dll via P/Invoke and attempt to initialize a webcam capture window using the legacy Video for Windows (VfW) API. This simulates the technique used by older RAT families (DarkComet, Cobian RAT, njRAT) that rely on the Video for Windows API for camera access. The capture window initialization will fail gracefully if no camera is present, but the DLL load event and API call are still generated for detection validation.

Command

powershell
powershell.exe -NoProfile -Command "$code = @'
using System;
using System.Runtime.InteropServices;
public class WebcamCapture {
    [DllImport(\"avicap32.dll\", CharSet=CharSet.Ansi)]
    public static extern IntPtr capCreateCaptureWindowA(string lpszWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hwndParent, int nID);
    [DllImport(\"user32.dll\")]
    public static extern bool DestroyWindow(IntPtr hWnd);
}
'@
Add-Type -TypeDefinition $code
$hwnd = [WebcamCapture]::capCreateCaptureWindowA('TestCapture', 0x10000000, 0, 0, 320, 240, [IntPtr]::Zero, 0)
Write-Host \"Capture window handle: $hwnd\"
if ($hwnd -ne [IntPtr]::Zero) { [WebcamCapture]::DestroyWindow($hwnd) }"

Expected Telemetry

Sysmon Event ID 7 (Image Load): Image=powershell.exe, ImageLoaded=C:\Windows\System32\avicap32.dll. Sysmon Event ID 1 (Process Create): CommandLine will contain 'avicap32.dll' and 'capCreateCaptureWindowA'. PowerShell Script Block Log Event ID 4104 with the full P/Invoke code.

Expected Detection

KQL alert fires on DeviceImageLoadEvents where FileName='avicap32.dll' initiated by powershell.exe. SPL alert fires on EventCode=7 with ImageLoaded matching *avicap32.dll* from Image=*powershell.exe*. DetectionSource='AvicapDLLLoad'.

Test 2 Video File Creation in Temp Directory Simulation
windows

Simulates the file creation artifact produced by RAT-based webcam capture by creating a file with an .avi extension in the %TEMP% directory from PowerShell. This represents the output artifact created by malware that captures webcam footage and stages it in the temp directory before exfiltration, as observed in Clambling (AVI format) and similar malware families.

Command

powershell
powershell.exe -NoProfile -Command "$outputPath = Join-Path $env:TEMP 'capture_$(Get-Date -Format yyyyMMdd_HHmmss).avi'; [System.IO.File]::WriteAllBytes($outputPath, [byte[]](0x52,0x49,0x46,0x46,0x00,0x00,0x00,0x00,0x41,0x56,0x49,0x20)); Write-Host 'Simulated AVI created:' $outputPath"

Cleanup

powershell
powershell.exe -Command "Get-ChildItem $env:TEMP -Filter 'capture_*.avi' | Remove-Item -Force"

Expected Telemetry

Sysmon Event ID 11 (File Create): Image=powershell.exe, TargetFilename=C:\Users\<user>\AppData\Local\Temp\capture_<timestamp>.avi. File will contain RIFF header bytes matching AVI format. Sysmon Event ID 1 (Process Create) for the PowerShell process.

Expected Detection

KQL alert fires on DeviceFileEvents where FileName endswith '.avi' and FolderPath contains '\Temp\' with InitiatingProcessFileName='powershell.exe'. SPL alert fires on EventCode=11 with TargetFilename matching *.avi in *\Temp\* from Image=*powershell.exe*. DetectionSource='SuspiciousVideoFileCreation'.

Test 3 Webcam Capture via Python OpenCV (Cross-Platform)
windows

Uses Python with the OpenCV library to capture a single frame from the webcam and save it as a JPEG file. This technique is used by PoetRAT (which used a Python tool named Bewmac), Machete, and other Python-based RATs. The test requires Python 3 and opencv-python to be installed. If no camera is present, OpenCV will return a failed capture but still generate process and import events.

Command

powershell
python3 -c "import cv2, os, time; cap = cv2.VideoCapture(0); ret, frame = cap.read(); out_path = os.path.join(os.environ.get('TEMP', '/tmp'), 'frame_' + str(int(time.time())) + '.jpg'); cv2.imwrite(out_path, frame) if ret else open(out_path + '.failed', 'w').close(); cap.release(); print('Output:', out_path)"

Cleanup

powershell
python3 -c "import os, glob; [os.remove(f) for f in glob.glob(os.path.join(os.environ.get('TEMP', '/tmp'), 'frame_*.jpg*'))]"

Expected Telemetry

Sysmon Event ID 1 (Process Create): Image=python3.exe (or python.exe), CommandLine contains 'cv2.VideoCapture' and 'imwrite'. Sysmon Event ID 7 (Image Load): opencv_videoio*.dll or _cv2.pyd loaded by python3.exe. Sysmon Event ID 11 (File Create): TargetFilename matching frame_<timestamp>.jpg in %TEMP%.

Expected Detection

KQL: DeviceFileEvents fires on .jpg creation in Temp by python.exe. SPL: EventCode=11 with TargetFilename=*\Temp\frame_*.jpg from Image=*python*.exe. On macOS/Linux: auditd records open() syscalls to /dev/video0 or AVFoundation camera access.

Test 4 Webcam Capture Using ffmpeg (Common RAT Dependency)
windows

Uses ffmpeg to capture a 5-second video clip from the default webcam using DirectShow (Windows) and saves it to a temporary directory. ffmpeg is often bundled with or downloaded by RATs as a dependency for media capture (e.g., PoetRAT's Bewmac tool, Silence Group's surveillance implants). This tests both the process creation detection and the video file creation in a staging path.

Command

powershell
ffmpeg.exe -f dshow -i video="@device_pnp_\/\\?\usb#vid_" -t 5 -vcodec libx264 "%TEMP%\surveillance_%COMPUTERNAME%_%DATE:~-4,4%%DATE:~-7,2%%DATE:~-10,2%.mp4" -y 2>nul || echo Camera not available or ffmpeg not found

Cleanup

powershell
del /q "%TEMP%\surveillance_%COMPUTERNAME%_*.mp4" 2>nul

Expected Telemetry

Sysmon Event ID 1 (Process Create): Image=ffmpeg.exe, CommandLine contains '-f dshow' and '-i video=' and the output .mp4 path in %TEMP%. Sysmon Event ID 11 (File Create): TargetFilename matching *.mp4 in %TEMP% with Image=ffmpeg.exe. DeviceNetworkEvents (KQL) should be clean for this test — ffmpeg does not make network connections in offline capture mode.

Expected Detection

KQL: DeviceFileEvents fires on .mp4 creation in %TEMP% by ffmpeg.exe (if ffmpeg is not in KnownMediaApps allowlist). SPL: EventCode=11 with TargetFilename=*\Temp\surveillance_*.mp4. The suspicious naming convention (surveillance_ prefix, hostname and date in filename) is a high-fidelity indicator of malicious intent.

Related Detections

Tactic Hub