Query Details

Rule : Command-Output Transfer to Webhooks

Exfiltration Webhook Command Output

Query

let lookback = 7d;
let suspicious_processes = DeviceProcessEvents
| where Timestamp > ago(lookback)
| where ProcessCommandLine has "webhook.site" and (FileName in~ ("curl.exe","curl","powershell.exe","pwsh.exe","cmd.exe","bash","sh") or ProcessCommandLine has_any ("curl","Invoke-WebRequest","Invoke-RestMethod"))
| project Timestamp, DeviceId, DeviceName, Evidence="Process invocation", AccountName, Details=ProcessCommandLine;
let suspicious_network = DeviceNetworkEvents
| where Timestamp > ago(lookback)
| where RemoteUrl contains "webhook.site"
| project Timestamp, DeviceId, DeviceName, Evidence="Network connection", AccountName=InitiatingProcessAccountName, Details=strcat(RemoteUrl," | ",InitiatingProcessCommandLine);
union suspicious_processes, suspicious_network
| order by Timestamp desc

About this query

Explanation

This query is designed to detect suspicious activity where command-line tools and network connections are used to send data to webhook.site, which could indicate data exfiltration. Here's a simplified breakdown:

  1. Purpose: The query aims to identify potential malicious behavior where data is sent to webhook.site, a service often used for testing webhooks but can also be misused for data exfiltration.

  2. Detection Logic:

    • It looks for command-line executions involving webhook.site using tools like curl, PowerShell, cmd, bash, or specific PowerShell methods (Invoke-WebRequest, Invoke-RestMethod).
    • It also checks for network connections to webhook.site.
  3. Data Sources:

    • The query examines two main data tables: DeviceProcessEvents for command-line activity and DeviceNetworkEvents for network connections.
  4. Output:

    • The results from both data sources are combined into a single timeline, showing when and how the suspicious activity occurred.
  5. False Positives:

    • The query acknowledges that legitimate use of webhook.site for development or IT purposes could trigger alerts. It suggests excluding known developers or integration teams from alerts to reduce false positives.
  6. Triage Steps:

    • Analysts should review the command lines for any sensitive information being sent and check for any reconnaissance commands executed before the data transfer.
    • If unauthorized, the destination should be blocked at the network level.
  7. Considerations:

    • The query requires visibility into endpoint command lines and network activity.
    • Initial thresholds are suggested, but the query should be tested and refined in a hunting context before being used for alerting.