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

User login from different countries within 3 hours Uses Authentication Normalization

Back
Id09ec8fa2-b25f-4696-bfae-05a7b85d7b9e
RulenameUser login from different countries within 3 hours (Uses Authentication Normalization)
DescriptionThis query searches for successful user logins from different countries within 3 hours.

To use this analytics rule, make sure you have deployed the ASIM normalization parsers
SeverityHigh
TacticsInitialAccess
TechniquesT1078
KindScheduled
Query frequency3h
Query period3h
Trigger threshold0
Trigger operatorgt
Source Urihttps://github.com/Azure/Azure-Sentinel/blob/master/Detections/ASimAuthentication/imAuthSigninsMultipleCountries.yaml
Version1.2.5
Arm template09ec8fa2-b25f-4696-bfae-05a7b85d7b9e.json
Deploy To Azure
let timeframe = ago(3h);
let threshold = 2;
imAuthentication
| where TimeGenerated > timeframe
| where EventType == 'Logon'
    and EventResult == 'Success'
| where isnotempty(SrcGeoCountry)
| summarize
    StartTime        = min(TimeGenerated)
    , EndTime        = max(TimeGenerated)
    , Vendors        = make_set(EventVendor, 128)
    , Products       = make_set(EventProduct, 128)
    , NumOfCountries = dcount(SrcGeoCountry)
    , Countries      = make_set(SrcGeoCountry, 128)
    by TargetUserId, TargetUsername, TargetUserType
| where NumOfCountries >= threshold
| where TargetUserType !in ("Application", "Service", "System", "Other", "Machine", "ServicePrincipal")
| extend
  Name = iif(
      TargetUsername contains "@"
          , tostring(split(TargetUsername, '@', 0)[0])
          , TargetUsername
      ),
  UPNSuffix = iif(
      TargetUsername contains "@"
      , tostring(split(TargetUsername, '@', 1)[0])
      , ""
  )
kind: Scheduled
relevantTechniques:
- T1078
metadata:
  support:
    tier: Community
  author:
    name: Ofer Shezaf
  categories:
    domains:
    - Security - Network
  source:
    kind: Community
description: |
  'This query searches for successful user logins from different countries within 3 hours.
   To use this analytics rule, make sure you have deployed the [ASIM normalization parsers](https://aka.ms/ASimAuthentication)'  
queryPeriod: 3h
queryFrequency: 3h
tactics:
- InitialAccess
name: User login from different countries within 3 hours (Uses Authentication Normalization)
requiredDataConnectors: []
entityMappings:
- entityType: Account
  fieldMappings:
  - identifier: FullName
    columnName: TargetUserName
  - identifier: Name
    columnName: Name
  - identifier: UPNSuffix
    columnName: UPNSuffix
triggerThreshold: 0
OriginalUri: https://github.com/Azure/Azure-Sentinel/blob/master/Detections/ASimAuthentication/imAuthSigninsMultipleCountries.yaml
version: 1.2.5
id: 09ec8fa2-b25f-4696-bfae-05a7b85d7b9e
query: |
  let timeframe = ago(3h);
  let threshold = 2;
  imAuthentication
  | where TimeGenerated > timeframe
  | where EventType == 'Logon'
      and EventResult == 'Success'
  | where isnotempty(SrcGeoCountry)
  | summarize
      StartTime        = min(TimeGenerated)
      , EndTime        = max(TimeGenerated)
      , Vendors        = make_set(EventVendor, 128)
      , Products       = make_set(EventProduct, 128)
      , NumOfCountries = dcount(SrcGeoCountry)
      , Countries      = make_set(SrcGeoCountry, 128)
      by TargetUserId, TargetUsername, TargetUserType
  | where NumOfCountries >= threshold
  | where TargetUserType !in ("Application", "Service", "System", "Other", "Machine", "ServicePrincipal")
  | extend
    Name = iif(
        TargetUsername contains "@"
            , tostring(split(TargetUsername, '@', 0)[0])
            , TargetUsername
        ),
    UPNSuffix = iif(
        TargetUsername contains "@"
        , tostring(split(TargetUsername, '@', 1)[0])
        , ""
    )  
triggerOperator: gt
tags:
- version: 1.0.0
  Id: 2954d424-f786-4677-9ffc-c24c44c6e7d5
- SchemaVersion: 0.1.0
  Schema: ASIMAuthentication
severity: High
{
  "$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/09ec8fa2-b25f-4696-bfae-05a7b85d7b9e')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/09ec8fa2-b25f-4696-bfae-05a7b85d7b9e')]",
      "properties": {
        "alertRuleTemplateName": "09ec8fa2-b25f-4696-bfae-05a7b85d7b9e",
        "customDetails": null,
        "description": "'This query searches for successful user logins from different countries within 3 hours.\n To use this analytics rule, make sure you have deployed the [ASIM normalization parsers](https://aka.ms/ASimAuthentication)'\n",
        "displayName": "User login from different countries within 3 hours (Uses Authentication Normalization)",
        "enabled": true,
        "entityMappings": [
          {
            "entityType": "Account",
            "fieldMappings": [
              {
                "columnName": "TargetUserName",
                "identifier": "FullName"
              },
              {
                "columnName": "Name",
                "identifier": "Name"
              },
              {
                "columnName": "UPNSuffix",
                "identifier": "UPNSuffix"
              }
            ]
          }
        ],
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Detections/ASimAuthentication/imAuthSigninsMultipleCountries.yaml",
        "query": "let timeframe = ago(3h);\nlet threshold = 2;\nimAuthentication\n| where TimeGenerated > timeframe\n| where EventType == 'Logon'\n    and EventResult == 'Success'\n| where isnotempty(SrcGeoCountry)\n| summarize\n    StartTime        = min(TimeGenerated)\n    , EndTime        = max(TimeGenerated)\n    , Vendors        = make_set(EventVendor, 128)\n    , Products       = make_set(EventProduct, 128)\n    , NumOfCountries = dcount(SrcGeoCountry)\n    , Countries      = make_set(SrcGeoCountry, 128)\n    by TargetUserId, TargetUsername, TargetUserType\n| where NumOfCountries >= threshold\n| where TargetUserType !in (\"Application\", \"Service\", \"System\", \"Other\", \"Machine\", \"ServicePrincipal\")\n| extend\n  Name = iif(\n      TargetUsername contains \"@\"\n          , tostring(split(TargetUsername, '@', 0)[0])\n          , TargetUsername\n      ),\n  UPNSuffix = iif(\n      TargetUsername contains \"@\"\n      , tostring(split(TargetUsername, '@', 1)[0])\n      , \"\"\n  )\n",
        "queryFrequency": "PT3H",
        "queryPeriod": "PT3H",
        "severity": "High",
        "subTechniques": [],
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "InitialAccess"
        ],
        "tags": [
          {
            "Id": "2954d424-f786-4677-9ffc-c24c44c6e7d5",
            "version": "1.0.0"
          },
          {
            "Schema": "ASIMAuthentication",
            "SchemaVersion": "0.1.0"
          }
        ],
        "techniques": [
          "T1078"
        ],
        "templateVersion": "1.2.5",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}