Detection rules › Elastic

Shellcode from Unusual Microsoft Signed Module

Source
github.com/elastic/protections-artifacts

Identifies attempts to allocate or execute shellcode from unbacked memory and where the protection provenance of the unbacked region is coming from an unusual signed Microsoft module.

MITRE ATT&CK coverage

TacticTechniques
Stealth

Rule body

[rule]
description = """
Identifies attempts to allocate or execute shellcode from unbacked memory and where the protection provenance of the
unbacked region is coming from an unusual signed Microsoft module.
"""
id = "abbb1618-6eae-459e-949d-bf628aa0abd4"
license = "Elastic License v2"
name = "Shellcode from Unusual Microsoft Signed Module"
os_list = ["windows"]
version = "1.0.7"

query = '''
api where
    process.executable != null and process.parent.executable != null and
    process.Ext.api.behaviors in ("shellcode", "allocate_shellcode", "execute_shellcode") and
    process.Ext.api.name in ("VirtualAlloc", "VirtualProtect", "WriteProcessMemory", "VirtualProtectEx", "VirtualAllocEx",
                             "MapViewOfFile", "MapViewOfFile2", "SetThreadContext", "SuspendThread", "ReadProcessMemory", "connect") and
    process.thread.Ext.call_stack_final_user_module.name == "Unbacked" and
    process.thread.Ext.call_stack_final_user_module.protection_provenance_path != null and
    _arraysearch(process.thread.Ext.call_stack_final_user_module.code_signature, $entry,
                 $entry.trusted == true and $entry.subject_name in ("Microsoft Corporation", "Microsoft Windows")) and
    process.thread.Ext.call_stack_summary :
                        ("ntdll.dll|Unbacked",
                         "ntdll.dll|kernelbase.dll|Unbacked",
                         "ntdll.dll|kernelbase.dll|kernel32.dll|Unbacked",
                         "ntdll.dll|wow64.dll|wow64cpu.dll|wow64.dll|ntdll.dll|Unbacked",
                         "ntdll.dll|wow64.dll|wow64cpu.dll|wow64.dll|ntdll.dll|kernelbase.dll|Unbacked",
                         "ntdll.dll|wow64.dll|wow64cpu.dll|wow64.dll|ntdll.dll|Unbacked|kernel32.dll|ntdll.dll",
                         "ntdll.dll|wow64.dll|wow64cpu.dll|wow64.dll|ntdll.dll|kernelbase.dll|Unbacked|kernel32.dll|ntdll.dll",
                         "ntdll.dll|mswsock.dll|ws2_32.dll|Unbacked",
                         "wow64cpu.dll|wow64.dll|ntdll.dll|mswsock.dll|ws2_32.dll|Unbacked|kernel32.dll|ntdll.dll") and
    process.thread.Ext.call_stack_final_user_module.protection_provenance_path like "c:\\windows\\system32\\*" and

    not (process.executable : "C:\\Program Files\\Dell\\DTP\\InstrumentationSubAgent\\Dell.TechHub.Instrumentation.SubAgent.exe" and 
         process.parent.executable : "C:\\Program Files\\Dell\\TechHub\\Dell.TechHub.exe" and 
         process.code_signature.subject_name == "Dell Technologies Inc." and process.code_signature.trusted == true) and

    not (process.parent.executable : "C:\\Program Files (x86)\\ScreenConnect Client*\\ScreenConnect.ClientService.exe" and
        process.executable : "C:\\Program Files (x86)\\ScreenConnect Client (*)\\ScreenConnect.WindowsClient.exe" and
        process.code_signature.subject_name == "ConnectWise, LLC" and process.code_signature.trusted == true) and

    not (process.name == "powershell.exe" and user.id == "S-1-5-18" and
         process.parent.executable : "C:\\Program Files (x86)\\Quest\\KACE\\KInventory.exe") and

    not process.thread.Ext.call_stack_final_user_module.protection_provenance : ("cyvrtrap.dll", "bass.dll") and

    not (process.executable : "C:\\Windows\\System32\\PrintIsolationHost.exe" and
         process.thread.Ext.call_stack_final_user_module.protection_provenance_path like "c:\\windows\\system32\\msvcr100.dll") and

    not (process.executable : "C:\\Windows\\System32\\inetsrv\\w3wp.exe" and process.parent.executable : "C:\\Windows\\System32\\svchost.exe" and 
         _arraysearch(process.thread.Ext.call_stack, $entry, 
                      $entry.callsite_trailing_bytes : ("41c644240c01*488b558849895424104883c4785b5e5f415c415d415e415f5dc3*", 
                                                        "41c6470c01833*488bc6488b5590498957104883c4685b5e5f415c415*",
                                                        "*85f60f95c00fb6c00fb6c041c6470c01488b558849895710488d65c85b5e5f415c415d415e*"))) and

    not (process.parent.executable : "C:\\Program Files\\ATERA Networks\\AteraAgent\\Agent\\AteraAgent.exe" and
         process.executable : "C:\\Program Files\\ATERA Networks\\AteraAgent\\Agent\\packages\\AgentPackageMonitoring\\AgentPackageMonitoring.exe")
'''

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


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

[internal]
min_endpoint_version = "8.14.2"

Stages and Predicates

Stage 1: api

api where
    process.executable != null and process.parent.executable != null and
    process.Ext.api.behaviors in ("shellcode", "allocate_shellcode", "execute_shellcode") and
    process.Ext.api.name in ("VirtualAlloc", "VirtualProtect", "WriteProcessMemory", "VirtualProtectEx", "VirtualAllocEx",
                             "MapViewOfFile", "MapViewOfFile2", "SetThreadContext", "SuspendThread", "ReadProcessMemory", "connect") and
    process.thread.Ext.call_stack_final_user_module.name == "Unbacked" and
    process.thread.Ext.call_stack_final_user_module.protection_provenance_path != null and
    _arraysearch(process.thread.Ext.call_stack_final_user_module.code_signature, $entry,
                 $entry.trusted == true and $entry.subject_name in ("Microsoft Corporation", "Microsoft Windows")) and
    process.thread.Ext.call_stack_summary :
                        ("ntdll.dll|Unbacked",
                         "ntdll.dll|kernelbase.dll|Unbacked",
                         "ntdll.dll|kernelbase.dll|kernel32.dll|Unbacked",
                         "ntdll.dll|wow64.dll|wow64cpu.dll|wow64.dll|ntdll.dll|Unbacked",
                         "ntdll.dll|wow64.dll|wow64cpu.dll|wow64.dll|ntdll.dll|kernelbase.dll|Unbacked",
                         "ntdll.dll|wow64.dll|wow64cpu.dll|wow64.dll|ntdll.dll|Unbacked|kernel32.dll|ntdll.dll",
                         "ntdll.dll|wow64.dll|wow64cpu.dll|wow64.dll|ntdll.dll|kernelbase.dll|Unbacked|kernel32.dll|ntdll.dll",
                         "ntdll.dll|mswsock.dll|ws2_32.dll|Unbacked",
                         "wow64cpu.dll|wow64.dll|ntdll.dll|mswsock.dll|ws2_32.dll|Unbacked|kernel32.dll|ntdll.dll") and
    process.thread.Ext.call_stack_final_user_module.protection_provenance_path like "c:\\windows\\system32\\*" and

    not (process.executable : "C:\\Program Files\\Dell\\DTP\\InstrumentationSubAgent\\Dell.TechHub.Instrumentation.SubAgent.exe" and 
         process.parent.executable : "C:\\Program Files\\Dell\\TechHub\\Dell.TechHub.exe" and 
         process.code_signature.subject_name == "Dell Technologies Inc." and process.code_signature.trusted == true) and

    not (process.parent.executable : "C:\\Program Files (x86)\\ScreenConnect Client*\\ScreenConnect.ClientService.exe" and
        process.executable : "C:\\Program Files (x86)\\ScreenConnect Client (*)\\ScreenConnect.WindowsClient.exe" and
        process.code_signature.subject_name == "ConnectWise, LLC" and process.code_signature.trusted == true) and

    not (process.name == "powershell.exe" and user.id == "S-1-5-18" and
         process.parent.executable : "C:\\Program Files (x86)\\Quest\\KACE\\KInventory.exe") and

    not process.thread.Ext.call_stack_final_user_module.protection_provenance : ("cyvrtrap.dll", "bass.dll") and

    not (process.executable : "C:\\Windows\\System32\\PrintIsolationHost.exe" and
         process.thread.Ext.call_stack_final_user_module.protection_provenance_path like "c:\\windows\\system32\\msvcr100.dll") and

    not (process.executable : "C:\\Windows\\System32\\inetsrv\\w3wp.exe" and process.parent.executable : "C:\\Windows\\System32\\svchost.exe" and 
         _arraysearch(process.thread.Ext.call_stack, $entry, 
                      $entry.callsite_trailing_bytes : ("41c644240c01*488b558849895424104883c4785b5e5f415c415d415e415f5dc3*", 
                                                        "41c6470c01833*488bc6488b5590498957104883c4685b5e5f415c415*",
                                                        "*85f60f95c00fb6c00fb6c041c6470c01488b558849895710488d65c85b5e5f415c415d415e*"))) and

    not (process.parent.executable : "C:\\Program Files\\ATERA Networks\\AteraAgent\\Agent\\AteraAgent.exe" and
         process.executable : "C:\\Program Files\\ATERA Networks\\AteraAgent\\Agent\\packages\\AgentPackageMonitoring\\AgentPackageMonitoring.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.executableeqC:\Windows\System32\inetsrv\w3wp.exeexcludes:process.executable field:"process.executable" value:"C:\Windows\System32\inetsrv\w3wp.exe"
process.parent.executableeqC:\Windows\System32\svchost.exeexcludes:process.parent.executable field:"process.parent.executable" value:"C:\Windows\System32\svchost.exe"
process.code_signature.subject_nameeqConnectWise, LLCexcludes:process.code_signature.subject_name field:"process.code_signature.subject_name" value:"ConnectWise, LLC"
process.code_signature.trustedeqtrueexcludes:process.code_signature.trusted field:"process.code_signature.trusted" value:"true"
process.executablewildcardC:\Program Files (x86)\ScreenConnect Client (*)\ScreenConnect.WindowsClient.exeexcludes:process.executable field:"process.executable" value:"C:\Program Files (x86)\ScreenConnect Client (*)\ScreenConnect.WindowsClient.exe"
process.parent.executablewildcardC:\Program Files (x86)\ScreenConnect Client*\ScreenConnect.ClientService.exeexcludes:process.parent.executable field:"process.parent.executable" value:"C:\Program Files (x86)\ScreenConnect Client*\ScreenConnect.ClientService.exe"
process.code_signature.subject_nameeqDell Technologies Inc.excludes:process.code_signature.subject_name field:"process.code_signature.subject_name" value:"Dell Technologies Inc."
process.executableeqC:\Program Files\Dell\DTP\InstrumentationSubAgent\Dell.TechHub.Instrumentation.SubAgent.exeexcludes:process.executable field:"process.executable" value:"C:\Program Files\Dell\DTP\InstrumentationSubAgent\Dell.TechHub.Instrumentation.SubAgent.exe"
process.parent.executableeqC:\Program Files\Dell\TechHub\Dell.TechHub.exeexcludes:process.parent.executable field:"process.parent.executable" value:"C:\Program Files\Dell\TechHub\Dell.TechHub.exe"
process.executableeqC:\Program Files\ATERA Networks\AteraAgent\Agent\packages\AgentPackageMonitoring\AgentPackageMonitoring.exeexcludes:process.executable field:"process.executable" value:"C:\Program Files\ATERA Networks\AteraAgent\Agent\packages\AgentPackageMonitoring\AgentPackageMonitoring.exe"
process.parent.executableeqC:\Program Files\ATERA Networks\AteraAgent\Agent\AteraAgent.exeexcludes:process.parent.executable field:"process.parent.executable" value:"C:\Program Files\ATERA Networks\AteraAgent\Agent\AteraAgent.exe"
process.executableeqC:\Windows\System32\PrintIsolationHost.exeexcludes:process.executable field:"process.executable" value:"C:\Windows\System32\PrintIsolationHost.exe"
process.thread.Ext.call_stack_final_user_module.protection_provenance_patheqc:\windows\system32\msvcr100.dllexcludes:process.thread.Ext.call_stack_final_user_module.protection_provenance_path field:"process.thread.Ext.call_stack_final_user_module.protection_provenance_path" value:"c:\windows\system32\msvcr100.dll"
process.nameeqpowershell.exeexcludes:process.name field:"process.name" value:"powershell.exe"
process.parent.executableeqC:\Program Files (x86)\Quest\KACE\KInventory.exeexcludes:process.parent.executable field:"process.parent.executable" value:"C:\Program Files (x86)\Quest\KACE\KInventory.exe"
user.ideqS-1-5-18excludes:user.id field:"user.id" value:"S-1-5-18"
process.thread.Ext.call_stack_final_user_module.protection_provenanceeqcyvrtrap.dll, bass.dllexcludes:process.thread.Ext.call_stack_final_user_module.protection_provenance field:"process.thread.Ext.call_stack_final_user_module.protection_provenance" value:"cyvrtrap.dll" field:"process.thread.Ext.call_stack_final_user_module.protection_provenance" value:"bass.dll"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
process.Ext.api.behaviorsin
  • allocate_shellcode corpus 9 (elastic 9)
  • execute_shellcode corpus 3 (elastic 3)
  • shellcode corpus 2 (elastic 2)
field:"process.Ext.api.behaviors" kind:in
process.Ext.api.namein
  • MapViewOfFile
  • MapViewOfFile2
  • ReadProcessMemory
  • SetThreadContext corpus 4 (elastic 4)
  • SuspendThread
  • VirtualAlloc corpus 4 (elastic 4)
  • VirtualAllocEx
  • VirtualProtect corpus 19 (elastic 19)
  • VirtualProtectEx
  • WriteProcessMemory corpus 14 (elastic 14)
  • connect corpus 5 (elastic 5)
field:"process.Ext.api.name" kind:in
process.executableis_not_null
  • (no value, null check)
field:"Image" kind:is_not_null
process.parent.executableis_not_null
  • (no value, null check)
field:"ParentImage" kind:is_not_null
process.thread.Ext.call_stack_final_user_module.nameeq
  • Unbacked corpus 21 (elastic 21)
field:"process.thread.Ext.call_stack_final_user_module.name" kind:eq value:"Unbacked"
process.thread.Ext.call_stack_final_user_module.protection_provenance_pathis_not_null
  • (no value, null check)
field:"process.thread.Ext.call_stack_final_user_module.protection_provenance_path" kind:is_not_null
process.thread.Ext.call_stack_final_user_module.protection_provenance_pathwildcard
  • c:\windows\system32\*
field:"process.thread.Ext.call_stack_final_user_module.protection_provenance_path" kind:wildcard value:"c:\windows\system32\*"
process.thread.Ext.call_stack_summarywildcard
  • ntdll.dll|Unbacked corpus 6 (elastic 6)
  • ntdll.dll|kernelbase.dll|Unbacked corpus 6 (elastic 6)
  • ntdll.dll|kernelbase.dll|kernel32.dll|Unbacked corpus 4 (elastic 4)
  • ntdll.dll|mswsock.dll|ws2_32.dll|Unbacked corpus 3 (elastic 3)
  • ntdll.dll|wow64.dll|wow64cpu.dll|wow64.dll|ntdll.dll|Unbacked corpus 4 (elastic 4)
  • ntdll.dll|wow64.dll|wow64cpu.dll|wow64.dll|ntdll.dll|Unbacked|kernel32.dll|ntdll.dll corpus 2 (elastic 2)
  • ntdll.dll|wow64.dll|wow64cpu.dll|wow64.dll|ntdll.dll|kernelbase.dll|Unbacked corpus 5 (elastic 5)
  • ntdll.dll|wow64.dll|wow64cpu.dll|wow64.dll|ntdll.dll|kernelbase.dll|Unbacked|kernel32.dll|ntdll.dll corpus 4 (elastic 4)
  • wow64cpu.dll|wow64.dll|ntdll.dll|mswsock.dll|ws2_32.dll|Unbacked|kernel32.dll|ntdll.dll corpus 2 (elastic 2)
field:"process.thread.Ext.call_stack_summary" kind:wildcard