Detection rules › Elastic

Dual Persistence via Startup and Scheduled Task

Time window
3m
Sequence by
Effective_process.entity_id, process.entity_id
Source
github.com/elastic/protections-artifacts

Identifies the creation of two persistence items via startup followed by scheduled task by an unsigned executable. Adversaries may use this technique to maintain multiple methods of persistence on an endpoint.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies the creation of two persistence items via startup followed by scheduled task by an unsigned executable.
Adversaries may use this technique to maintain multiple methods of persistence on an endpoint.
"""
id = "8eb8bf95-872b-43c9-9f7c-528d795d6b4e"
license = "Elastic License v2"
name = "Dual Persistence via Startup and Scheduled Task"
os_list = ["windows"]
reference = ["https://docs.microsoft.com/en-us/previous-versions/technet-magazine/ee851671(v=msdn.10)"]
version = "1.0.16"

query = '''
sequence with maxspan=3m
 [any where event.category in ("registry", "file") and
  process.executable : ("?:\\*", "\\Device\\Mup*") and
  event.action != "deletion" and user.id like ("S-1-5-21*", "S-1-12-*") and 
  not process.code_signature.status like ("trusted", "errorExpired", "errorCode_endpoint*") and 
   (
    (registry.data.strings != null and 
     not registry.data.strings : ("*:\\Program Files\\*", "*:\\Program Files (x86)\\*") and
     registry.path :
              ("H*\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\*", 
	       "H*\\Software\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Run\\*",
	       "H*\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\Run\\*", 
	       "H*\\Software\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\Run\\*", 
	       "HKEY_USERS\\*\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Windows\\Load", 
	       "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\Shell", 
	       "HKEY_USERS\\*\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\Shell", 
	       "HKEY_USERS\\*\\Environment\\UserInitMprLogonScript", 
	       "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\Userinit", 
	       "HKEY_USERS\\*\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\\Shell", 
	       "HKEY_USERS\\*\\SOFTWARE\\Policies\\Microsoft\\Windows\\System\\Scripts\\Logoff\\Script", 
	       "HKEY_USERS\\*\\SOFTWARE\\Policies\\Microsoft\\Windows\\System\\Scripts\\Logon\\Script", 
	       "HKEY_USERS\\*\\SOFTWARE\\Policies\\Microsoft\\Windows\\System\\Scripts\\Shutdown\\Script", 
	       "HKEY_USERS\\*\\SOFTWARE\\Policies\\Microsoft\\Windows\\System\\Scripts\\Startup\\Script", 
	       "HKEY_USERS\\*\\SOFTWARE\\Microsoft\\Ctf\\LangBarAddin\\*\\FilePath", 
	       "HKEY_USERS\\*\\SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\*\\Exec", 
	       "HKEY_USERS\\*\\SOFTWARE\\Microsoft\\Command Processor\\Autorun")) or
    (file.name != null and file.path : "?:\\*\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\*" and not file.name : "desktop.ini")
   )] by process.entity_id
  [file where event.action != "deletion" and
   file.path : "?:\\Windows\\System32\\Tasks\\*" and file.name != null] by Effective_process.entity_id
'''

min_endpoint_version = "8.4.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0

[[optional_actions]]
action = "rollback"
field = "process.entity_id"
state = 0

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1053"
name = "Scheduled Task/Job"
reference = "https://attack.mitre.org/techniques/T1053/"
[[threat.technique.subtechnique]]
id = "T1053.005"
name = "Scheduled Task"
reference = "https://attack.mitre.org/techniques/T1053/005/"


[[threat.technique]]
id = "T1547"
name = "Boot or Logon Autostart Execution"
reference = "https://attack.mitre.org/techniques/T1547/"
[[threat.technique.subtechnique]]
id = "T1547.001"
name = "Registry Run Keys / Startup Folder"
reference = "https://attack.mitre.org/techniques/T1547/001/"



[threat.tactic]
id = "TA0003"
name = "Persistence"
reference = "https://attack.mitre.org/tactics/TA0003/"
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1112"
name = "Modify Registry"
reference = "https://attack.mitre.org/techniques/T1112/"


[threat.tactic]
id = "TA0005"
name = "Defense Evasion"
reference = "https://attack.mitre.org/tactics/TA0005/"

[internal]
min_endpoint_version = "8.4.0"

Stages and Predicates

Ordered sequence: each step below must occur in order within 3m, correlated by Effective_process.entity_id, process.entity_id.

Stage 1: any

[any where event.category in ("registry", "file") and
  process.executable : ("?:\\*", "\\Device\\Mup*") and
  event.action != "deletion" and user.id like ("S-1-5-21*", "S-1-12-*") and 
  not process.code_signature.status like ("trusted", "errorExpired", "errorCode_endpoint*") and 
   (
    (registry.data.strings != null and 
     not registry.data.strings : ("*:\\Program Files\\*", "*:\\Program Files (x86)\\*") and
     registry.path :
              ("H*\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\*", 
	       "H*\\Software\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Run\\*",
	       "H*\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\Run\\*", 
	       "H*\\Software\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\Run\\*", 
	       "HKEY_USERS\\*\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Windows\\Load", 
	       "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\Shell", 
	       "HKEY_USERS\\*\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\Shell", 
	       "HKEY_USERS\\*\\Environment\\UserInitMprLogonScript", 
	       "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\Userinit", 
	       "HKEY_USERS\\*\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\\Shell", 
	       "HKEY_USERS\\*\\SOFTWARE\\Policies\\Microsoft\\Windows\\System\\Scripts\\Logoff\\Script", 
	       "HKEY_USERS\\*\\SOFTWARE\\Policies\\Microsoft\\Windows\\System\\Scripts\\Logon\\Script", 
	       "HKEY_USERS\\*\\SOFTWARE\\Policies\\Microsoft\\Windows\\System\\Scripts\\Shutdown\\Script", 
	       "HKEY_USERS\\*\\SOFTWARE\\Policies\\Microsoft\\Windows\\System\\Scripts\\Startup\\Script", 
	       "HKEY_USERS\\*\\SOFTWARE\\Microsoft\\Ctf\\LangBarAddin\\*\\FilePath", 
	       "HKEY_USERS\\*\\SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\*\\Exec", 
	       "HKEY_USERS\\*\\SOFTWARE\\Microsoft\\Command Processor\\Autorun")) or
    (file.name != null and file.path : "?:\\*\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\*" and not file.name : "desktop.ini")
   )] by process.entity_id

Stage 2: file

[file where event.action != "deletion" and
   file.path : "?:\\Windows\\System32\\Tasks\\*" and file.name != null] by Effective_process.entity_id

Exclusions

The rule actively suppresses these predicates.

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actionne
  • deletion corpus 86 (elastic 86)
field:"EventType" kind:ne value:"deletion"
event.categoryin
  • file corpus 43 (elastic 43)
  • registry corpus 14 (elastic 14)
field:"event.category" kind:in
file.nameis_not_null
  • (no value, null check)
field:"file.name" kind:is_not_null
file.pathwildcard
  • ?:\*\Microsoft\Windows\Start Menu\Programs\Startup\* corpus 9 (elastic 9)
  • ?:\Windows\System32\Tasks\* corpus 6 (elastic 6)
field:"TargetFilename" kind:wildcard
process.executablewildcard
  • ?:\* corpus 18 (elastic 18)
  • \Device\Mup* corpus 4 (elastic 4)
field:"Image" kind:wildcard
registry.data.stringsis_not_null
  • (no value, null check)
field:"Details" kind:is_not_null
registry.pathwildcard
  • H*\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run\* corpus 11 (elastic 11)
  • H*\Software\Microsoft\Windows\CurrentVersion\Run\* corpus 12 (elastic 12)
  • H*\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run\* corpus 11 (elastic 11)
  • H*\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Run\* corpus 11 (elastic 11)
  • HKEY_USERS\*\Environment\UserInitMprLogonScript corpus 12 (elastic 12)
  • HKEY_USERS\*\SOFTWARE\Microsoft\Command Processor\Autorun corpus 11 (elastic 11)
  • HKEY_USERS\*\SOFTWARE\Microsoft\Ctf\LangBarAddin\*\FilePath corpus 11 (elastic 11)
  • HKEY_USERS\*\SOFTWARE\Microsoft\Internet Explorer\Extensions\*\Exec corpus 11 (elastic 11)
  • HKEY_USERS\*\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\Load corpus 12 (elastic 12)
  • HKEY_USERS\*\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell corpus 12 (elastic 12)
  • HKEY_USERS\*\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\Shell corpus 11 (elastic 11)
  • HKEY_USERS\*\SOFTWARE\Policies\Microsoft\Windows\System\Scripts\Logoff\Script corpus 11 (elastic 11)
  • HKEY_USERS\*\SOFTWARE\Policies\Microsoft\Windows\System\Scripts\Logon\Script corpus 11 (elastic 11)
  • HKEY_USERS\*\SOFTWARE\Policies\Microsoft\Windows\System\Scripts\Shutdown\Script corpus 11 (elastic 11)
  • HKEY_USERS\*\SOFTWARE\Policies\Microsoft\Windows\System\Scripts\Startup\Script corpus 11 (elastic 11)
  • HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell
  • HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit
field:"TargetObject" kind:wildcard
user.idwildcard
  • S-1-12-* corpus 46 (elastic 46)
  • S-1-5-21* corpus 47 (elastic 47)
field:"user.id" kind:wildcard