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

Detection of Malware C2 Domains in DNS Events

Back
Ida1c02815-4248-4728-a9ae-dac73c67db23
RulenameDetection of Malware C2 Domains in DNS Events
DescriptionIdentifies a match in DNSEvents from Recorded Future C2 DNS Name Domains Risklist.
SeverityMedium
TacticsCommandAndControl
Required data connectorsDNS
KindScheduled
Query frequency1h
Query period1d
Trigger threshold0
Trigger operatorgt
Source Urihttps://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Recorded Future/Analytic Rules/RecordedFutureDomainMalwareC2inDNSEvents.yaml
Version1.0.1
Arm templatea1c02815-4248-4728-a9ae-dac73c67db23.json
Deploy To Azure
// Identifies a match in DnsEvent from the Recorded Future DOMAIN Malware C2 DNS Name 
let dt_lookBack = 1h;
let ioc_lookBack = 1d;
//Create a list of TLDs in our threat feed for later validation
let list_tlds = ThreatIntelligenceIndicator
| where TimeGenerated > ago(ioc_lookBack)
// Picking up only Recorded Future IOC's that are pertinent to the use case (Malware C2 Detection)
| where Description == 'Recorded Future - Domains - Command and Control Activity'
| where isnotempty(DomainName)
| extend parts = split(DomainName, '.')
| extend tld = parts[(array_length(parts)-1)]
| summarize count() by tostring(tld)
| summarize make_list(tld);
ThreatIntelligenceIndicator
| where TimeGenerated >= ago(ioc_lookBack) and ExpirationDateTime > now()
| where Active == true
// Picking up only Recorded Future IOC's that are pertinent to the use case (Malware C2 Detection)
| where Description == 'Recorded Future - Domains - Command and Control Activity'
// Picking up only IOC's that contain the entities we want
| where isnotempty(DomainName)
| join (
  DnsEvents
  | where TimeGenerated > ago(dt_lookBack)
  //Extract Domain patterns from syslog message
  | where isnotempty(Name)
  | extend parts = split(Name, '.')
  //Split out the TLD
  | extend tld = parts[(array_length(parts)-1)]
  //Validate parsed Domain by checking if the TLD is in the list of TLDs in our threat feed
  | where tld in~ (list_tlds)
  | extend DNS_TimeGenerated = TimeGenerated
  ) 
on $left.DomainName==$right.Name
| where DNS_TimeGenerated >= TimeGenerated and DNS_TimeGenerated < ExpirationDateTime
| summarize LatestIndicatorTime = arg_max(TimeGenerated, *) by IndicatorId
| project LatestIndicatorTime, DomainName, Description, ConfidenceScore, AdditionalInformation, ActivityGroupNames, IndicatorId, ThreatType, ExpirationDateTime, DNS_TimeGenerated, Computer, ClientIP, Name, QueryType
| extend timestamp = DNS_TimeGenerated, HostCustomEntity = Computer, IPCustomEntity = ClientIP, DomainCustomEntity = DomainName
id: a1c02815-4248-4728-a9ae-dac73c67db23
name: Detection of Malware C2 Domains in DNS Events
requiredDataConnectors:
- connectorId: DNS
  dataTypes:
  - DnsEvents
entityMappings:
- entityType: Host
  fieldMappings:
  - identifier: FullName
    columnName: HostCustomEntity
- entityType: IP
  fieldMappings:
  - identifier: Address
    columnName: IPCustomEntity
- entityType: DNS
  fieldMappings:
  - identifier: DomainName
    columnName: DomainCustomEntity
description: |
    'Identifies a match in DNSEvents from Recorded Future C2 DNS Name Domains Risklist.'
status: Available
query: |
  // Identifies a match in DnsEvent from the Recorded Future DOMAIN Malware C2 DNS Name 
  let dt_lookBack = 1h;
  let ioc_lookBack = 1d;
  //Create a list of TLDs in our threat feed for later validation
  let list_tlds = ThreatIntelligenceIndicator
  | where TimeGenerated > ago(ioc_lookBack)
  // Picking up only Recorded Future IOC's that are pertinent to the use case (Malware C2 Detection)
  | where Description == 'Recorded Future - Domains - Command and Control Activity'
  | where isnotempty(DomainName)
  | extend parts = split(DomainName, '.')
  | extend tld = parts[(array_length(parts)-1)]
  | summarize count() by tostring(tld)
  | summarize make_list(tld);
  ThreatIntelligenceIndicator
  | where TimeGenerated >= ago(ioc_lookBack) and ExpirationDateTime > now()
  | where Active == true
  // Picking up only Recorded Future IOC's that are pertinent to the use case (Malware C2 Detection)
  | where Description == 'Recorded Future - Domains - Command and Control Activity'
  // Picking up only IOC's that contain the entities we want
  | where isnotempty(DomainName)
  | join (
    DnsEvents
    | where TimeGenerated > ago(dt_lookBack)
    //Extract Domain patterns from syslog message
    | where isnotempty(Name)
    | extend parts = split(Name, '.')
    //Split out the TLD
    | extend tld = parts[(array_length(parts)-1)]
    //Validate parsed Domain by checking if the TLD is in the list of TLDs in our threat feed
    | where tld in~ (list_tlds)
    | extend DNS_TimeGenerated = TimeGenerated
    ) 
  on $left.DomainName==$right.Name
  | where DNS_TimeGenerated >= TimeGenerated and DNS_TimeGenerated < ExpirationDateTime
  | summarize LatestIndicatorTime = arg_max(TimeGenerated, *) by IndicatorId
  | project LatestIndicatorTime, DomainName, Description, ConfidenceScore, AdditionalInformation, ActivityGroupNames, IndicatorId, ThreatType, ExpirationDateTime, DNS_TimeGenerated, Computer, ClientIP, Name, QueryType
  | extend timestamp = DNS_TimeGenerated, HostCustomEntity = Computer, IPCustomEntity = ClientIP, DomainCustomEntity = DomainName  
severity: Medium
triggerThreshold: 0
queryPeriod: 1d
queryFrequency: 1h
triggerOperator: gt
kind: Scheduled
tactics:
- CommandAndControl
relevantTechniques: 
OriginalUri: https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Recorded Future/Analytic Rules/RecordedFutureDomainMalwareC2inDNSEvents.yaml
version: 1.0.1
{
  "$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/a1c02815-4248-4728-a9ae-dac73c67db23')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/a1c02815-4248-4728-a9ae-dac73c67db23')]",
      "properties": {
        "alertRuleTemplateName": "a1c02815-4248-4728-a9ae-dac73c67db23",
        "customDetails": null,
        "description": "'Identifies a match in DNSEvents from Recorded Future C2 DNS Name Domains Risklist.'\n",
        "displayName": "Detection of Malware C2 Domains in DNS Events",
        "enabled": true,
        "entityMappings": [
          {
            "entityType": "Host",
            "fieldMappings": [
              {
                "columnName": "HostCustomEntity",
                "identifier": "FullName"
              }
            ]
          },
          {
            "entityType": "IP",
            "fieldMappings": [
              {
                "columnName": "IPCustomEntity",
                "identifier": "Address"
              }
            ]
          },
          {
            "entityType": "DNS",
            "fieldMappings": [
              {
                "columnName": "DomainCustomEntity",
                "identifier": "DomainName"
              }
            ]
          }
        ],
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Recorded Future/Analytic Rules/RecordedFutureDomainMalwareC2inDNSEvents.yaml",
        "query": "// Identifies a match in DnsEvent from the Recorded Future DOMAIN Malware C2 DNS Name \nlet dt_lookBack = 1h;\nlet ioc_lookBack = 1d;\n//Create a list of TLDs in our threat feed for later validation\nlet list_tlds = ThreatIntelligenceIndicator\n| where TimeGenerated > ago(ioc_lookBack)\n// Picking up only Recorded Future IOC's that are pertinent to the use case (Malware C2 Detection)\n| where Description == 'Recorded Future - Domains - Command and Control Activity'\n| where isnotempty(DomainName)\n| extend parts = split(DomainName, '.')\n| extend tld = parts[(array_length(parts)-1)]\n| summarize count() by tostring(tld)\n| summarize make_list(tld);\nThreatIntelligenceIndicator\n| where TimeGenerated >= ago(ioc_lookBack) and ExpirationDateTime > now()\n| where Active == true\n// Picking up only Recorded Future IOC's that are pertinent to the use case (Malware C2 Detection)\n| where Description == 'Recorded Future - Domains - Command and Control Activity'\n// Picking up only IOC's that contain the entities we want\n| where isnotempty(DomainName)\n| join (\n  DnsEvents\n  | where TimeGenerated > ago(dt_lookBack)\n  //Extract Domain patterns from syslog message\n  | where isnotempty(Name)\n  | extend parts = split(Name, '.')\n  //Split out the TLD\n  | extend tld = parts[(array_length(parts)-1)]\n  //Validate parsed Domain by checking if the TLD is in the list of TLDs in our threat feed\n  | where tld in~ (list_tlds)\n  | extend DNS_TimeGenerated = TimeGenerated\n  ) \non $left.DomainName==$right.Name\n| where DNS_TimeGenerated >= TimeGenerated and DNS_TimeGenerated < ExpirationDateTime\n| summarize LatestIndicatorTime = arg_max(TimeGenerated, *) by IndicatorId\n| project LatestIndicatorTime, DomainName, Description, ConfidenceScore, AdditionalInformation, ActivityGroupNames, IndicatorId, ThreatType, ExpirationDateTime, DNS_TimeGenerated, Computer, ClientIP, Name, QueryType\n| extend timestamp = DNS_TimeGenerated, HostCustomEntity = Computer, IPCustomEntity = ClientIP, DomainCustomEntity = DomainName\n",
        "queryFrequency": "PT1H",
        "queryPeriod": "P1D",
        "severity": "Medium",
        "status": "Available",
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "CommandAndControl"
        ],
        "techniques": null,
        "templateVersion": "1.0.1",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}