Detection rules › Elastic

Shellcode behavior from suspicious RWX provenance

Source
github.com/elastic/protections-artifacts

Identifies suspicious API calls from a signed module and originating from suspicious RWX memory. This may indicate an attempt to perform code injection.

MITRE ATT&CK coverage

TacticTechniques
Stealth

Rule body

[rule]
description = """
Identifies suspicious API calls from a signed module and originating from suspicious RWX memory. This may indicate an
attempt to perform code injection.
"""
id = "a8bacf2b-23a9-4a6d-a117-5df433403c70"
license = "Elastic License v2"
name = "Shellcode behavior from suspicious RWX provenance"
os_list = ["windows"]
version = "1.0.3"

query = '''
api where
 process.Ext.api.behaviors == "allocate_shellcode" and process.Ext.api.behaviors == "unbacked_rwx" and
 process.Ext.api.metadata.target_address_name == "Unbacked" and
 process.thread.Ext.call_stack_final_user_module.protection_provenance != null and
 process.thread.Ext.call_stack_final_user_module.hash.sha256 != null and
 process.thread.Ext.call_stack_final_user_module.code_signature != null and
 process.thread.Ext.call_stack_summary in
                           ("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|kernelbase.dll|Unbacked|kernel32.dll|ntdll.dll") and
 endswith~(process.thread.Ext.call_stack_final_user_module.protection_provenance_path, process.thread.Ext.call_stack_final_user_module.protection_provenance) and
 _arraysearch(process.thread.Ext.call_stack_final_user_module.code_signature, $entry, $entry.trusted == true) and
 _arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info : "Unbacked*" and not $entry.protection_provenance : "Unbacked*" and $entry.callsite_trailing_bytes : "?*") and
 not endswith~(process.thread.Ext.call_stack_final_user_module.protection_provenance, process.name) and
 not process.thread.Ext.call_stack_final_user_module.protection_provenance_path like
                                                    ("?:\\windows\\microsoft.net\\framework*\\clr.dll",
                                                     "?:\\windows\\microsoft.net\\framework*\\mscorwks.dll",
                                                     "?:\\program files (x86)\\*",
                                                     "?:\\program files\\*",
                                                     "?:\\windows\\winsxs\\x*\\msvcr*.dll",
                                                     "c:\\windows\\syswow64\\msv?_?.dll") and
 not _arraysearch(process.thread.Ext.call_stack_final_user_module.code_signature, $entry, $entry.trusted == true and
                  $entry.subject_name in ("Microsoft Windows Hardware Compatibility Publisher", "Microsoft Windows Software Compatibility Publisher", "Microsoft Windows", "Microsoft Corporation",
                                          "Asesoria Informatica Gallega SL", "Riot Games, Inc.", ".NET", "Beijing Huorong Network Technology Co., Ltd.", "DameWare Development, LLC.", "Code Systems Corporation",
                                          "ACEVILLE PTE LTD", "Roblox Corporation")) and
 not (process.Ext.api.name == "VirtualProtect" and
      _arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info like ("c:\\windows\\sys?????\\ntdll.dll!LdrLoadDll*", "c:\\windows\\sys?????\\kernelbase.dll!LoadLibrary*"))) and
 not _arraysearch(process.thread.Ext.call_stack, $entry, $entry.callsite_trailing_bytes like
                ("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
                 "00000000000000f6375c5b2e8900000000000000ff0000ffeeffee0000000000001000000000000020000000000000000100000000000000100000000000003f",
                 "8985271*085c00f859400000056e84003000056e85502000056e85301000090909090909090908b4e3485c90f848900000003")) and
 not process.thread.Ext.call_stack_final_user_module.hash.sha256 in
                        ("eff52743773eb550fcc6ce3efc37c85724502233b6b002a35496d828bd7b280a",
                         "fc450380eaa226b351c919e87df61dd869f02b6ab47beedf8f940618a65761b0",
                         "b982741576a050860c3f3608c7b269dbd35ab296429192b8afa53f1f190069c0",
                         "68fba9dd89bfad35f8fd657b9af22a8aebda31bffda35058a7f5ae376136e89b",
                         "f60dd9f2fcbd495674dfc1555effb710eb081fc7d4cae5fa58c438ab50405081")
'''

min_endpoint_version = "8.14.2"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0
tree = true

[[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.Ext.api.behaviors == "allocate_shellcode" and process.Ext.api.behaviors == "unbacked_rwx" and
 process.Ext.api.metadata.target_address_name == "Unbacked" and
 process.thread.Ext.call_stack_final_user_module.protection_provenance != null and
 process.thread.Ext.call_stack_final_user_module.hash.sha256 != null and
 process.thread.Ext.call_stack_final_user_module.code_signature != null and
 process.thread.Ext.call_stack_summary in
                           ("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|kernelbase.dll|Unbacked|kernel32.dll|ntdll.dll") and
 endswith~(process.thread.Ext.call_stack_final_user_module.protection_provenance_path, process.thread.Ext.call_stack_final_user_module.protection_provenance) and
 _arraysearch(process.thread.Ext.call_stack_final_user_module.code_signature, $entry, $entry.trusted == true) and
 _arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info : "Unbacked*" and not $entry.protection_provenance : "Unbacked*" and $entry.callsite_trailing_bytes : "?*") and
 not endswith~(process.thread.Ext.call_stack_final_user_module.protection_provenance, process.name) and
 not process.thread.Ext.call_stack_final_user_module.protection_provenance_path like
                                                    ("?:\\windows\\microsoft.net\\framework*\\clr.dll",
                                                     "?:\\windows\\microsoft.net\\framework*\\mscorwks.dll",
                                                     "?:\\program files (x86)\\*",
                                                     "?:\\program files\\*",
                                                     "?:\\windows\\winsxs\\x*\\msvcr*.dll",
                                                     "c:\\windows\\syswow64\\msv?_?.dll") and
 not _arraysearch(process.thread.Ext.call_stack_final_user_module.code_signature, $entry, $entry.trusted == true and
                  $entry.subject_name in ("Microsoft Windows Hardware Compatibility Publisher", "Microsoft Windows Software Compatibility Publisher", "Microsoft Windows", "Microsoft Corporation",
                                          "Asesoria Informatica Gallega SL", "Riot Games, Inc.", ".NET", "Beijing Huorong Network Technology Co., Ltd.", "DameWare Development, LLC.", "Code Systems Corporation",
                                          "ACEVILLE PTE LTD", "Roblox Corporation")) and
 not (process.Ext.api.name == "VirtualProtect" and
      _arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info like ("c:\\windows\\sys?????\\ntdll.dll!LdrLoadDll*", "c:\\windows\\sys?????\\kernelbase.dll!LoadLibrary*"))) and
 not _arraysearch(process.thread.Ext.call_stack, $entry, $entry.callsite_trailing_bytes like
                ("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
                 "00000000000000f6375c5b2e8900000000000000ff0000ffeeffee0000000000001000000000000020000000000000000100000000000000100000000000003f",
                 "8985271*085c00f859400000056e84003000056e85502000056e85301000090909090909090908b4e3485c90f848900000003")) and
 not process.thread.Ext.call_stack_final_user_module.hash.sha256 in
                        ("eff52743773eb550fcc6ce3efc37c85724502233b6b002a35496d828bd7b280a",
                         "fc450380eaa226b351c919e87df61dd869f02b6ab47beedf8f940618a65761b0",
                         "b982741576a050860c3f3608c7b269dbd35ab296429192b8afa53f1f190069c0",
                         "68fba9dd89bfad35f8fd657b9af22a8aebda31bffda35058a7f5ae376136e89b",
                         "f60dd9f2fcbd495674dfc1555effb710eb081fc7d4cae5fa58c438ab50405081")

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.Ext.api.nameeqVirtualProtectexcludes:process.Ext.api.name field:"process.Ext.api.name" value:"VirtualProtect"
process.thread.Ext.call_stack_final_user_module.code_signaturearray_any(no value, null check)excludes:process.thread.Ext.call_stack_final_user_module.code_signature
process.thread.Ext.call_stack_final_user_module.hash.sha256in68fba9dd89bfad35f8fd657b9af22a8aebda31bffda35058a7f5ae376136e89b, b982741576a050860c3f3608c7b269dbd35ab296429192b8afa53f1f190069c0, eff52743773eb550fcc6ce3efc37c85724502233b6b002a35496d828bd7b280a, f60dd9f2fcbd495674dfc1555effb710eb081fc7d4cae5fa58c438ab50405081, fc450380eaa226b351c919e87df61dd869f02b6ab47beedf8f940618a65761b0excludes:process.thread.Ext.call_stack_final_user_module.hash.sha256
process.thread.Ext.call_stack_final_user_module.protection_provenanceends_withprocess.nameexcludes:process.thread.Ext.call_stack_final_user_module.protection_provenance field:"process.thread.Ext.call_stack_final_user_module.protection_provenance" value:"process.name"
process.thread.Ext.call_stack_final_user_module.protection_provenance_pathwildcard?:\windows\microsoft.net\framework*\clr.dll, ?:\windows\microsoft.net\framework*\mscorwks.dll, ?:\program files (x86)\*, ?:\program files\*, ?:\windows\winsxs\x*\msvcr*.dll, c:\windows\syswow64\msv?_?.dllexcludes:process.thread.Ext.call_stack_final_user_module.protection_provenance_path

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
process.Ext.api.behaviorseq
  • allocate_shellcode corpus 9 (elastic 9)
  • unbacked_rwx
field:"process.Ext.api.behaviors" kind:eq
process.Ext.api.metadata.target_address_nameeq
  • Unbacked corpus 8 (elastic 8)
field:"process.Ext.api.metadata.target_address_name" kind:eq value:"Unbacked"
process.thread.Ext.call_stack_final_user_module.code_signatureis_not_null
  • (no value, null check)
field:"process.thread.Ext.call_stack_final_user_module.code_signature" kind:is_not_null
process.thread.Ext.call_stack_final_user_module.hash.sha256is_not_null
  • (no value, null check)
field:"process.thread.Ext.call_stack_final_user_module.hash.sha256" kind:is_not_null
process.thread.Ext.call_stack_final_user_module.protection_provenanceis_not_null
  • (no value, null check)
field:"process.thread.Ext.call_stack_final_user_module.protection_provenance" kind:is_not_null
process.thread.Ext.call_stack_final_user_module.protection_provenance_pathends_with
  • process.thread.Ext.call_stack_final_user_module.protection_provenance (field reference)
field:"process.thread.Ext.call_stack_final_user_module.protection_provenance_path" kind:ends_with value:"process.thread.Ext.call_stack_final_user_module.protection_provenance"
process.thread.Ext.call_stack_summaryin
  • ntdll.dll|Unbacked
  • ntdll.dll|kernelbase.dll|Unbacked corpus 3 (elastic 3)
  • 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|kernelbase.dll|Unbacked|kernel32.dll|ntdll.dll
field:"process.thread.Ext.call_stack_summary" kind:in