registry where host.os.type == "windows" and event.type == "change" and process.executable != null and
event.action == "modification" and registry.value == "ImagePath" and
registry.key : (
"*\\ADWS", "*\\AppHostSvc", "*\\AppReadiness", "*\\AudioEndpointBuilder", "*\\AxInstSV", "*\\camsvc", "*\\CertSvc",
"*\\COMSysApp", "*\\CscService", "*\\defragsvc", "*\\DeviceAssociationService", "*\\DeviceInstall", "*\\DevQueryBroker",
"*\\Dfs", "*\\DFSR", "*\\diagnosticshub.standardcollector.service", "*\\DiagTrack", "*\\DmEnrollmentSvc", "*\\DNS",
"*\\dot3svc", "*\\Eaphost", "*\\GraphicsPerfSvc", "*\\hidserv", "*\\HvHost", "*\\IISADMIN", "*\\IKEEXT",
"*\\InstallService", "*\\iphlpsvc", "*\\IsmServ", "*\\LanmanServer", "*\\MSiSCSI", "*\\NcbService", "*\\Netlogon",
"*\\Netman", "*\\NtFrs", "*\\PlugPlay", "*\\Power", "*\\PrintNotify", "*\\ProfSvc", "*\\PushToInstall", "*\\RSoPProv",
"*\\sacsvr", "*\\SENS", "*\\SensorDataService", "*\\SgrmBroker", "*\\ShellHWDetection", "*\\shpamsvc", "*\\StorSvc",
"*\\svsvc", "*\\swprv", "*\\SysMain", "*\\Themes", "*\\TieringEngineService", "*\\TokenBroker", "*\\TrkWks",
"*\\UALSVC", "*\\UserManager", "*\\vm3dservice", "*\\vmicguestinterface", "*\\vmicheartbeat", "*\\vmickvpexchange",
"*\\vmicrdv", "*\\vmicshutdown", "*\\vmicvmsession", "*\\vmicvss", "*\\vmvss", "*\\VSS", "*\\w3logsvc", "*\\W3SVC",
"*\\WalletService", "*\\WAS", "*\\wercplsupport", "*\\WerSvc", "*\\Winmgmt", "*\\wisvc", "*\\wmiApSrv",
"*\\WPDBusEnum", "*\\WSearch"
) and
not (
registry.data.strings : (
"?:\\Windows\\system32\\*.exe",
"%systemroot%\\system32\\*.exe",
"%windir%\\system32\\*.exe",
"%SystemRoot%\\system32\\svchost.exe -k *",
"%windir%\\system32\\svchost.exe -k *"
) and
not registry.data.strings : (
"*\\cmd.exe",
"*\\cscript.exe",
"*\\ieexec.exe",
"*\\iexpress.exe",
"*\\installutil.exe",
"*\\Microsoft.Workflow.Compiler.exe",
"*\\msbuild.exe",
"*\\mshta.exe",
"*\\msiexec.exe",
"*\\msxsl.exe",
"*\\net.exe",
"*\\powershell.exe",
"*\\pwsh.exe",
"*\\reg.exe",
"*\\RegAsm.exe",
"*\\RegSvcs.exe",
"*\\regsvr32.exe",
"*\\rundll32.exe",
"*\\vssadmin.exe",
"*\\wbadmin.exe",
"*\\wmic.exe",
"*\\wscript.exe"
)
)
Install detection rules in Elastic Security
Detect Potential Privilege Escalation via Service ImagePath Modification in the Elastic Security detection engine by installing this rule into your Elastic Stack.
To setup this rule, check out the installation guide for Prebuilt Security Detection Rules(opens in a new tab or window).