Identify File with Double Extensions
Description of the Query:
KQL Query:
// Detect Files With Misleading Double Extensions Using Regex
DeviceFileEvents
| where Timestamp > ago(30d) // Limit results to the last 24 hours
| where ActionType in ("FileCreate", "FileModify") // Focus on file creation or modification events
| extend FileName = tostring(split(FolderPath, "\\")[-1]) // Extract the file name from the full path
| where isnotempty(FileName) // Ensure FileName is not null or empty
| where FileName matches regex @'[^\\.]+\\.[^\\.]+\\.[^\\.]+' // Match file names with at least two dots (double extensions)
| extend FileExtension = tostring(split(FileName, ".")[-1]) // Extract the final extension
| extend SuspiciousExtensions = dynamic(["exe", "vbs", "js", "bat", "cmd", "ps1"]) // List of suspicious extensions
| where FileExtension has_any (SuspiciousExtensions) // Filter for files with suspicious final extensions
| project
Timestamp,
DeviceName,
FileName,
FolderPath,
FileExtension,
InitiatingProcessCommandLine,
InitiatingProcessAccountName,
ActionType
| sort by Timestamp descExplanation of Changes:
Notes:
PreviousIdentify Suspicious String in Service Creation ImagePathNextDetect Potential Cleartext Credentials in Commandline
Last updated