Identify Suspicious String in Service Creation ImagePath
Description of the Query:
KQL Query:
// Detect Suspicious String in Service Creation ImagePath
DeviceEvents
| where Timestamp > ago(1d) // Limit results to the last 24 hours
| where ActionType == "ServiceCreate" // Focus on service creation events
| extend ImagePath = tostring(parse_json(AdditionalFields).ImagePath) // Extract ImagePath from AdditionalFields
| extend UserName = tostring(split(InitiatingProcessAccountName, @"\")[1]) // Extract username for context
| where ImagePath has_any (
"cmd.exe",
"powershell.exe",
"mshta.exe",
"cscript.exe",
"wscript.exe",
"-EncodedCommand",
"-ExecutionPolicy",
"C:\\Users\\",
"C:\\Windows\\Temp",
"C:\\ProgramData"
"ADMIN$"
"C$"
"127.0.0.1"
) // Filter for suspicious strings in ImagePath
| project
Timestamp,
DeviceName,
UserName,
ServiceName = tostring(parse_json(AdditionalFields).ServiceName), // Extract service name
ImagePath,
InitiatingProcessFileName,
InitiatingProcessCommandLine,
InitiatingProcessAccountName,
ActionType
| sort by Timestamp descExplanation of the Query:
Use Case:
Notes:
Last updated