Detection rules › Elastic

Network Connect API from Modified Memory

Source
github.com/elastic/protections-artifacts

Identifies attempts to perform a network connection from a suspicious backed memory block. This may be the result of code injection via module stomping.

MITRE ATT&CK coverage

TacticTechniques
Stealth

Rule body

[rule]
description = """
Identifies attempts to perform a network connection from a suspicious backed memory block. This may be the result of
code injection via module stomping.
"""
id = "8092c7fc-2cd4-4630-84b0-b9c9ea140856"
license = "Elastic License v2"
name = "Network Connect API from Modified Memory"
os_list = ["windows"]
version = "1.0.4"

query = '''
api where process.Ext.api.name == "connect" and
 (
   (process.thread.Ext.call_stack_summary regex """ntdll.dll\|mswsock.dll\|[a-z0-9]+\.dll""" and
    _arraysearch(process.thread.Ext.call_stack, $entry,
                 stringcontains~($entry.symbol_info, substring(process.thread.Ext.call_stack_summary, 22, length(process.thread.Ext.call_stack_summary))) and ($entry.callsite_trailing_bytes : "?*" and $entry.allocation_private_bytes >= 100000))) or

   (process.thread.Ext.call_stack_summary regex """ntdll.dll\|mswsock.dll\|ws2_32.dll\|[a-z0-9]+\.dll""" and
    _arraysearch(process.thread.Ext.call_stack, $entry,
                 stringcontains~($entry.symbol_info, substring(process.thread.Ext.call_stack_summary, 33, length(process.thread.Ext.call_stack_summary))) and ($entry.callsite_trailing_bytes : "?*" and $entry.allocation_private_bytes >= 100000))) or

   (process.thread.Ext.call_stack_summary regex """wow64cpu.dll\|wow64.dll\|ntdll.dll\|mswsock.dll\|[a-z0-9]+\.dll""" and
    _arraysearch(process.thread.Ext.call_stack, $entry,
                 stringcontains~($entry.symbol_info, substring(process.thread.Ext.call_stack_summary, 45, length(process.thread.Ext.call_stack_summary))) and ($entry.callsite_trailing_bytes : "?*" and $entry.allocation_private_bytes >= 100000))) or

   (process.thread.Ext.call_stack_summary regex """wow64cpu.dll\|wow64.dll\|ntdll.dll\|mswsock.dll\|ws2_32.dll\|[a-z0-9]+\.dll""" and
    _arraysearch(process.thread.Ext.call_stack, $entry,
                 stringcontains~($entry.symbol_info, substring(process.thread.Ext.call_stack_summary, 56, length(process.thread.Ext.call_stack_summary))) and ($entry.callsite_trailing_bytes : "?*" and $entry.allocation_private_bytes >= 100000)))
  ) and

  not process.thread.Ext.call_stack_summary in
                            ("wow64cpu.dll|wow64.dll|ntdll.dll|mswsock.dll|ws2_32.dll|vfp?r.dll",
                             "wow64cpu.dll|wow64.dll|ntdll.dll|mswsock.dll|ws2_32.dll|ftacommonex.dll",
                             "wow64cpu.dll|wow64.dll|ntdll.dll|mswsock.dll|asproxy.dll",
                             "ntdll.dll|mswsock.dll|ws2_32.dll|xdlicense.dll") and
  not _arraysearch(process.thread.Ext.call_stack_final_user_module.code_signature,
                   $entry, $entry.status == "trusted" and
                   $entry.subject_name in ("Microsoft Windows Hardware Compatibility Publisher",
                                           "Asesoria Informatica Gallega SL", "Astrill Systems Corp.",
                                           "Rockwell Automation Inc", "Star Finanz-Software Entwicklung und Vertriebs GmbH",
                                           "Siemens Industry Software Inc.", "Bitdefender SRL"))
'''

min_endpoint_version = "8.14.0"
optional_actions = []
[[actions]]
action = "kill_process"
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/"
[[threat]]
framework = "MITRE ATT&CK"

[threat.tactic]
id = "TA0011"
name = "Command and Control"
reference = "https://attack.mitre.org/tactics/TA0011/"

[internal]
min_endpoint_version = "8.14.0"

Stages and Predicates

Stage 1: api

api where process.Ext.api.name == "connect" and
 (
   (process.thread.Ext.call_stack_summary regex """ntdll.dll\|mswsock.dll\|[a-z0-9]+\.dll""" and
    _arraysearch(process.thread.Ext.call_stack, $entry,
                 stringcontains~($entry.symbol_info, substring(process.thread.Ext.call_stack_summary, 22, length(process.thread.Ext.call_stack_summary))) and ($entry.callsite_trailing_bytes : "?*" and $entry.allocation_private_bytes >= 100000))) or

   (process.thread.Ext.call_stack_summary regex """ntdll.dll\|mswsock.dll\|ws2_32.dll\|[a-z0-9]+\.dll""" and
    _arraysearch(process.thread.Ext.call_stack, $entry,
                 stringcontains~($entry.symbol_info, substring(process.thread.Ext.call_stack_summary, 33, length(process.thread.Ext.call_stack_summary))) and ($entry.callsite_trailing_bytes : "?*" and $entry.allocation_private_bytes >= 100000))) or

   (process.thread.Ext.call_stack_summary regex """wow64cpu.dll\|wow64.dll\|ntdll.dll\|mswsock.dll\|[a-z0-9]+\.dll""" and
    _arraysearch(process.thread.Ext.call_stack, $entry,
                 stringcontains~($entry.symbol_info, substring(process.thread.Ext.call_stack_summary, 45, length(process.thread.Ext.call_stack_summary))) and ($entry.callsite_trailing_bytes : "?*" and $entry.allocation_private_bytes >= 100000))) or

   (process.thread.Ext.call_stack_summary regex """wow64cpu.dll\|wow64.dll\|ntdll.dll\|mswsock.dll\|ws2_32.dll\|[a-z0-9]+\.dll""" and
    _arraysearch(process.thread.Ext.call_stack, $entry,
                 stringcontains~($entry.symbol_info, substring(process.thread.Ext.call_stack_summary, 56, length(process.thread.Ext.call_stack_summary))) and ($entry.callsite_trailing_bytes : "?*" and $entry.allocation_private_bytes >= 100000)))
  ) and

  not process.thread.Ext.call_stack_summary in
                            ("wow64cpu.dll|wow64.dll|ntdll.dll|mswsock.dll|ws2_32.dll|vfp?r.dll",
                             "wow64cpu.dll|wow64.dll|ntdll.dll|mswsock.dll|ws2_32.dll|ftacommonex.dll",
                             "wow64cpu.dll|wow64.dll|ntdll.dll|mswsock.dll|asproxy.dll",
                             "ntdll.dll|mswsock.dll|ws2_32.dll|xdlicense.dll") and
  not _arraysearch(process.thread.Ext.call_stack_final_user_module.code_signature,
                   $entry, $entry.status == "trusted" and
                   $entry.subject_name in ("Microsoft Windows Hardware Compatibility Publisher",
                                           "Asesoria Informatica Gallega SL", "Astrill Systems Corp.",
                                           "Rockwell Automation Inc", "Star Finanz-Software Entwicklung und Vertriebs GmbH",
                                           "Siemens Industry Software Inc.", "Bitdefender SRL"))

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
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_summaryinntdll.dll|mswsock.dll|ws2_32.dll|xdlicense.dll, wow64cpu.dll|wow64.dll|ntdll.dll|mswsock.dll|asproxy.dll, wow64cpu.dll|wow64.dll|ntdll.dll|mswsock.dll|ws2_32.dll|ftacommonex.dll, wow64cpu.dll|wow64.dll|ntdll.dll|mswsock.dll|ws2_32.dll|vfp?r.dllexcludes:process.thread.Ext.call_stack_summary

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
process.Ext.api.nameeq
  • connect corpus 5 (elastic 5)
field:"process.Ext.api.name" kind:eq value:"connect"
process.thread.Ext.call_stack_summaryregex_match
  • ntdll.dll|mswsock.dll|[a-z0-9]+.dll
  • ntdll.dll|mswsock.dll|ws2_32.dll|[a-z0-9]+.dll
  • wow64cpu.dll|wow64.dll|ntdll.dll|mswsock.dll|[a-z0-9]+.dll
  • wow64cpu.dll|wow64.dll|ntdll.dll|mswsock.dll|ws2_32.dll|[a-z0-9]+.dll
field:"process.thread.Ext.call_stack_summary" kind:regex_match