Detection rules › Kusto

DEV-0270 New User Creation

Status
available
Severity
high
Time window
6h
Source
github.com/Azure/Azure-Sentinel

The following query tries to detect creation of a new user using a known DEV-0270 username/password schema

MITRE ATT&CK coverage

TacticTechniques
Persistence

Telemetry coverage

Rule body

id: 7965f0be-c039-4d18-8ee8-9a6add8aecf3
name: DEV-0270 New User Creation
description: | 
  'The following query tries to detect creation of a new user using a known DEV-0270 username/password schema'
severity: High 
requiredDataConnectors:
  - connectorId: SecurityEvents
    dataTypes:
      - SecurityEvent
  - connectorId: WindowsSecurityEvents
    dataTypes:
      - SecurityEvent
  - connectorId: MicrosoftThreatProtection
    dataTypes:
      - DeviceProcessEvents
queryFrequency: 6h 
queryPeriod: 6h 
triggerOperator: gt 
triggerThreshold: 0 
status: Available
tactics: 
  - Persistence
relevantTechniques:
  - T1098
tags:
  - Dev-0270
query: |
  (union isfuzzy=true
  (SecurityEvent
  | where EventID == 4688
  | where CommandLine has_all ('net user', '/add') 
  | parse CommandLine with * "user " username " "*
  | extend password = extract(@"\buser\s+[^\s]+\s+([^\s]+)", 1, CommandLine) 
  | where username in('DefaultAccount') or password in('P@ssw0rd1234', '_AS_@1394') 
  | project TimeGenerated, Computer, Account, AccountDomain, ProcessName, ProcessNameFullPath = NewProcessName, EventID, Activity, CommandLine, EventSourceName, Type
  ),
  (DeviceProcessEvents 
  | where InitiatingProcessCommandLine has_all('net user', '/add') 
  | parse InitiatingProcessCommandLine with * "user " username " "* 
  | extend password = extract(@"\buser\s+[^\s]+\s+([^\s]+)", 1, InitiatingProcessCommandLine) 
  | where username in('DefaultAccount') or password in('P@ssw0rd1234', '_AS_@1394') 
  | extend Account = strcat(InitiatingProcessAccountDomain, @'\', InitiatingProcessAccountName), Computer = DeviceName
  )
  )
  | extend HostName = tostring(split(Computer, ".")[0]), DomainIndex = toint(indexof(Computer, '.'))
  | extend HostNameDomain = iff(DomainIndex != -1, substring(Computer, DomainIndex + 1), Computer)
  | extend AccountName = tostring(split(Account, @'\')[1]), AccountNTDomain = tostring(split(Account, @'\')[0])
entityMappings:
  - entityType: Account
    fieldMappings:
      - identifier: FullName
        columnName: Account
      - identifier: Name
        columnName: AccountName
      - identifier: NTDomain
        columnName: AccountNTDomain
  - entityType: Host
    fieldMappings:
      - identifier: FullName
        columnName: Computer
      - identifier: HostName
        columnName: HostName
      - identifier: DnsDomain
        columnName: HostNameDomain
version: 1.0.3
kind: Scheduled

Stages and Predicates

Stage 1: union

union of 2 branches

Stage 2: source

SecurityEvent

Stage 3: where

| where EventID == 4688

Stage 4: where

| where CommandLine has_all ('net user', '/add')

Stage 5: parse

| parse CommandLine with * "user " username " "*

Stage 6: extend

| extend password = extract(@"\buser\s+[^\s]+\s+([^\s]+)", 1, CommandLine)

Stage 7: where

| where username in('DefaultAccount') or password in('P@ssw0rd1234', '_AS_@1394')

Stage 8: project

| project TimeGenerated, Computer, Account, AccountDomain, ProcessName, ProcessNameFullPath = NewProcessName, EventID, Activity, CommandLine, EventSourceName, Type

Stage 9: source

DeviceProcessEvents

Stage 10: where

| where InitiatingProcessCommandLine has_all('net user', '/add')

Stage 11: parse

| parse InitiatingProcessCommandLine with * "user " username " "*

Stage 12: extend

| extend password = extract(@"\buser\s+[^\s]+\s+([^\s]+)", 1, InitiatingProcessCommandLine)

Stage 13: where

| where username in('DefaultAccount') or password in('P@ssw0rd1234', '_AS_@1394')

Stage 14: extend (4 consecutive steps)

| extend Account = strcat(InitiatingProcessAccountDomain, @'\', InitiatingProcessAccountName), Computer = DeviceName

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
CommandLinematch
  • /add transforms: term corpus 9 (sigma 5, splunk 2, kusto 2)
  • net user transforms: term
field:"CommandLine" kind:match
EventIDeq
  • 4688 corpus 317 (splunk 283, kusto 33, elastic 1)
field:"EventID" kind:eq value:"4688"
InitiatingProcessCommandLinematch
  • /add transforms: term corpus 9 (sigma 5, splunk 2, kusto 2)
  • net user transforms: term
field:"CommandLine" kind:match
passwordin
  • P@ssw0rd1234
  • _AS_@1394
field:"password" kind:in
usernamein
  • DefaultAccount
field:"username" kind:in value:"DefaultAccount"

Output fields

These fields are emitted when the rule matches.

FieldSource
Accountextend
AccountDomainproject
Activityproject
CommandLineproject
Computerextend
EventIDproject
EventSourceNameproject
ProcessNameproject
ProcessNameFullPathproject
TimeGeneratedproject
Typeproject
passwordextend
DomainIndexextend
HostNameextend
HostNameDomainextend
AccountNTDomainextend
AccountNameextend