Microsoft Sentinel Analytic Rules
cloudbrothers.infoAzure Sentinel RepoToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

Service installation from user writable directory

Back
Id5a9ccb48-1316-46e1-89d1-aca0355c305e
RulenameService installation from user writable directory
DescriptionThis query detects a service installation that is originated from a user writable directory.

Ref: https://attack.mitre.org/techniques/T1569/002/
TacticsExecution
TechniquesT1569.002
Required data connectorsSecurityEvents
WindowsSecurityEvents
KindScheduled
Source Urihttps://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Windows Security Events/Hunting Queries/ServiceInstallationFromUsersWritableDirectory.yaml
Version1.0.0
Arm template5a9ccb48-1316-46e1-89d1-aca0355c305e.json
Deploy To Azure
// 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
id: 5a9ccb48-1316-46e1-89d1-aca0355c305e
relevantTechniques:
- T1569.002
OriginalUri: https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Windows Security Events/Hunting Queries/ServiceInstallationFromUsersWritableDirectory.yaml
description: |
  'This query detects a service installation that is originated from a user writable directory.
  Ref: https://attack.mitre.org/techniques/T1569/002/'  
kind: Scheduled
version: 1.0.0
entityMappings:
- fieldMappings:
  - identifier: FullName
    columnName: UserName
  entityType: Account
- fieldMappings:
  - identifier: FullName
    columnName: Computer
  entityType: Host
- fieldMappings:
  - identifier: Name
    columnName: ImagePath
  entityType: File
requiredDataConnectors:
- connectorId: SecurityEvents
  dataTypes:
  - SecurityEvent
- connectorId: WindowsSecurityEvents
  dataTypes:
  - SecurityEvent
tactics:
- Execution
name: Service installation from user writable directory
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  
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "workspace": {
      "type": "String"
    }
  },
  "resources": [
    {
      "apiVersion": "2024-01-01-preview",
      "id": "[concat(resourceId('Microsoft.OperationalInsights/workspaces/providers', parameters('workspace'), 'Microsoft.SecurityInsights'),'/alertRules/5a9ccb48-1316-46e1-89d1-aca0355c305e')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/5a9ccb48-1316-46e1-89d1-aca0355c305e')]",
      "properties": {
        "alertRuleTemplateName": "5a9ccb48-1316-46e1-89d1-aca0355c305e",
        "customDetails": null,
        "description": "'This query detects a service installation that is originated from a user writable directory.\nRef: https://attack.mitre.org/techniques/T1569/002/'\n",
        "displayName": "Service installation from user writable directory",
        "enabled": true,
        "entityMappings": [
          {
            "entityType": "Account",
            "fieldMappings": [
              {
                "columnName": "UserName",
                "identifier": "FullName"
              }
            ]
          },
          {
            "entityType": "Host",
            "fieldMappings": [
              {
                "columnName": "Computer",
                "identifier": "FullName"
              }
            ]
          },
          {
            "entityType": "File",
            "fieldMappings": [
              {
                "columnName": "ImagePath",
                "identifier": "Name"
              }
            ]
          }
        ],
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Windows Security Events/Hunting Queries/ServiceInstallationFromUsersWritableDirectory.yaml",
        "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",
        "subTechniques": [
          "T1569.002"
        ],
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "Execution"
        ],
        "techniques": [
          "T1569"
        ],
        "templateVersion": "1.0.0"
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}