Identify Instances of PowerShell Invoke-WebRequest, IWR or Net.WebClient
Description of the Query:
KQL Query:
// Detect PowerShell Invoke-WebRequest, IWR, or Net.WebClient Activity
DeviceProcessEvents
| where Timestamp > ago(10d) // Limit results to the last 24 hours
| where ActionType == "ProcessCreate" // Focus on process creation events
| where InitiatingProcessFileName contains "powershell.exe" // Filter for PowerShell processes
| where ProcessCommandLine has_any ("Invoke-WebRequest", "iwr", "Net.WebClient", "DownloadFile", "DownloadString")
| extend ParsedCommandLine = parse_command_line(ProcessCommandLine, "windows") // Parse command line using the Windows parser
| extend DownloadURL = extract(@"((http|https):\/\/[^\s]+)", 0, ProcessCommandLine) // Extract URLs from the command line
| extend UserName = tostring(split(ParsedCommandLine.User, @"\")[1]) // Extract username for context
| project
Timestamp,
DeviceName,
UserName,
InitiatingProcessFileName,
ProcessCommandLine,
DownloadURL,
InitiatingProcessCommandLine,
ActionType
| sort by Timestamp descExplanation of the Query:
Use Case:
Notes:
PreviousIdentify Potential RDP Tunneled SessionsNextIdentify Processes Launched by PowerShell Remoting (WSMProvHost.exe)
Last updated