Detection rules › Elastic

Startup Persistence from Backed RWX Memory

Source
github.com/elastic/protections-artifacts

Identifies when a process is writing to commonly abused persistence locations (registry run keys and startup folder) from a thread running from a memory section with read, write and execute permissions. This may indicate an attempt to persist from a packed or injected program.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies when a process is writing to commonly abused persistence locations (registry run keys and startup folder)
from a thread running from a memory section with read, write and execute permissions. This may indicate an attempt to
persist from a packed or injected program.
"""
id = "15c48f2d-e461-40a9-accd-090a0863ea10"
license = "Elastic License v2"
name = "Startup Persistence from Backed RWX Memory"
os_list = ["windows"]
version = "1.0.14"

query = '''
any where event.category in ("registry", "file") and process.executable != null and
 not event.action in ("deletion", "query") and process.thread.Ext.call_stack_summary like "?*" and
 not process.code_signature.status like ("trusted", "errorExpired", "errorCode_endpoint*") and
 not process.thread.Ext.call_stack_summary like ("*Unbacked*", "*clr.dll*", "*Unknown*", "*|kernelbase.dll|irsetup.exe*", 
                                              "*issetup.dll|isrt.dll*", "*adobepim.dll|set-up.dat*") and
 _arraysearch(process.thread.Ext.call_stack, $entry, $entry.protection : "RWX") and
   (
    (registry.data.strings != null 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\\*")) or
    (file.name != null and file.path : "?:\\*\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\*")
   ) and
   not (process.executable : "?:\\Windows\\Sys*\\msiexec.exe" and
       _arraysearch(process.thread.Ext.call_stack, $entry,
	                $entry.protection : "RWX" and $entry.symbol_info : ("?:\\Windows\\Temp\\*", "?:\\Windows\\Installer\\*"))) and 
   not _arraysearch(process.thread.Ext.call_stack, $entry,
	                $entry.protection : "RWX" and
	                $entry.symbol_info : ("?:\\Windows\\Installer\\*",
	                                      "?:\\Users\\*\\AppData\\Local\\Temp\\*\\isrt.dll!_RegSetKeyValue+*",
	                                      "?:\\Users\\*\\AppData\\Local\\Temp\\{*}\\ISSetup.dll!InstallEngineTypelib*",
	                                      "?:\\Program Files (x86)\\Gizmo\\gdrive.dll!Remount_Startup_Images*")) and
   not registry.data.strings : ("?:\\windows\\Twain_32\\fjscan32\\FjtwMkup.exe /Station", "\"C:\\Users\\*\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Webex\\Webex.lnk\" /minimized /autostartedWithWindows=true") and
   not (process.executable :  "?:\\Windows\\SysWOW64\\DWRCS.EXE" and registry.data.strings : "?:\\WINDOWS\\SysWOW64\\DWRCST.exe") and
   not process.executable : ("?:\\Program Files (x86)\\*.exe", "?:\\Program Files\\*.exe")
'''

min_endpoint_version = "8.7.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 = "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 = "8.7.0"

Stages and Predicates

Stage 1: any

any where event.category in ("registry", "file") and process.executable != null and
 not event.action in ("deletion", "query") and process.thread.Ext.call_stack_summary like "?*" and
 not process.code_signature.status like ("trusted", "errorExpired", "errorCode_endpoint*") and
 not process.thread.Ext.call_stack_summary like ("*Unbacked*", "*clr.dll*", "*Unknown*", "*|kernelbase.dll|irsetup.exe*", 
                                              "*issetup.dll|isrt.dll*", "*adobepim.dll|set-up.dat*") and
 _arraysearch(process.thread.Ext.call_stack, $entry, $entry.protection : "RWX") and
   (
    (registry.data.strings != null 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\\*")) or
    (file.name != null and file.path : "?:\\*\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\*")
   ) and
   not (process.executable : "?:\\Windows\\Sys*\\msiexec.exe" and
       _arraysearch(process.thread.Ext.call_stack, $entry,
	                $entry.protection : "RWX" and $entry.symbol_info : ("?:\\Windows\\Temp\\*", "?:\\Windows\\Installer\\*"))) and 
   not _arraysearch(process.thread.Ext.call_stack, $entry,
	                $entry.protection : "RWX" and
	                $entry.symbol_info : ("?:\\Windows\\Installer\\*",
	                                      "?:\\Users\\*\\AppData\\Local\\Temp\\*\\isrt.dll!_RegSetKeyValue+*",
	                                      "?:\\Users\\*\\AppData\\Local\\Temp\\{*}\\ISSetup.dll!InstallEngineTypelib*",
	                                      "?:\\Program Files (x86)\\Gizmo\\gdrive.dll!Remount_Startup_Images*")) and
   not registry.data.strings : ("?:\\windows\\Twain_32\\fjscan32\\FjtwMkup.exe /Station", "\"C:\\Users\\*\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Webex\\Webex.lnk\" /minimized /autostartedWithWindows=true") and
   not (process.executable :  "?:\\Windows\\SysWOW64\\DWRCS.EXE" and registry.data.strings : "?:\\WINDOWS\\SysWOW64\\DWRCST.exe") and
   not process.executable : ("?:\\Program Files (x86)\\*.exe", "?:\\Program Files\\*.exe")

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.thread.Ext.call_stackarray_any(no value, null check)excludes:process.thread.Ext.call_stack
process.executablewildcard?:\Windows\Sys*\msiexec.exeexcludes:process.executable field:"process.executable" value:"?:\Windows\Sys*\msiexec.exe"
process.executableeq?:\Windows\SysWOW64\DWRCS.EXEexcludes:process.executable field:"process.executable" value:"?:\Windows\SysWOW64\DWRCS.EXE"
registry.data.stringseq?:\WINDOWS\SysWOW64\DWRCST.exeexcludes:registry.data.strings field:"registry.data.strings" value:"?:\WINDOWS\SysWOW64\DWRCST.exe"
event.actionindeletion, queryexcludes:event.action field:"event.action" value:"deletion" field:"event.action" value:"query"
process.code_signature.statuswildcardtrusted, errorExpired, errorCode_endpoint*excludes:process.code_signature.status field:"process.code_signature.status" value:"trusted" field:"process.code_signature.status" value:"errorExpired" field:"process.code_signature.status" value:"errorCode_endpoint*"
process.executablewildcard?:\Program Files (x86)\*.exe, ?:\Program Files\*.exeexcludes:process.executable field:"process.executable" value:"?:\Program Files (x86)\*.exe" field:"process.executable" value:"?:\Program Files\*.exe"
process.thread.Ext.call_stack_summarymatchUnbacked, clr.dll, Unknown, |kernelbase.dll|irsetup.exe, issetup.dll|isrt.dll, adobepim.dll|set-up.datexcludes:process.thread.Ext.call_stack_summary
registry.data.stringswildcard?:\windows\Twain_32\fjscan32\FjtwMkup.exe /Station, "C:\Users\*\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Webex\Webex.lnk" /minimized /autostartedWithWindows=trueexcludes:registry.data.strings

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
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)
field:"TargetFilename" kind:wildcard value:"?:\*\Microsoft\Windows\Start Menu\Programs\Startup\*"
process.executableis_not_null
  • (no value, null check)
field:"Image" kind:is_not_null
process.thread.Ext.call_stack_summarywildcard
  • ?* corpus 14 (elastic 14)
field:"process.thread.Ext.call_stack_summary" kind:wildcard value:"?*"
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)
field:"TargetObject" kind:wildcard