{
  "$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/4a9d3c2e-7f1b-4e58-9a0c-2d5b8e3f1a7c')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/4a9d3c2e-7f1b-4e58-9a0c-2d5b8e3f1a7c')]",
      "properties": {
        "alertRuleTemplateName": "4a9d3c2e-7f1b-4e58-9a0c-2d5b8e3f1a7c",
        "customDetails": null,
        "description": "Detects certutil.exe being used to download files from remote URLs via the\n-urlcache or -verifyctl flags. CertUtil is a signed Windows binary (LOLBin)\nthat attackers abuse to download payloads while bypassing application\nwhitelisting and network controls.\nTune AllowlistedDomains to match your PKI/CA infrastructure.\n",
        "displayName": "CertUtil Used for File Download (Living off the Land)",
        "enabled": true,
        "entityMappings": [
          {
            "entityType": "Host",
            "fieldMappings": [
              {
                "columnName": "HostName",
                "identifier": "FullName"
              }
            ]
          },
          {
            "entityType": "Account",
            "fieldMappings": [
              {
                "columnName": "AccountName",
                "identifier": "Name"
              },
              {
                "columnName": "AccountDomain",
                "identifier": "NTDomain"
              }
            ]
          },
          {
            "entityType": "Process",
            "fieldMappings": [
              {
                "columnName": "ProcessCommandLine",
                "identifier": "CommandLine"
              }
            ]
          }
        ],
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Endpoint%20Threat%20Protection%20Essentials/Analytic%20Rules/Certutil-Download-Abuse.yaml",
        "query": "let Lookback = 1h;\nlet AllowlistedDomains = dynamic([\n  \"windowsupdate.microsoft.com\",\n  \"download.microsoft.com\",\n  \"dl.delivery.mp.microsoft.com\",\n  \"ctldl.windowsupdate.com\"\n]);\nlet MDE_Results =\n  DeviceProcessEvents\n  | where Timestamp >= ago(Lookback)\n  | where FileName =~ \"certutil.exe\"\n  | where ProcessCommandLine has_any (\"-urlcache\", \"-verifyctl\", \"-decode\", \"-decodehex\")\n  | where ProcessCommandLine has_any (\"http://\", \"https://\", \"ftp://\")\n  | where not(ProcessCommandLine has_any (AllowlistedDomains))\n  | extend\n      AccountName   = InitiatingProcessAccountName,\n      AccountDomain = InitiatingProcessAccountDomain,\n      HostName      = DeviceName,\n      EventTime     = Timestamp\n  | project EventTime, HostName, AccountName, AccountDomain,\n      ProcessCommandLine, InitiatingProcessFileName;\nlet SecEvent_Results =\n  SecurityEvent\n  | where TimeGenerated >= ago(Lookback)\n  | where EventID == 4688\n  | where NewProcessName endswith \"\\\\certutil.exe\"\n  | where CommandLine has_any (\"-urlcache\", \"-verifyctl\", \"-decode\", \"-decodehex\")\n  | where CommandLine has_any (\"http://\", \"https://\", \"ftp://\")\n  | where not(CommandLine has_any (AllowlistedDomains))\n  | extend\n      AccountName   = SubjectUserName,\n      AccountDomain = SubjectDomainName,\n      HostName      = Computer,\n      EventTime     = TimeGenerated,\n      ProcessCommandLine = CommandLine,\n      InitiatingProcessFileName = ParentProcessName\n  | project EventTime, HostName, AccountName, AccountDomain,\n      ProcessCommandLine, InitiatingProcessFileName;\nunion MDE_Results, SecEvent_Results\n| sort by EventTime desc\n",
        "queryFrequency": "PT1H",
        "queryPeriod": "PT1H",
        "severity": "High",
        "status": "Available",
        "subTechniques": [],
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "CommandAndControl",
          "DefenseEvasion"
        ],
        "techniques": [
          "T1105",
          "T1140",
          "T1218"
        ],
        "templateVersion": "1.0.0",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}
