Detection rules › Elastic

Registry or File Modification from Suspicious Memory

Source
github.com/elastic/protections-artifacts

Identifies the modification of file or registry to set persistence or evade defense and from a call stack pointing to an unbacked memory region or Microsoft Visual Basics DLLs. Adversaries may use this technique to maintain persistence or evade defense from an injected process.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies the modification of file or registry to set persistence or evade defense and from a call stack pointing to an
unbacked memory region or Microsoft Visual Basics DLLs. Adversaries may use this technique to maintain persistence or
evade defense from an injected process.
"""
id = "280557d4-403b-49e5-a4eb-e043a6ae7674"
license = "Elastic License v2"
name = "Registry or File Modification from Suspicious Memory"
os_list = ["windows"]
reference = [
    "https://docs.microsoft.com/en-us/previous-versions/technet-magazine/ee851671(v=msdn.10)",
    "https://www.elastic.co/security-labs/upping-the-ante-detecting-in-memory-threats-with-kernel-call-stacks",
]
version = "1.0.21"

query = '''
any where event.category in ("registry", "file") and event.action != "deletion" and 
 file.name != null and registry.data.strings != null and 
 process.thread.Ext.call_stack_summary like ("*|vbe?.dll*", "*kernelbase.dll|Unbacked*") 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\\*", 
		 "H*\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Runonce\\*",
		 "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",
		 "HKEY_USERS\\*\\Environment\\UserInitMprLogonScript",
		 "HKEY_USERS\\*Classes\\*\\InprocServer32\\*",
		 "HKEY_USERS\\*Classes\\*\\DelegateExecute\\*",
		 "HKEY_USERS\\*Classes\\*\\TreatAs\\*",
		 "HKEY_USERS\\*Classes\\CLSID\\*\\ScriptletURL\\*",
		 "HKLM\\SYSTEM\\*ControlSet*\\Services\\*\\Parameters\\ServiceDll",
		 "HKLM\\SYSTEM\\ControlSet*\\Services\\*\\ImagePath",

		 "HK*\\S-1-5-21-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\AccessVBOM",
		 "HK*\\S-1-5-21-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\VbaWarnings",
		 "HK*\\S-1-12-1-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\AccessVBOM",
		 "HK*\\S-1-12-1-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\VbaWarnings",
		 "HKEY_USERS\\*\\Software\\Microsoft\\Windows Script\\Settings\\AmsiEnable",
		 "HK*\\*\\Software\\Microsoft\\Windows Script\\Settings\\AmsiEnable",
		 "HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\\ConsentPromptBehaviorAdmin",
		 "HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\\EnableLUA")) or

    (file.name != null and file.path : "?:\\*\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\*" and
     not file.name : "desktop.ini")
   ) and

   not (process.code_signature.trusted == true and registry.value : "com.squirrel.*" and
        registry.data.strings : "*--process-start-args*" and
        registry.path : "H*\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\*") and

   not (process.executable : ("?:\\Program Files\\*", "?:\\Program Files (x86)\\*") and
        process.code_signature.trusted == true and process.thread.Ext.call_stack_summary like "*|mscorlib.ni.dll|*") and

   not process.thread.Ext.call_stack_summary like "*Unbacked|clr.dll|*" and

   not (process.code_signature.trusted == true and
        process.code_signature.subject_name : ("Autodesk, Inc.", "SimpleHelp Ltd", "Kaspersky Lab*", "JetBrains s.r.o.",
                                               "IDrive, Inc.", "RingCentral, Inc.", "Plarium Global LTD", "Sanford, L.P.",
                                               "CutCom Software Inc.", "Bluestack Systems, Inc")) and

   /* Third party signed software from program files */
   not (process.code_signature.trusted == true and
        not process.code_signature.subject_name like "Microsoft*" and
        process.executable : ("?:\\Program Files\\*.exe", "?:\\Program Files (x86)\\*.exe")) and

   not process.executable :
               ("?:\\Program Files\\OpenVPN Connect\\OpenVPNConnect.exe",
                "?:\\Program Files (x86)\\OpenVPN Connect\\OpenVPNConnect.exe",
                "?:\\Program Files\\DYMO\\DYMO Label Software\\DYMO.DLS.Printing.Host.exe",
                "?:\\Program Files (x86)\\DYMO\\DYMO Label Software\\DYMO.DLS.Printing.Host.exe",
                "?:\\Program Files\\Microsoft Visual Studio\\Installer.*\\setup.exe",
                "?:\\Program Files (x86)\\Microsoft Visual Studio\\Installer.*\\setup.exe")
'''

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

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

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1543"
name = "Create or Modify System Process"
reference = "https://attack.mitre.org/techniques/T1543/"
[[threat.technique.subtechnique]]
id = "T1543.003"
name = "Windows Service"
reference = "https://attack.mitre.org/techniques/T1543/003/"


[[threat.technique]]
id = "T1546"
name = "Event Triggered Execution"
reference = "https://attack.mitre.org/techniques/T1546/"
[[threat.technique.subtechnique]]
id = "T1546.015"
name = "Component Object Model Hijacking"
reference = "https://attack.mitre.org/techniques/T1546/015/"


[[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 = "T1055"
name = "Process Injection"
reference = "https://attack.mitre.org/techniques/T1055/"

[[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.8.0"

Stages and Predicates

Stage 1: any

any where event.category in ("registry", "file") and event.action != "deletion" and
 file.name != null and registry.data.strings != null and
 process.thread.Ext.call_stack_summary like ("*|vbe?.dll*", "*kernelbase.dll|Unbacked*") 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\\*",
		 "H*\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Runonce\\*",
		 "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",
		 "HKEY_USERS\\*\\Environment\\UserInitMprLogonScript",
		 "HKEY_USERS\\*Classes\\*\\InprocServer32\\*",
		 "HKEY_USERS\\*Classes\\*\\DelegateExecute\\*",
		 "HKEY_USERS\\*Classes\\*\\TreatAs\\*",
		 "HKEY_USERS\\*Classes\\CLSID\\*\\ScriptletURL\\*",
		 "HKLM\\SYSTEM\\*ControlSet*\\Services\\*\\Parameters\\ServiceDll",
		 "HKLM\\SYSTEM\\ControlSet*\\Services\\*\\ImagePath",
		 "HK*\\S-1-5-21-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\AccessVBOM",
		 "HK*\\S-1-5-21-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\VbaWarnings",
		 "HK*\\S-1-12-1-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\AccessVBOM",
		 "HK*\\S-1-12-1-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\VbaWarnings",
		 "HKEY_USERS\\*\\Software\\Microsoft\\Windows Script\\Settings\\AmsiEnable",
		 "HK*\\*\\Software\\Microsoft\\Windows Script\\Settings\\AmsiEnable",
		 "HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\\ConsentPromptBehaviorAdmin",
		 "HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\\EnableLUA")) or
    (file.name != null and file.path : "?:\\*\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\*" and
     not file.name : "desktop.ini")
   ) and
   not (process.code_signature.trusted == true and registry.value : "com.squirrel.*" and
        registry.data.strings : "*--process-start-args*" and
        registry.path : "H*\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\*") and
   not (process.executable : ("?:\\Program Files\\*", "?:\\Program Files (x86)\\*") and
        process.code_signature.trusted == true and process.thread.Ext.call_stack_summary like "*|mscorlib.ni.dll|*") and
   not process.thread.Ext.call_stack_summary like "*Unbacked|clr.dll|*" and
   not (process.code_signature.trusted == true and
        process.code_signature.subject_name : ("Autodesk, Inc.", "SimpleHelp Ltd", "Kaspersky Lab*", "JetBrains s.r.o.",
                                               "IDrive, Inc.", "RingCentral, Inc.", "Plarium Global LTD", "Sanford, L.P.",
                                               "CutCom Software Inc.", "Bluestack Systems, Inc")) and
   not (process.code_signature.trusted == true and
        not process.code_signature.subject_name like "Microsoft*" and
        process.executable : ("?:\\Program Files\\*.exe", "?:\\Program Files (x86)\\*.exe")) and
   not process.executable :
               ("?:\\Program Files\\OpenVPN Connect\\OpenVPNConnect.exe",
                "?:\\Program Files (x86)\\OpenVPN Connect\\OpenVPNConnect.exe",
                "?:\\Program Files\\DYMO\\DYMO Label Software\\DYMO.DLS.Printing.Host.exe",
                "?:\\Program Files (x86)\\DYMO\\DYMO Label Software\\DYMO.DLS.Printing.Host.exe",
                "?:\\Program Files\\Microsoft Visual Studio\\Installer.*\\setup.exe",
                "?:\\Program Files (x86)\\Microsoft Visual Studio\\Installer.*\\setup.exe")

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.code_signature.subject_namestarts_withMicrosoftexcludes:process.code_signature.subject_name field:"process.code_signature.subject_name" value:"Microsoft"
process.code_signature.trustedeqtrueexcludes:process.code_signature.trusted field:"process.code_signature.trusted" value:"true"
process.executablewildcard?:\Program Files\*.exe, ?:\Program Files (x86)\*.exeexcludes:process.executable field:"process.executable" value:"?:\Program Files\*.exe" field:"process.executable" value:"?:\Program Files (x86)\*.exe"
process.code_signature.subject_namewildcardAutodesk, Inc., SimpleHelp Ltd, Kaspersky Lab*, JetBrains s.r.o., IDrive, Inc., RingCentral, Inc., Plarium Global LTD, Sanford, L.P., CutCom Software Inc., Bluestack Systems, Incexcludes:process.code_signature.subject_name
process.executablestarts_with?:\Program Files\, ?:\Program Files (x86)\excludes:process.executable field:"process.executable" value:"?:\Program Files\" field:"process.executable" value:"?:\Program Files (x86)\"
process.thread.Ext.call_stack_summarymatch|mscorlib.ni.dll|excludes:process.thread.Ext.call_stack_summary field:"process.thread.Ext.call_stack_summary" value:"|mscorlib.ni.dll|"
registry.data.stringsmatch--process-start-argsexcludes:registry.data.strings field:"registry.data.strings" value:"--process-start-args"
registry.pathwildcardH*\Software\Microsoft\Windows\CurrentVersion\Run\*excludes:registry.path field:"registry.path" value:"H*\Software\Microsoft\Windows\CurrentVersion\Run\*"
registry.valuestarts_withcom.squirrel.excludes:registry.value field:"registry.value" value:"com.squirrel."
process.executablewildcard?:\Program Files\OpenVPN Connect\OpenVPNConnect.exe, ?:\Program Files (x86)\OpenVPN Connect\OpenVPNConnect.exe, ?:\Program Files\DYMO\DYMO Label Software\DYMO.DLS.Printing.Host.exe, ?:\Program Files (x86)\DYMO\DYMO Label Software\DYMO.DLS.Printing.Host.exe, ?:\Program Files\Microsoft Visual Studio\Installer.*\setup.exe, ?:\Program Files (x86)\Microsoft Visual Studio\Installer.*\setup.exeexcludes:process.executable
process.thread.Ext.call_stack_summarymatchUnbacked|clr.dll|excludes:process.thread.Ext.call_stack_summary field:"process.thread.Ext.call_stack_summary" value:"Unbacked|clr.dll|"

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)
field:"TargetFilename" kind:wildcard value:"?:\*\Microsoft\Windows\Start Menu\Programs\Startup\*"
process.code_signature.subject_namewildcard
  • Microsoft* corpus 22 (elastic 22)
field:"Signature" kind:wildcard value:"Microsoft*"
process.thread.Ext.call_stack_summarywildcard
  • *kernelbase.dll|Unbacked*
  • *|vbe?.dll* corpus 4 (elastic 4)
field:"process.thread.Ext.call_stack_summary" kind:wildcard
registry.data.stringsis_not_null
  • (no value, null check)
field:"Details" kind:is_not_null
registry.pathwildcard
  • H*\SOFTWARE\Microsoft\Windows\CurrentVersion\Runonce\* corpus 2 (elastic 2)
  • 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)
  • HK*\*\Software\Microsoft\Windows Script\Settings\AmsiEnable corpus 2 (elastic 2)
  • HK*\S-1-12-1-*\SOFTWARE\Microsoft\Office\*\Security\AccessVBOM corpus 2 (elastic 2)
  • HK*\S-1-12-1-*\SOFTWARE\Microsoft\Office\*\Security\VbaWarnings corpus 2 (elastic 2)
  • HK*\S-1-5-21-*\SOFTWARE\Microsoft\Office\*\Security\AccessVBOM corpus 2 (elastic 2)
  • HK*\S-1-5-21-*\SOFTWARE\Microsoft\Office\*\Security\VbaWarnings corpus 2 (elastic 2)
  • HKEY_USERS\*Classes\*\DelegateExecute\*
  • HKEY_USERS\*Classes\*\InprocServer32\* corpus 2 (elastic 2)
  • HKEY_USERS\*Classes\*\TreatAs\*
  • HKEY_USERS\*Classes\CLSID\*\ScriptletURL\*
  • 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)
  • HKEY_USERS\*\Software\Microsoft\Windows Script\Settings\AmsiEnable corpus 2 (elastic 2)
  • HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell
  • HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit
  • HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\ConsentPromptBehaviorAdmin
  • HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA
  • HKLM\SYSTEM\*ControlSet*\Services\*\Parameters\ServiceDll
  • HKLM\SYSTEM\ControlSet*\Services\*\ImagePath corpus 4 (elastic 4)
field:"TargetObject" kind:wildcard