Detection rules › Elastic

Startup Persistence via Windows Script Interpreter

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

Identifies modification of startup persistence locations (registry run keys and startup folder) by a Windows script interpreter. Adversaries may use this technique to maintain persistence.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies modification of startup persistence locations (registry run keys and startup folder) by a Windows script
interpreter. Adversaries may use this technique to maintain persistence.
"""
id = "a85000c8-3eac-413b-8353-079343c2b6f0"
license = "Elastic License v2"
name = "Startup Persistence via Windows Script Interpreter"
os_list = ["windows"]
reference = ["https://docs.microsoft.com/en-us/previous-versions/technet-magazine/ee851671(v=msdn.10)"]
version = "1.0.42"

query = '''
sequence by process.entity_id with maxspan=2m
 [process where event.action : "start" and
  (
   process.pe.original_file_name : ("wscript.exe", "powershell.exe", "mshta.exe", "pwsh.exe") or
   process.parent.name : ("wscript.exe", "powershell.exe", "mshta.exe", "pwsh.exe") or
   (process.name : "javaw.exe" and process.args : "-jar" and process.args_count == 3)
   ) and
   /* noisy patterns */
  not process.Ext.token.integrity_level_name == "system" and
  not (process.command_line : ("*:\\Program Files\\*.exe", "*:\\Program Files (x86)\\*.exe", "*\\\\*\\SYSVOL\\*") and not process.name : "javaw.exe") and
  not process.executable : "?:\\Users\\*\\AppData\\Local\\Microsoft\\OneDrive\\OneDrive.exe" and
  not (process.name : "powershell.exe" and process.command_line : ("*$env:APPDATA*Browser Assistant*", "*MicrosoftEdgeAutoLaunch*GoogleChromeAutoLaunch*")) and
  not (process.pe.original_file_name : "Teams.exe" and process.code_signature.trusted == true) and
  not (process.name : "cscript.exe" and process.args : "?:\\Program Files\\Nextech\\NxTSAddin\\InstallNXTSAddinForCurrentUser.vbs") and
  not (process.parent.name : "powershell.exe" and process.parent.args : "'C:\\ProgramData\\CentraStage\\Packages\\*.ps1'") and
  not process.executable :
                 ("C:\\Program Files (x86)\\Exclaimer Ltd\\Cloud Signature Update Agent\\Exclaimer.CloudSignatureAgent.exe",
                  "C:\\Windows\\System32\\wsl.exe",
                  "C:\\Program Files\\Microsoft OneDrive\\OneDrive.exe",
                  "C:\\Program Files\\Microsoft Office\\root\\Office??\\ONENOTE.EXE",
                  "C:\\Program Files\\WindowsApps\\MSTeams_*\\ms-teams.exe",
                  "C:\\Program Files\\Nextcloud\\nextcloud.exe",
                  "C:\\Program Files\\WindowsApps\\MSTeams_*\\ms-teams.exe") and
  not (process.code_signature.subject_name in ("CrashPlan Group LLC", "Red Hat, Inc", "d7xTech, Inc", "Code42 Software Inc",
       "Galactic Advisors, Inc.", "Hamilton Bonaduz AG", "epostbox epb GmbH", "FastTrack Software ApS", "AnyDesk Software GmbH",
       "Dassault Systemes SolidWorks Corp.") and
       process.code_signature.trusted == true) and
  not process.parent.executable :
                      ("C:\\Program Files (x86)\\BigFix Enterprise\\BES Client\\BESClient.exe",
                       "C:\\Program Files (x86)\\Microsoft Intune Management Extension\\agentexecutor.exe",
                       "C:\\Program Files\\Produce8-Agent\\Produce8-Agent.exe",
                       "C:\\WINDOWS\\_ScriptingFramework\\Modul\\Engine.exe") and
  process.hash.sha256 != null and
  not process.hash.sha256 in ("7b2ba9a849427f8cafac26fe3c522a62287b70dd05de3464e673706a8871552d",
                             "a22895e55b26202eae166838edbe2ea6aad00d7ea600c11f8a31ede5cbce2048",
                             "b924ad8062eaf4e70437c8be50fa612162795ff0839479546ce907ffa8d6e386",
                             "e554425243e3e8ca1cd5fe550db41e6fa58a007c74fad400274b128452f38fb8") and
  not (process.name : "wscript.exe" and process.args : "C:\\MININT\\Scripts\\LiteTouch.wsf")
  ]
 [any where event.category : ("registry", "file") and event.action != "deletion" and
   (
    (file.name != null and file.path : "?:\\*\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\*" and
     file.name != "desktop.ini") or
    (registry.data.strings != null and
     registry.path : (
      "H*\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\*",
      "H*\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce\\*",
      "H*\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx\\*",
      "H*\\Software\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Run\\*",
      "H*\\Software\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\RunOnce\\*",
      "H*\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\Run\\*",
      "H*\\Software\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\Run\\*",
      "HKEY_USERS\\*Classes\\*\\InprocServer32\\*",
      "HKEY_USERS\\*Classes\\*\\LocalServer32\\*") and
     not (process.name : "powershell.exe" and registry.path : "H*\\*\\RunOnce\\Update*") and
     not (process.name : "powershell.exe" and file.path : "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp\\KnowledgeLake *.lnk") and
     not registry.data.strings :
                   ("*%ProgramFiles%*",
                    "*:\\Program Files\\*",
                    "*:\\Program Files (x86)\\*",
                    "ctfmon.exe /n", "\"\\\\*",
                    "rundll32.exe C:\\WINDOWS\\system32\\advpack.dll,DelNodeRunDLL32*",
                    "\"C:\\Users\\*\\AppData\\Local\\Microsoft\\OneDrive\\OneDrive.exe\"  /background",
                    "\"C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" -ToastActivated",
                    "Powershell.exe -NoProfile -ExecutionPolicy ByPass -WindowStyle Hidden -file C:\\*\\RunOnce\\Logon.ps1"))
   )
  ]
'''

min_endpoint_version = "7.15.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 = "T1059"
name = "Command and Scripting Interpreter"
reference = "https://attack.mitre.org/techniques/T1059/"
[[threat.technique.subtechnique]]
id = "T1059.001"
name = "PowerShell"
reference = "https://attack.mitre.org/techniques/T1059/001/"

[[threat.technique.subtechnique]]
id = "T1059.005"
name = "Visual Basic"
reference = "https://attack.mitre.org/techniques/T1059/005/"

[[threat.technique.subtechnique]]
id = "T1059.007"
name = "JavaScript"
reference = "https://attack.mitre.org/techniques/T1059/007/"



[threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"
[[threat]]
framework = "MITRE ATT&CK"
[[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/"

[internal]
min_endpoint_version = "7.15.0"

Stages and Predicates

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

Stage 1: process

[process where event.action : "start" and
  (
   process.pe.original_file_name : ("wscript.exe", "powershell.exe", "mshta.exe", "pwsh.exe") or
   process.parent.name : ("wscript.exe", "powershell.exe", "mshta.exe", "pwsh.exe") or
   (process.name : "javaw.exe" and process.args : "-jar" and process.args_count == 3)
   ) and
  not process.Ext.token.integrity_level_name == "system" and
  not (process.command_line : ("*:\\Program Files\\*.exe", "*:\\Program Files (x86)\\*.exe", "*\\\\*\\SYSVOL\\*") and not process.name : "javaw.exe") and
  not process.executable : "?:\\Users\\*\\AppData\\Local\\Microsoft\\OneDrive\\OneDrive.exe" and
  not (process.name : "powershell.exe" and process.command_line : ("*$env:APPDATA*Browser Assistant*", "*MicrosoftEdgeAutoLaunch*GoogleChromeAutoLaunch*")) and
  not (process.pe.original_file_name : "Teams.exe" and process.code_signature.trusted == true) and
  not (process.name : "cscript.exe" and process.args : "?:\\Program Files\\Nextech\\NxTSAddin\\InstallNXTSAddinForCurrentUser.vbs") and
  not (process.parent.name : "powershell.exe" and process.parent.args : "'C:\\ProgramData\\CentraStage\\Packages\\*.ps1'") and
  not process.executable :
                 ("C:\\Program Files (x86)\\Exclaimer Ltd\\Cloud Signature Update Agent\\Exclaimer.CloudSignatureAgent.exe",
                  "C:\\Windows\\System32\\wsl.exe",
                  "C:\\Program Files\\Microsoft OneDrive\\OneDrive.exe",
                  "C:\\Program Files\\Microsoft Office\\root\\Office??\\ONENOTE.EXE",
                  "C:\\Program Files\\WindowsApps\\MSTeams_*\\ms-teams.exe",
                  "C:\\Program Files\\Nextcloud\\nextcloud.exe",
                  "C:\\Program Files\\WindowsApps\\MSTeams_*\\ms-teams.exe") and
  not (process.code_signature.subject_name in ("CrashPlan Group LLC", "Red Hat, Inc", "d7xTech, Inc", "Code42 Software Inc",
       "Galactic Advisors, Inc.", "Hamilton Bonaduz AG", "epostbox epb GmbH", "FastTrack Software ApS", "AnyDesk Software GmbH",
       "Dassault Systemes SolidWorks Corp.") and
       process.code_signature.trusted == true) and
  not process.parent.executable :
                      ("C:\\Program Files (x86)\\BigFix Enterprise\\BES Client\\BESClient.exe",
                       "C:\\Program Files (x86)\\Microsoft Intune Management Extension\\agentexecutor.exe",
                       "C:\\Program Files\\Produce8-Agent\\Produce8-Agent.exe",
                       "C:\\WINDOWS\\_ScriptingFramework\\Modul\\Engine.exe") and
  process.hash.sha256 != null and
  not process.hash.sha256 in ("7b2ba9a849427f8cafac26fe3c522a62287b70dd05de3464e673706a8871552d",
                             "a22895e55b26202eae166838edbe2ea6aad00d7ea600c11f8a31ede5cbce2048",
                             "b924ad8062eaf4e70437c8be50fa612162795ff0839479546ce907ffa8d6e386",
                             "e554425243e3e8ca1cd5fe550db41e6fa58a007c74fad400274b128452f38fb8") and
  not (process.name : "wscript.exe" and process.args : "C:\\MININT\\Scripts\\LiteTouch.wsf")
  ]

Stage 2: any

[any where event.category : ("registry", "file") and event.action != "deletion" and
   (
    (file.name != null and file.path : "?:\\*\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\*" and
     file.name != "desktop.ini") or
    (registry.data.strings != null and
     registry.path : (
      "H*\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\*",
      "H*\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce\\*",
      "H*\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx\\*",
      "H*\\Software\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Run\\*",
      "H*\\Software\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\RunOnce\\*",
      "H*\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\Run\\*",
      "H*\\Software\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\Run\\*",
      "HKEY_USERS\\*Classes\\*\\InprocServer32\\*",
      "HKEY_USERS\\*Classes\\*\\LocalServer32\\*") and
     not (process.name : "powershell.exe" and registry.path : "H*\\*\\RunOnce\\Update*") and
     not (process.name : "powershell.exe" and file.path : "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp\\KnowledgeLake *.lnk") and
     not registry.data.strings :
                   ("*%ProgramFiles%*",
                    "*:\\Program Files\\*",
                    "*:\\Program Files (x86)\\*",
                    "ctfmon.exe /n", "\"\\\\*",
                    "rundll32.exe C:\\WINDOWS\\system32\\advpack.dll,DelNodeRunDLL32*",
                    "\"C:\\Users\\*\\AppData\\Local\\Microsoft\\OneDrive\\OneDrive.exe\"  /background",
                    "\"C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" -ToastActivated",
                    "Powershell.exe -NoProfile -ExecutionPolicy ByPass -WindowStyle Hidden -file C:\\*\\RunOnce\\Logon.ps1"))
   )
  ]

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.nameeqjavaw.exeexcludes:process.name field:"process.name" value:"javaw.exe"
process.command_linewildcard*:\Program Files\*.exe, *:\Program Files (x86)\*.exe, *\\*\SYSVOL\*excludes:process.command_line field:"process.command_line" value:"*:\Program Files\*.exe" field:"process.command_line" value:"*:\Program Files (x86)\*.exe" field:"process.command_line" value:"*\\*\SYSVOL\*"
process.argseq?:\Program Files\Nextech\NxTSAddin\InstallNXTSAddinForCurrentUser.vbsexcludes:process.args field:"process.args" value:"?:\Program Files\Nextech\NxTSAddin\InstallNXTSAddinForCurrentUser.vbs"
process.nameeqcscript.exeexcludes:process.name field:"process.name" value:"cscript.exe"
process.argseqC:\MININT\Scripts\LiteTouch.wsfexcludes:process.args field:"process.args" value:"C:\MININT\Scripts\LiteTouch.wsf"
process.nameeqwscript.exeexcludes:process.name field:"process.name" value:"wscript.exe"
process.code_signature.subject_nameinAnyDesk Software GmbH, Code42 Software Inc, CrashPlan Group LLC, Dassault Systemes SolidWorks Corp., FastTrack Software ApS, Galactic Advisors, Inc., Hamilton Bonaduz AG, Red Hat, Inc, d7xTech, Inc, epostbox epb GmbHexcludes:process.code_signature.subject_name
process.code_signature.trustedeqtrueexcludes:process.code_signature.trusted field:"process.code_signature.trusted" value:"true"
process.pe.original_file_nameeqTeams.exeexcludes:process.pe.original_file_name field:"process.pe.original_file_name" value:"Teams.exe"
process.command_linewildcard*$env:APPDATA*Browser Assistant*, *MicrosoftEdgeAutoLaunch*GoogleChromeAutoLaunch*excludes:process.command_line field:"process.command_line" value:"*$env:APPDATA*Browser Assistant*" field:"process.command_line" value:"*MicrosoftEdgeAutoLaunch*GoogleChromeAutoLaunch*"
process.nameeqpowershell.exeexcludes:process.name field:"process.name" value:"powershell.exe"
process.parent.argswildcard'C:\ProgramData\CentraStage\Packages\*.ps1'excludes:process.parent.args field:"process.parent.args" value:"'C:\ProgramData\CentraStage\Packages\*.ps1'"
process.parent.nameeqpowershell.exeexcludes:process.parent.name field:"process.parent.name" value:"powershell.exe"
process.Ext.token.integrity_level_nameeqsystemexcludes:process.Ext.token.integrity_level_name field:"process.Ext.token.integrity_level_name" value:"system"
process.executablewildcard?:\Users\*\AppData\Local\Microsoft\OneDrive\OneDrive.exeexcludes:process.executable field:"process.executable" value:"?:\Users\*\AppData\Local\Microsoft\OneDrive\OneDrive.exe"
process.executablewildcardC:\Program Files (x86)\Exclaimer Ltd\Cloud Signature Update Agent\Exclaimer.CloudSignatureAgent.exe, C:\Windows\System32\wsl.exe, C:\Program Files\Microsoft OneDrive\OneDrive.exe, C:\Program Files\Microsoft Office\root\Office??\ONENOTE.EXE, C:\Program Files\WindowsApps\MSTeams_*\ms-teams.exe, C:\Program Files\Nextcloud\nextcloud.exe, C:\Program Files\WindowsApps\MSTeams_*\ms-teams.exeexcludes:process.executable
process.hash.sha256in7b2ba9a849427f8cafac26fe3c522a62287b70dd05de3464e673706a8871552d, a22895e55b26202eae166838edbe2ea6aad00d7ea600c11f8a31ede5cbce2048, b924ad8062eaf4e70437c8be50fa612162795ff0839479546ce907ffa8d6e386, e554425243e3e8ca1cd5fe550db41e6fa58a007c74fad400274b128452f38fb8excludes:process.hash.sha256
process.parent.executableeqC:\Program Files (x86)\BigFix Enterprise\BES Client\BESClient.exe, C:\Program Files (x86)\Microsoft Intune Management Extension\agentexecutor.exe, C:\Program Files\Produce8-Agent\Produce8-Agent.exe, C:\WINDOWS\_ScriptingFramework\Modul\Engine.exeexcludes:process.parent.executable

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actionne
  • deletion corpus 86 (elastic 86)
field:"EventType" kind:ne value:"deletion"
event.actionwildcard
  • start corpus 391 (elastic 391)
field:"EventType" kind:wildcard value:"start"
event.categorywildcard
  • file corpus 43 (elastic 43)
  • registry corpus 14 (elastic 14)
field:"event.category" kind:wildcard
file.nameis_not_null
  • (no value, null check)
field:"file.name" kind:is_not_null
file.namene
  • desktop.ini
field:"file.name" kind:ne value:"desktop.ini"
file.pathwildcard
  • ?:\*\Microsoft\Windows\Start Menu\Programs\Startup\* corpus 9 (elastic 9)
field:"TargetFilename" kind:wildcard value:"?:\*\Microsoft\Windows\Start Menu\Programs\Startup\*"
process.argswildcard
  • -jar corpus 8 (elastic 8)
field:"process.args" kind:wildcard value:"-jar"
process.args_counteq
  • 3 transforms: number corpus 22 (elastic 22)
field:"process.args_count" kind:eq value:"3"
process.hash.sha256is_not_null
  • (no value, null check)
field:"Hashes" kind:is_not_null
process.namewildcard
  • javaw.exe corpus 9 (elastic 9)
field:"process_name" kind:wildcard value:"javaw.exe"
process.parent.namewildcard
  • mshta.exe corpus 24 (elastic 22, splunk 2)
  • powershell.exe corpus 39 (elastic 36, kusto 2, splunk 1)
  • pwsh.exe corpus 5 (elastic 5)
  • wscript.exe corpus 24 (elastic 23, splunk 1)
field:"parent_process_name" kind:wildcard
process.pe.original_file_namewildcard
  • mshta.exe corpus 40 (elastic 21, sigma 13, splunk 6)
  • powershell.exe corpus 138 (sigma 84, splunk 30, elastic 24)
  • pwsh.exe corpus 7 (elastic 7)
  • wscript.exe corpus 38 (elastic 21, sigma 17)
field:"OriginalFileName" 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\RunOnceEx\*
  • H*\Software\Microsoft\Windows\CurrentVersion\RunOnce\* corpus 2 (elastic 2)
  • 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\RunOnce\*
  • H*\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Run\* corpus 11 (elastic 11)
  • HKEY_USERS\*Classes\*\InprocServer32\* corpus 2 (elastic 2)
  • HKEY_USERS\*Classes\*\LocalServer32\*
field:"TargetObject" kind:wildcard