Detection rules › Elastic
Startup Persistence via Windows Script Interpreter
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.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.name | eq | javaw.exe | excludes:process.name field:"process.name" value:"javaw.exe" |
process.command_line | wildcard | *:\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.args | eq | ?:\Program Files\Nextech\NxTSAddin\InstallNXTSAddinForCurrentUser.vbs | excludes:process.args field:"process.args" value:"?:\Program Files\Nextech\NxTSAddin\InstallNXTSAddinForCurrentUser.vbs" |
process.name | eq | cscript.exe | excludes:process.name field:"process.name" value:"cscript.exe" |
process.args | eq | C:\MININT\Scripts\LiteTouch.wsf | excludes:process.args field:"process.args" value:"C:\MININT\Scripts\LiteTouch.wsf" |
process.name | eq | wscript.exe | excludes:process.name field:"process.name" value:"wscript.exe" |
process.code_signature.subject_name | in | AnyDesk 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 GmbH | excludes:process.code_signature.subject_name |
process.code_signature.trusted | eq | true | excludes:process.code_signature.trusted field:"process.code_signature.trusted" value:"true" |
process.pe.original_file_name | eq | Teams.exe | excludes:process.pe.original_file_name field:"process.pe.original_file_name" value:"Teams.exe" |
process.command_line | wildcard | *$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.name | eq | powershell.exe | excludes:process.name field:"process.name" value:"powershell.exe" |
process.parent.args | wildcard | 'C:\ProgramData\CentraStage\Packages\*.ps1' | excludes:process.parent.args field:"process.parent.args" value:"'C:\ProgramData\CentraStage\Packages\*.ps1'" |
process.parent.name | eq | powershell.exe | excludes:process.parent.name field:"process.parent.name" value:"powershell.exe" |
process.Ext.token.integrity_level_name | eq | system | excludes:process.Ext.token.integrity_level_name field:"process.Ext.token.integrity_level_name" value:"system" |
process.executable | wildcard | ?:\Users\*\AppData\Local\Microsoft\OneDrive\OneDrive.exe | excludes:process.executable field:"process.executable" value:"?:\Users\*\AppData\Local\Microsoft\OneDrive\OneDrive.exe" |
process.executable | wildcard | 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 | excludes:process.executable |
process.hash.sha256 | in | 7b2ba9a849427f8cafac26fe3c522a62287b70dd05de3464e673706a8871552d, a22895e55b26202eae166838edbe2ea6aad00d7ea600c11f8a31ede5cbce2048, b924ad8062eaf4e70437c8be50fa612162795ff0839479546ce907ffa8d6e386, e554425243e3e8ca1cd5fe550db41e6fa58a007c74fad400274b128452f38fb8 | excludes:process.hash.sha256 |
process.parent.executable | eq | 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 | excludes:process.parent.executable |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
event.action | ne |
| field:"EventType" kind:ne value:"deletion" |
event.action | wildcard |
| field:"EventType" kind:wildcard value:"start" |
event.category | wildcard |
| field:"event.category" kind:wildcard |
file.name | is_not_null | field:"file.name" kind:is_not_null | |
file.name | ne |
| field:"file.name" kind:ne value:"desktop.ini" |
file.path | wildcard |
| field:"TargetFilename" kind:wildcard value:"?:\*\Microsoft\Windows\Start Menu\Programs\Startup\*" |
process.args | wildcard |
| field:"process.args" kind:wildcard value:"-jar" |
process.args_count | eq |
| field:"process.args_count" kind:eq value:"3" |
process.hash.sha256 | is_not_null | field:"Hashes" kind:is_not_null | |
process.name | wildcard |
| field:"process_name" kind:wildcard value:"javaw.exe" |
process.parent.name | wildcard |
| field:"parent_process_name" kind:wildcard |
process.pe.original_file_name | wildcard |
| field:"OriginalFileName" kind:wildcard |
registry.data.strings | is_not_null | field:"Details" kind:is_not_null | |
registry.path | wildcard |
| field:"TargetObject" kind:wildcard |