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

Certified Pre-Owned - backup of CA private key - rule 1

Back
Idaa5eaac7-1264-4833-b620-8f062be75541
RulenameCertified Pre-Owned - backup of CA private key - rule 1
DescriptionThis query identifies someone that performs a read operation of they CA key from the file.
SeverityMedium
TacticsDefenseEvasion
TechniquesT1036
Required data connectorsSecurityEvents
KindScheduled
Query frequency1h
Query period1h
Trigger threshold0
Trigger operatorgt
Source Urihttps://github.com/Azure/Azure-Sentinel/blob/master/Solutions/FalconFriday/Analytic Rules/CertifiedPreOwned-backup-key-1.yaml
Version1.0.0
Arm templateaa5eaac7-1264-4833-b620-8f062be75541.json
Deploy To Azure
SecurityEvent
// Fill in the machine name of your CA.
| where EventID == 5058 and Computer contains "<YOUR CA MACHINE NAME>"
| where EventData contains "%%2499" // Machine key.
| extend EventData=parse_xml(EventData)
| mv-apply d=EventData.EventData.Data on
(
    where d["@Name"]=="KeyName"
    | project KeyName=tostring(d["#text"])
)
| mv-apply d=EventData.EventData.Data on
(
    where d["@Name"]=="SubjectUserName"
    | project SubjectUserName=tostring(d["#text"])
)
| mv-apply d=EventData.EventData.Data on
(
    where d["@Name"]=="Operation"
    | project Operation=tostring(d["#text"])
)
| extend Operation=iff(Operation == "%%2458", "Read persisted key from file", Operation)
// This one is a guess and very poorly documented :(
| extend Operation=iff(Operation == "%%2459", "Write persisted key to file", Operation)
// Fill in the keyname of the CA key.
| where KeyName == "<INSERT ISSUING CA KEY HERE>" // Or any other key you want to monitor.
queryPeriod: 1h
version: 1.0.0
kind: Scheduled
triggerThreshold: 0
relevantTechniques:
- T1036
triggerOperator: gt
entityMappings:
- fieldMappings:
  - identifier: FullName
    columnName: Computer
  entityType: Host
query: |
  SecurityEvent
  // Fill in the machine name of your CA.
  | where EventID == 5058 and Computer contains "<YOUR CA MACHINE NAME>"
  | where EventData contains "%%2499" // Machine key.
  | extend EventData=parse_xml(EventData)
  | mv-apply d=EventData.EventData.Data on
  (
      where d["@Name"]=="KeyName"
      | project KeyName=tostring(d["#text"])
  )
  | mv-apply d=EventData.EventData.Data on
  (
      where d["@Name"]=="SubjectUserName"
      | project SubjectUserName=tostring(d["#text"])
  )
  | mv-apply d=EventData.EventData.Data on
  (
      where d["@Name"]=="Operation"
      | project Operation=tostring(d["#text"])
  )
  | extend Operation=iff(Operation == "%%2458", "Read persisted key from file", Operation)
  // This one is a guess and very poorly documented :(
  | extend Operation=iff(Operation == "%%2459", "Write persisted key to file", Operation)
  // Fill in the keyname of the CA key.
  | where KeyName == "<INSERT ISSUING CA KEY HERE>" // Or any other key you want to monitor.  
name: Certified Pre-Owned - backup of CA private key - rule 1
queryFrequency: 1h
requiredDataConnectors:
- connectorId: SecurityEvents
  dataTypes:
  - SecurityEvent
description: |
    This query identifies someone that performs a read operation of they CA key from the file.
status: Available
id: aa5eaac7-1264-4833-b620-8f062be75541
OriginalUri: https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/FalconFriday/Analytic Rules/CertifiedPreOwned-backup-key-1.yaml
tactics:
- DefenseEvasion
severity: Medium
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "workspace": {
      "type": "String"
    }
  },
  "resources": [
    {
      "apiVersion": "2023-02-01-preview",
      "id": "[concat(resourceId('Microsoft.OperationalInsights/workspaces/providers', parameters('workspace'), 'Microsoft.SecurityInsights'),'/alertRules/aa5eaac7-1264-4833-b620-8f062be75541')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/aa5eaac7-1264-4833-b620-8f062be75541')]",
      "properties": {
        "alertRuleTemplateName": "aa5eaac7-1264-4833-b620-8f062be75541",
        "customDetails": null,
        "description": "This query identifies someone that performs a read operation of they CA key from the file.\n",
        "displayName": "Certified Pre-Owned - backup of CA private key - rule 1",
        "enabled": true,
        "entityMappings": [
          {
            "entityType": "Host",
            "fieldMappings": [
              {
                "columnName": "Computer",
                "identifier": "FullName"
              }
            ]
          }
        ],
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/FalconFriday/Analytic Rules/CertifiedPreOwned-backup-key-1.yaml",
        "query": "SecurityEvent\n// Fill in the machine name of your CA.\n| where EventID == 5058 and Computer contains \"<YOUR CA MACHINE NAME>\"\n| where EventData contains \"%%2499\" // Machine key.\n| extend EventData=parse_xml(EventData)\n| mv-apply d=EventData.EventData.Data on\n(\n    where d[\"@Name\"]==\"KeyName\"\n    | project KeyName=tostring(d[\"#text\"])\n)\n| mv-apply d=EventData.EventData.Data on\n(\n    where d[\"@Name\"]==\"SubjectUserName\"\n    | project SubjectUserName=tostring(d[\"#text\"])\n)\n| mv-apply d=EventData.EventData.Data on\n(\n    where d[\"@Name\"]==\"Operation\"\n    | project Operation=tostring(d[\"#text\"])\n)\n| extend Operation=iff(Operation == \"%%2458\", \"Read persisted key from file\", Operation)\n// This one is a guess and very poorly documented :(\n| extend Operation=iff(Operation == \"%%2459\", \"Write persisted key to file\", Operation)\n// Fill in the keyname of the CA key.\n| where KeyName == \"<INSERT ISSUING CA KEY HERE>\" // Or any other key you want to monitor.\n",
        "queryFrequency": "PT1H",
        "queryPeriod": "PT1H",
        "severity": "Medium",
        "status": "Available",
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "DefenseEvasion"
        ],
        "techniques": [
          "T1036"
        ],
        "templateVersion": "1.0.0",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}