Service installation from user writable directory
Id | 5a9ccb48-1316-46e1-89d1-aca0355c305e |
Rulename | Service installation from user writable directory |
Description | This query detects a service installation that is originated from a user writable directory. Ref: https://attack.mitre.org/techniques/T1569/002/ |
Tactics | Execution |
Techniques | T1569.002 |
Required data connectors | SecurityEvents WindowsSecurityEvents |
Kind | Scheduled |
Source Uri | https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Windows Security Events/Hunting Queries/ServiceInstallationFromUsersWritableDirectory.yaml |
Version | 1.0.0 |
Arm template | 5a9ccb48-1316-46e1-89d1-aca0355c305e.json |
// Enter a reference list for writable user paths"
let WritableUserPaths = dynamic (["\"C:\\Users\\","\"C:\\ProgramData\\"]);
Event
| where Source == "Service Control Manager" and EventID == 7045
| parse EventData with * 'ServiceName">' ServiceName "<" * 'ImagePath">' ImagePath "<" *
| where ImagePath has_any (WritableUserPaths)
| summarize StartTime = min(TimeGenerated), EndTime = max(TimeGenerated) by EventID, Computer, ImagePath, ServiceName, UserName
version: 1.0.0
id: 5a9ccb48-1316-46e1-89d1-aca0355c305e
query: |
// Enter a reference list for writable user paths"
let WritableUserPaths = dynamic (["\"C:\\Users\\","\"C:\\ProgramData\\"]);
Event
| where Source == "Service Control Manager" and EventID == 7045
| parse EventData with * 'ServiceName">' ServiceName "<" * 'ImagePath">' ImagePath "<" *
| where ImagePath has_any (WritableUserPaths)
| summarize StartTime = min(TimeGenerated), EndTime = max(TimeGenerated) by EventID, Computer, ImagePath, ServiceName, UserName
tactics:
- Execution
name: Service installation from user writable directory
kind: Scheduled
description: |
'This query detects a service installation that is originated from a user writable directory.
Ref: https://attack.mitre.org/techniques/T1569/002/'
OriginalUri: https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Windows Security Events/Hunting Queries/ServiceInstallationFromUsersWritableDirectory.yaml
requiredDataConnectors:
- connectorId: SecurityEvents
dataTypes:
- SecurityEvent
- connectorId: WindowsSecurityEvents
dataTypes:
- SecurityEvent
relevantTechniques:
- T1569.002
entityMappings:
- entityType: Account
fieldMappings:
- identifier: FullName
columnName: UserName
- entityType: Host
fieldMappings:
- identifier: FullName
columnName: Computer
- entityType: File
fieldMappings:
- identifier: Name
columnName: ImagePath
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"workspace": {
"type": "String"
}
},
"resources": [
{
"id": "[concat(resourceId('Microsoft.OperationalInsights/workspaces/providers', parameters('workspace'), 'Microsoft.SecurityInsights'),'/alertRules/5a9ccb48-1316-46e1-89d1-aca0355c305e')]",
"name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/5a9ccb48-1316-46e1-89d1-aca0355c305e')]",
"type": "Microsoft.OperationalInsights/workspaces/providers/alertRules",
"kind": "Scheduled",
"apiVersion": "2022-11-01-preview",
"properties": {
"displayName": "Service installation from user writable directory",
"description": "'This query detects a service installation that is originated from a user writable directory.\nRef: https://attack.mitre.org/techniques/T1569/002/'\n",
"enabled": true,
"query": "// Enter a reference list for writable user paths\"\nlet WritableUserPaths = dynamic ([\"\\\"C:\\\\Users\\\\\",\"\\\"C:\\\\ProgramData\\\\\"]);\nEvent\n| where Source == \"Service Control Manager\" and EventID == 7045\n| parse EventData with * 'ServiceName\">' ServiceName \"<\" * 'ImagePath\">' ImagePath \"<\" *\n| where ImagePath has_any (WritableUserPaths)\n| summarize StartTime = min(TimeGenerated), EndTime = max(TimeGenerated) by EventID, Computer, ImagePath, ServiceName, UserName\n",
"suppressionDuration": "PT1H",
"suppressionEnabled": false,
"tactics": [
"Execution"
],
"techniques": [
"T1569.002"
],
"alertRuleTemplateName": "5a9ccb48-1316-46e1-89d1-aca0355c305e",
"customDetails": null,
"entityMappings": [
{
"fieldMappings": [
{
"identifier": "FullName",
"columnName": "UserName"
}
],
"entityType": "Account"
},
{
"fieldMappings": [
{
"identifier": "FullName",
"columnName": "Computer"
}
],
"entityType": "Host"
},
{
"fieldMappings": [
{
"identifier": "Name",
"columnName": "ImagePath"
}
],
"entityType": "File"
}
],
"templateVersion": "1.0.0",
"OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Windows Security Events/Hunting Queries/ServiceInstallationFromUsersWritableDirectory.yaml"
}
}
]
}