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 descAbout 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:
-
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. -
Detection Logic:
- It looks for command-line executions involving
webhook.siteusing tools likecurl, PowerShell,cmd,bash, or specific PowerShell methods (Invoke-WebRequest,Invoke-RestMethod). - It also checks for network connections to
webhook.site.
- It looks for command-line executions involving
-
Data Sources:
- The query examines two main data tables:
DeviceProcessEventsfor command-line activity andDeviceNetworkEventsfor network connections.
- The query examines two main data tables:
-
Output:
- The results from both data sources are combined into a single timeline, showing when and how the suspicious activity occurred.
-
False Positives:
- The query acknowledges that legitimate use of
webhook.sitefor development or IT purposes could trigger alerts. It suggests excluding known developers or integration teams from alerts to reduce false positives.
- The query acknowledges that legitimate use of
-
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.
-
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.