Detect Potential Cleartext Credentials in Commandline
Description of the Query:
KQL Query:
// Detect Potential Cleartext Credentials in Command Line
DeviceProcessEvents
| where Timestamp > ago(1d) // Limit results to the last 24 hours
| where ActionType == "ProcessCreate" // Focus on process creation events
| extend CommandLineLower = tolower(ProcessCommandLine) // Convert command line to lowercase for case-insensitive matching
| where CommandLineLower has_any (
"password=",
"pwd=",
"username=",
"user=",
"pass=",
"credential=",
"-password",
"-pwd",
"-username",
"-user",
"-pass",
"-credential"
) // Look for common credential-related keywords
| extend Base64Pattern = extract(@"([A-Za-z0-9+/=]{20,})", 0, ProcessCommandLine) // Extract potential base64-encoded strings
| extend IsBase64Credential = iff(Base64Pattern != "", true, false) // Check if a base64 pattern was found
| where IsBase64Credential == true or CommandLineLower has_any ("password", "pwd", "username", "user", "pass", "credential")
| project
Timestamp,
DeviceName,
InitiatingProcessAccountName,
InitiatingProcessCommandLine,
ProcessCommandLine,
Base64Pattern,
IsBase64Credential,
ActionType
| sort by Timestamp descExplanation of the Query:
Use Case:
Notes:
PreviousIdentify File with Double ExtensionsNextDetect When Large Number of Files Downloaded From OneDrive or SharePoint
Last updated