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 IPs in DNS Events

Back
Id22cc1dff-14ad-481d-97e1-0602895e429e
RulenameDetection of Malware C2 IPs in DNS Events
DescriptionIdentifies a match in DnsEvents from Recorded Future Actively Communicating C&C Server 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/RecordedFutureIPMalwareC2inDNSEvents.yaml
Version1.0.0
Arm template22cc1dff-14ad-481d-97e1-0602895e429e.json
Deploy To Azure
// Identifies a match in DnsEvent from the Recorded Future C2 Malware Detection IPs (Actively Communicating C&C Server RiskList)
let dt_lookBack = 1h;
let ioc_lookBack = 1d;
ThreatIntelligenceIndicator
// Picking up only Recorded Future IOC's that are pertinent to the use case (Malware C2 Detection)
| where Description == "Recorded Future - IP - Actively Communicating C&C Server"
| where TimeGenerated >= ago(ioc_lookBack) and ExpirationDateTime > now()
| where Active == true
| extend TI_ipEntity = NetworkIP
| join (
  DnsEvents | where TimeGenerated >= ago(dt_lookBack)
  | where SubType =~ "LookupQuery" and isnotempty(IPAddresses)
  | extend SingleIP = split(IPAddresses, ",")
  | mvexpand SingleIP
  | extend SingleIP = tostring(SingleIP)
  // renaming time column so it is clear the log this came from
  | extend DNS_TimeGenerated = TimeGenerated
  )
on $left.TI_ipEntity == $right.SingleIP
| where DNS_TimeGenerated >= TimeGenerated and DNS_TimeGenerated < ExpirationDateTime
| summarize LatestIndicatorTime = arg_max(TimeGenerated, *) by IndicatorId
| project LatestIndicatorTime, ActivityGroupNames, IndicatorId, ThreatType, Url, ExpirationDateTime, ConfidenceScore, DNS_TimeGenerated, TI_ipEntity, Computer, EventId, SubType, ClientIP, Name, IPAddresses, NetworkIP, Description, AdditionalInformation
| extend timestamp = DNS_TimeGenerated, IPCustomEntity = ClientIP, HostCustomEntity = Computer, URLCustomEntity = Url
queryPeriod: 1d
version: 1.0.0
kind: Scheduled
triggerThreshold: 0
relevantTechniques: 
triggerOperator: gt
entityMappings:
- fieldMappings:
  - identifier: FullName
    columnName: HostCustomEntity
  entityType: Host
- fieldMappings:
  - identifier: Address
    columnName: IPCustomEntity
  entityType: IP
- fieldMappings:
  - identifier: Url
    columnName: URLCustomEntity
  entityType: URL
- fieldMappings:
  - identifier: Address
    columnName: TI_ipEntity
  entityType: IP
query: |
  // Identifies a match in DnsEvent from the Recorded Future C2 Malware Detection IPs (Actively Communicating C&C Server RiskList)
  let dt_lookBack = 1h;
  let ioc_lookBack = 1d;
  ThreatIntelligenceIndicator
  // Picking up only Recorded Future IOC's that are pertinent to the use case (Malware C2 Detection)
  | where Description == "Recorded Future - IP - Actively Communicating C&C Server"
  | where TimeGenerated >= ago(ioc_lookBack) and ExpirationDateTime > now()
  | where Active == true
  | extend TI_ipEntity = NetworkIP
  | join (
    DnsEvents | where TimeGenerated >= ago(dt_lookBack)
    | where SubType =~ "LookupQuery" and isnotempty(IPAddresses)
    | extend SingleIP = split(IPAddresses, ",")
    | mvexpand SingleIP
    | extend SingleIP = tostring(SingleIP)
    // renaming time column so it is clear the log this came from
    | extend DNS_TimeGenerated = TimeGenerated
    )
  on $left.TI_ipEntity == $right.SingleIP
  | where DNS_TimeGenerated >= TimeGenerated and DNS_TimeGenerated < ExpirationDateTime
  | summarize LatestIndicatorTime = arg_max(TimeGenerated, *) by IndicatorId
  | project LatestIndicatorTime, ActivityGroupNames, IndicatorId, ThreatType, Url, ExpirationDateTime, ConfidenceScore, DNS_TimeGenerated, TI_ipEntity, Computer, EventId, SubType, ClientIP, Name, IPAddresses, NetworkIP, Description, AdditionalInformation
  | extend timestamp = DNS_TimeGenerated, IPCustomEntity = ClientIP, HostCustomEntity = Computer, URLCustomEntity = Url  
name: Detection of Malware C2 IPs in DNS Events
queryFrequency: 1h
requiredDataConnectors:
- connectorId: DNS
  dataTypes:
  - DnsEvents
description: |
    'Identifies a match in DnsEvents from Recorded Future Actively Communicating C&C Server Risklist.'
status: Available
id: 22cc1dff-14ad-481d-97e1-0602895e429e
OriginalUri: https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Recorded Future/Analytic Rules/RecordedFutureIPMalwareC2inDNSEvents.yaml
tactics:
- CommandAndControl
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/22cc1dff-14ad-481d-97e1-0602895e429e')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/22cc1dff-14ad-481d-97e1-0602895e429e')]",
      "properties": {
        "alertRuleTemplateName": "22cc1dff-14ad-481d-97e1-0602895e429e",
        "customDetails": null,
        "description": "'Identifies a match in DnsEvents from Recorded Future Actively Communicating C&C Server Risklist.'\n",
        "displayName": "Detection of Malware C2 IPs in DNS Events",
        "enabled": true,
        "entityMappings": [
          {
            "entityType": "Host",
            "fieldMappings": [
              {
                "columnName": "HostCustomEntity",
                "identifier": "FullName"
              }
            ]
          },
          {
            "entityType": "IP",
            "fieldMappings": [
              {
                "columnName": "IPCustomEntity",
                "identifier": "Address"
              }
            ]
          },
          {
            "entityType": "URL",
            "fieldMappings": [
              {
                "columnName": "URLCustomEntity",
                "identifier": "Url"
              }
            ]
          },
          {
            "entityType": "IP",
            "fieldMappings": [
              {
                "columnName": "TI_ipEntity",
                "identifier": "Address"
              }
            ]
          }
        ],
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Recorded Future/Analytic Rules/RecordedFutureIPMalwareC2inDNSEvents.yaml",
        "query": "// Identifies a match in DnsEvent from the Recorded Future C2 Malware Detection IPs (Actively Communicating C&C Server RiskList)\nlet dt_lookBack = 1h;\nlet ioc_lookBack = 1d;\nThreatIntelligenceIndicator\n// Picking up only Recorded Future IOC's that are pertinent to the use case (Malware C2 Detection)\n| where Description == \"Recorded Future - IP - Actively Communicating C&C Server\"\n| where TimeGenerated >= ago(ioc_lookBack) and ExpirationDateTime > now()\n| where Active == true\n| extend TI_ipEntity = NetworkIP\n| join (\n  DnsEvents | where TimeGenerated >= ago(dt_lookBack)\n  | where SubType =~ \"LookupQuery\" and isnotempty(IPAddresses)\n  | extend SingleIP = split(IPAddresses, \",\")\n  | mvexpand SingleIP\n  | extend SingleIP = tostring(SingleIP)\n  // renaming time column so it is clear the log this came from\n  | extend DNS_TimeGenerated = TimeGenerated\n  )\non $left.TI_ipEntity == $right.SingleIP\n| where DNS_TimeGenerated >= TimeGenerated and DNS_TimeGenerated < ExpirationDateTime\n| summarize LatestIndicatorTime = arg_max(TimeGenerated, *) by IndicatorId\n| project LatestIndicatorTime, ActivityGroupNames, IndicatorId, ThreatType, Url, ExpirationDateTime, ConfidenceScore, DNS_TimeGenerated, TI_ipEntity, Computer, EventId, SubType, ClientIP, Name, IPAddresses, NetworkIP, Description, AdditionalInformation\n| extend timestamp = DNS_TimeGenerated, IPCustomEntity = ClientIP, HostCustomEntity = Computer, URLCustomEntity = Url\n",
        "queryFrequency": "PT1H",
        "queryPeriod": "P1D",
        "severity": "Medium",
        "status": "Available",
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "CommandAndControl"
        ],
        "techniques": null,
        "templateVersion": "1.0.0",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}