Detection rules › Elastic

Network Activity from a Stomped Module

Time window
2m
Sequence by
process.entity_id
Source
github.com/elastic/protections-artifacts

Identifies when a process loads a network library and the thread call stack is pointing to a modified memory module. This may be the result of a code injection using module stomping or DLL hollowing via overwriting the content of legit DLL with malicious code.

MITRE ATT&CK coverage

TacticTechniques
Stealth

Rule body

[rule]
description = """
Identifies when a process loads a network library and the thread call stack is pointing to a modified memory module.
This may be the result of a code injection using module stomping or DLL hollowing via overwriting the content of legit
DLL with malicious code.
"""
id = "4388a77b-4ddf-4e15-8314-ecf96c77807a"
license = "Elastic License v2"
name = "Network Activity from a Stomped Module"
os_list = ["windows"]
reference = ["https://www.elastic.co/security-labs/doubling-down-etw-callstacks"]
version = "1.0.21"

query = '''
sequence by process.entity_id with maxspan=2m
 [api where process.Ext.api.name == "VirtualProtect" and process.Ext.api.summary : "*.dll*" and 
  process.Ext.api.parameters.size >= 10000 and 
  not process.Ext.api.metadata.target_address_name in ("ntdll.dll", "kernelbase.dll") and
  process.Ext.api.metadata.target_address_path like
                                ("?:\\windows\\system32\\*.dll",
                                 "?:\\windows\\syswow64\\*.dll",
                                 "?:\\windows\\winsxs\\*.dll",
                                 "?:\\program files*\\microsoft\\*.dll",
                                 "?:\\program files*\\windows*.dll",
                                 "?:\\program files*\\common files\\microsoft*.dll") and
  not process.thread.Ext.call_stack_final_user_module.name like ("Kernel", "Kernel|*", "Unknown", "Undetermined") and
  not process.thread.Ext.call_stack_final_user_module.protection_provenance like ("Kernel", "Kernel|*") and
  not (process.thread.Ext.call_stack_summary : "*ntdll.dll|kernelbase.dll|combase.dll|msvbvm60.dll*" and
       process.Ext.api.metadata.target_address_path : "?:\\windows\\syswow64\\mfc71u.dll") and
  not process.Ext.api.metadata.target_address_path like
                               ("?:\\program files*\\microsoft\\scanprocess.dll",
                                "c:\\windows\\syswow64\\cyinjct.dll",
                                "c:\\windows\\syswow64\\cnc_bll.dll",
                                "c:\\windows\\syswow64\\dbodbc11.dll",
                                "c:\\windows\\syswow64\\eztwain4.dll",
                                "?:\\program files (x86)\\common files\\microsoft shared\\vba\\vba?\\vbe?.dll") and
  not process.thread.Ext.call_stack_final_user_module.path like
                                     ("?:\\program files\\*",
                                      "?:\\program files (x86)\\*",
                                      "\\program files\\*",
                                      "\\program files (x86)\\*",
                                      "?:\\windows\\syswow64\\combase.dll", 
                                      "?:\\windows\\syswow64\\apphelp.dll",
                                      "?:\\windows\\system32\\apphelp.dll",
                                      "?:\\windows\\syswow64\\ntdll.dll", 
                                      "?:\\windows\\system32\\ntdll.dll", 
                                      "?:\\windows\\system32\\rltkapo64.dll",
                                      "?:\\windows\\syswow64\\bit4ucsp1.dll",
                                      "c:\\windows\\syswow64\\hmpalert.dll") and
    not (process.executable : ("?:\\Program Files (x86)\\*.exe", "?:\\Program Files\\*.exe") and  
         process.code_signature.trusted == true and 
         process.code_signature.subject_name in ("Citrix Systems, Inc.", "Business Objects Americas", "COMMUNITY BRANDS PARENTCO", "Johnson Controls")) and
    not process.executable : ("?:\\Program Files (x86)\\Microsoft\\DocuAction.exe", 
                              "?:\\Windows\\twain_32\\Plustek\\Plustek SmartOffice PS* Series\\TWAIN_Proxy.exe",
                              "?:\\Program Files (x86)\\Business Objects\\Crystal Reports 11.5\\crw32.exe",
                              "?:\\Program Files (x86)\\Kantech\\Server_CE\\Bin\\RVPControl.exe",
                              "C:\\Program Files (x86)\\TerminalWorks\\TSScan\\TSScanConsole.exe",
                              "C:\\Program Files (x86)\\Common Files\\Adobe\\Adobe Desktop Common\\ADS\\Adobe Desktop Service.exe") and
    not (process.executable : "?:\\Windows\\SysWOW64\\dat\\Dexon\\Agent\\Agent.exe" and
         process.code_signature.subject_name == "Dexon Software S A" and process.code_signature.status == "errorExpired") and
    process.thread.Ext.call_stack_final_user_module.hash.sha256 != "3df383f4b0195620badc0bb9f5e1d86ebdb4975b60da4b910a26fee9b4af474f" 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", "Citrix Systems, Inc.", "Palo Alto Networks (Netherlands) B.V.",  "Palo Alto Networks")) and
    not (process.Ext.api.behaviors == "image_indirect_call" and process.thread.Ext.call_stack_summary like "ntdll.dll|wow64.dll|wow64cpu.dll|wow64.dll|ntdll.dll*")
  ] as event0 
 [any where 
  (
   (event.category : "library" and dll.name : ("ws2_32.dll", "wininet.dll", "winhttp.dll")) or 
   (event.category : "registry" and registry.path : "HKEY_USERS\\*\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\*")
   ) and 
   endswith~(process.thread.Ext.call_stack_summary, event0.process.Ext.api.metadata.target_address_name) and 
   process.thread.Ext.call_stack_summary like "ntdll.dll|*" and
  _arraysearch(process.thread.Ext.call_stack, $entry,
               $entry.allocation_private_bytes >= 100000 and 
               stringcontains~($entry.symbol_info, event0.process.Ext.api.metadata.target_address_name) and $entry.callsite_trailing_bytes like "?*") and
  not _arraysearch(process.thread.Ext.call_stack, $entry,
                   $entry.callsite_trailing_bytes == "33c0405f5ec356578b7c24108b3785f6742e56e853e9ffff85c074138b10578bc8ff920801000085c00f85605afeff3b74240c740b56ff15d015ed1b8bf0ebce")]
'''

min_endpoint_version = "8.10.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/"

[internal]
min_endpoint_version = "8.10.0"

Stages and Predicates

Ordered sequence: each step below must occur in order within 2m, correlated by process.entity_id.

Stage 1: api

[api where process.Ext.api.name == "VirtualProtect" and process.Ext.api.summary : "*.dll*" and 
  process.Ext.api.parameters.size >= 10000 and 
  not process.Ext.api.metadata.target_address_name in ("ntdll.dll", "kernelbase.dll") and
  process.Ext.api.metadata.target_address_path like
                                ("?:\\windows\\system32\\*.dll",
                                 "?:\\windows\\syswow64\\*.dll",
                                 "?:\\windows\\winsxs\\*.dll",
                                 "?:\\program files*\\microsoft\\*.dll",
                                 "?:\\program files*\\windows*.dll",
                                 "?:\\program files*\\common files\\microsoft*.dll") and
  not process.thread.Ext.call_stack_final_user_module.name like ("Kernel", "Kernel|*", "Unknown", "Undetermined") and
  not process.thread.Ext.call_stack_final_user_module.protection_provenance like ("Kernel", "Kernel|*") and
  not (process.thread.Ext.call_stack_summary : "*ntdll.dll|kernelbase.dll|combase.dll|msvbvm60.dll*" and
       process.Ext.api.metadata.target_address_path : "?:\\windows\\syswow64\\mfc71u.dll") and
  not process.Ext.api.metadata.target_address_path like
                               ("?:\\program files*\\microsoft\\scanprocess.dll",
                                "c:\\windows\\syswow64\\cyinjct.dll",
                                "c:\\windows\\syswow64\\cnc_bll.dll",
                                "c:\\windows\\syswow64\\dbodbc11.dll",
                                "c:\\windows\\syswow64\\eztwain4.dll",
                                "?:\\program files (x86)\\common files\\microsoft shared\\vba\\vba?\\vbe?.dll") and
  not process.thread.Ext.call_stack_final_user_module.path like
                                     ("?:\\program files\\*",
                                      "?:\\program files (x86)\\*",
                                      "\\program files\\*",
                                      "\\program files (x86)\\*",
                                      "?:\\windows\\syswow64\\combase.dll", 
                                      "?:\\windows\\syswow64\\apphelp.dll",
                                      "?:\\windows\\system32\\apphelp.dll",
                                      "?:\\windows\\syswow64\\ntdll.dll", 
                                      "?:\\windows\\system32\\ntdll.dll", 
                                      "?:\\windows\\system32\\rltkapo64.dll",
                                      "?:\\windows\\syswow64\\bit4ucsp1.dll",
                                      "c:\\windows\\syswow64\\hmpalert.dll") and
    not (process.executable : ("?:\\Program Files (x86)\\*.exe", "?:\\Program Files\\*.exe") and  
         process.code_signature.trusted == true and 
         process.code_signature.subject_name in ("Citrix Systems, Inc.", "Business Objects Americas", "COMMUNITY BRANDS PARENTCO", "Johnson Controls")) and
    not process.executable : ("?:\\Program Files (x86)\\Microsoft\\DocuAction.exe", 
                              "?:\\Windows\\twain_32\\Plustek\\Plustek SmartOffice PS* Series\\TWAIN_Proxy.exe",
                              "?:\\Program Files (x86)\\Business Objects\\Crystal Reports 11.5\\crw32.exe",
                              "?:\\Program Files (x86)\\Kantech\\Server_CE\\Bin\\RVPControl.exe",
                              "C:\\Program Files (x86)\\TerminalWorks\\TSScan\\TSScanConsole.exe",
                              "C:\\Program Files (x86)\\Common Files\\Adobe\\Adobe Desktop Common\\ADS\\Adobe Desktop Service.exe") and
    not (process.executable : "?:\\Windows\\SysWOW64\\dat\\Dexon\\Agent\\Agent.exe" and
         process.code_signature.subject_name == "Dexon Software S A" and process.code_signature.status == "errorExpired") and
    process.thread.Ext.call_stack_final_user_module.hash.sha256 != "3df383f4b0195620badc0bb9f5e1d86ebdb4975b60da4b910a26fee9b4af474f" 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", "Citrix Systems, Inc.", "Palo Alto Networks (Netherlands) B.V.",  "Palo Alto Networks")) and
    not (process.Ext.api.behaviors == "image_indirect_call" and process.thread.Ext.call_stack_summary like "ntdll.dll|wow64.dll|wow64cpu.dll|wow64.dll|ntdll.dll*")
  ] as event0

Stage 2: any

[any where 
  (
   (event.category : "library" and dll.name : ("ws2_32.dll", "wininet.dll", "winhttp.dll")) or 
   (event.category : "registry" and registry.path : "HKEY_USERS\\*\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\*")
   ) and 
   endswith~(process.thread.Ext.call_stack_summary, event0.process.Ext.api.metadata.target_address_name) and 
   process.thread.Ext.call_stack_summary like "ntdll.dll|*" and
  _arraysearch(process.thread.Ext.call_stack, $entry,
               $entry.allocation_private_bytes >= 100000 and 
               stringcontains~($entry.symbol_info, event0.process.Ext.api.metadata.target_address_name) and $entry.callsite_trailing_bytes like "?*") and
  not _arraysearch(process.thread.Ext.call_stack, $entry,
                   $entry.callsite_trailing_bytes == "33c0405f5ec356578b7c24108b3785f6742e56e853e9ffff85c074138b10578bc8ff920801000085c00f85605afeff3b74240c740b56ff15d015ed1b8bf0ebce")]

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.Ext.api.behaviorseqimage_indirect_callexcludes:process.Ext.api.behaviors field:"process.Ext.api.behaviors" value:"image_indirect_call"
process.thread.Ext.call_stack_summarystarts_withntdll.dll|wow64.dll|wow64cpu.dll|wow64.dll|ntdll.dllexcludes:process.thread.Ext.call_stack_summary field:"process.thread.Ext.call_stack_summary" value:"ntdll.dll|wow64.dll|wow64cpu.dll|wow64.dll|ntdll.dll"
process.Ext.api.metadata.target_address_patheq?:\windows\syswow64\mfc71u.dllexcludes:process.Ext.api.metadata.target_address_path field:"process.Ext.api.metadata.target_address_path" value:"?:\windows\syswow64\mfc71u.dll"
process.thread.Ext.call_stack_summarymatchntdll.dll|kernelbase.dll|combase.dll|msvbvm60.dllexcludes:process.thread.Ext.call_stack_summary field:"process.thread.Ext.call_stack_summary" value:"ntdll.dll|kernelbase.dll|combase.dll|msvbvm60.dll"
process.code_signature.statuseqerrorExpiredexcludes:process.code_signature.status field:"process.code_signature.status" value:"errorExpired"
process.code_signature.subject_nameeqDexon Software S Aexcludes:process.code_signature.subject_name field:"process.code_signature.subject_name" value:"Dexon Software S A"
process.executableeq?:\Windows\SysWOW64\dat\Dexon\Agent\Agent.exeexcludes:process.executable field:"process.executable" value:"?:\Windows\SysWOW64\dat\Dexon\Agent\Agent.exe"
process.code_signature.subject_nameinBusiness Objects Americas, COMMUNITY BRANDS PARENTCO, Citrix Systems, Inc., Johnson Controlsexcludes:process.code_signature.subject_name
process.code_signature.trustedeqtrueexcludes:process.code_signature.trusted field:"process.code_signature.trusted" value:"true"
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.Ext.api.metadata.target_address_nameinkernelbase.dll, ntdll.dllexcludes:process.Ext.api.metadata.target_address_name field:"process.Ext.api.metadata.target_address_name" value:"kernelbase.dll" field:"process.Ext.api.metadata.target_address_name" value:"ntdll.dll"
process.Ext.api.metadata.target_address_pathwildcard?:\program files*\microsoft\scanprocess.dll, c:\windows\syswow64\cyinjct.dll, c:\windows\syswow64\cnc_bll.dll, c:\windows\syswow64\dbodbc11.dll, c:\windows\syswow64\eztwain4.dll, ?:\program files (x86)\common files\microsoft shared\vba\vba?\vbe?.dllexcludes:process.Ext.api.metadata.target_address_path
process.executablewildcard?:\Program Files (x86)\Microsoft\DocuAction.exe, ?:\Windows\twain_32\Plustek\Plustek SmartOffice PS* Series\TWAIN_Proxy.exe, ?:\Program Files (x86)\Business Objects\Crystal Reports 11.5\crw32.exe, ?:\Program Files (x86)\Kantech\Server_CE\Bin\RVPControl.exe, C:\Program Files (x86)\TerminalWorks\TSScan\TSScanConsole.exe, C:\Program Files (x86)\Common Files\Adobe\Adobe Desktop Common\ADS\Adobe Desktop Service.exeexcludes:process.executable
process.thread.Ext.call_stack_final_user_module.namewildcardKernel, Kernel|*, Unknown, Undeterminedexcludes:process.thread.Ext.call_stack_final_user_module.name
process.thread.Ext.call_stack_final_user_module.pathwildcard?:\program files\*, ?:\program files (x86)\*, \program files\*, \program files (x86)\*, ?:\windows\syswow64\combase.dll, ?:\windows\syswow64\apphelp.dll, ?:\windows\system32\apphelp.dll, ?:\windows\syswow64\ntdll.dll, ?:\windows\system32\ntdll.dll, ?:\windows\system32\rltkapo64.dll, ?:\windows\syswow64\bit4ucsp1.dll, c:\windows\syswow64\hmpalert.dllexcludes:process.thread.Ext.call_stack_final_user_module.path
process.thread.Ext.call_stack_final_user_module.protection_provenancewildcardKernel, Kernel|*excludes:process.thread.Ext.call_stack_final_user_module.protection_provenance field:"process.thread.Ext.call_stack_final_user_module.protection_provenance" value:"Kernel" field:"process.thread.Ext.call_stack_final_user_module.protection_provenance" value:"Kernel|*"
process.thread.Ext.call_stackarray_any(no value, null check)excludes:process.thread.Ext.call_stack

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
dll.namewildcard
  • winhttp.dll corpus 16 (elastic 16)
  • wininet.dll corpus 18 (elastic 18)
  • ws2_32.dll corpus 20 (elastic 20)
field:"dll.name" kind:wildcard
event.categorywildcard
  • library corpus 22 (elastic 22)
  • registry corpus 14 (elastic 14)
field:"event.category" kind:wildcard
process.Ext.api.metadata.target_address_pathwildcard
  • ?:\program files*\common files\microsoft*.dll
  • ?:\program files*\microsoft\*.dll
  • ?:\program files*\windows*.dll
  • ?:\windows\system32\*.dll
  • ?:\windows\syswow64\*.dll
  • ?:\windows\winsxs\*.dll
field:"process.Ext.api.metadata.target_address_path" kind:wildcard
process.Ext.api.nameeq
  • VirtualProtect corpus 19 (elastic 19)
field:"process.Ext.api.name" kind:eq value:"VirtualProtect"
process.Ext.api.parameters.sizege
  • 10000 transforms: number corpus 11 (elastic 11)
field:"process.Ext.api.parameters.size" kind:ge value:"10000"
process.Ext.api.summarywildcard
  • *.dll*
field:"process.Ext.api.summary" kind:wildcard value:"*.dll*"
process.thread.Ext.call_stack_final_user_module.hash.sha256ne
  • 3df383f4b0195620badc0bb9f5e1d86ebdb4975b60da4b910a26fee9b4af474f
field:"process.thread.Ext.call_stack_final_user_module.hash.sha256" kind:ne value:"3df383f4b0195620badc0bb9f5e1d86ebdb4975b60da4b910a26fee9b4af474f"
process.thread.Ext.call_stack_summaryends_with
  • event0.process.Ext.api.metadata.target_address_name (field reference)
field:"process.thread.Ext.call_stack_summary" kind:ends_with value:"event0.process.Ext.api.metadata.target_address_name"
process.thread.Ext.call_stack_summarywildcard
  • ntdll.dll|* corpus 5 (elastic 5)
field:"process.thread.Ext.call_stack_summary" kind:wildcard value:"ntdll.dll|*"
registry.pathwildcard
  • HKEY_USERS\*\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\* corpus 3 (elastic 3)
field:"TargetObject" kind:wildcard value:"HKEY_USERS\*\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\*"