Detection rules › Elastic
Windows Socket Creation from Stomped Module
Identifies the creation of a Windows network socket from a potentially stomped module.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Stealth |
Rule body
[rule]
description = "Identifies the creation of a Windows network socket from a potentially stomped module."
id = "46b3b2f8-d876-4344-8fff-8c86103bf8e2"
license = "Elastic License v2"
name = "Windows Socket Creation from Stomped Module"
os_list = ["windows"]
version = "1.0.2"
query = '''
api where process.Ext.api.name == "VirtualProtect" and
process.Ext.api.metadata.target_address_name == "mswsock.dll" and
_arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info : "c:\\windows\\sys?????\\ws2_32.dll!WSASocket*") and
(
(process.thread.Ext.call_stack_summary regex """ntdll.dll\|apphelp.dll\|ntdll.dll\|kernelbase.dll\|ws2_32.dll\|[a-z]+\.dll""" and
_arraysearch(process.thread.Ext.call_stack, $entry,
stringcontains~($entry.symbol_info, substring(process.thread.Ext.call_stack_summary, 58, length(process.thread.Ext.call_stack_summary))) and $entry.callsite_trailing_bytes : "?*")) or
(process.thread.Ext.call_stack_summary regex """ntdll.dll\|wow64.dll\|wow64cpu.dll\|wow64.dll\|ntdll.dll\|apphelp.dll\|ntdll.dll\|kernelbase.dll\|ws2_32.dll\|[a-z]+\.dll""" and
_arraysearch(process.thread.Ext.call_stack, $entry,
stringcontains~($entry.symbol_info, substring(process.thread.Ext.call_stack_summary, 101, length(process.thread.Ext.call_stack_summary))) and $entry.callsite_trailing_bytes : "?*"))
) and
not _arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info like "c:\\windows\\syswow64\\rapi.dll*" and $entry.callsite_trailing_bytes like "8b450c8b0850ff5108eb1066837f50027509ff77548b0656ff500cb9a0725e67e8b23a0000eb0e8b0656*")
'''
min_endpoint_version = "8.10.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0
tree = true
[[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
Stage 1: api
api where process.Ext.api.name == "VirtualProtect" and
process.Ext.api.metadata.target_address_name == "mswsock.dll" and
_arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info : "c:\\windows\\sys?????\\ws2_32.dll!WSASocket*") and
(
(process.thread.Ext.call_stack_summary regex """ntdll.dll\|apphelp.dll\|ntdll.dll\|kernelbase.dll\|ws2_32.dll\|[a-z]+\.dll""" and
_arraysearch(process.thread.Ext.call_stack, $entry,
stringcontains~($entry.symbol_info, substring(process.thread.Ext.call_stack_summary, 58, length(process.thread.Ext.call_stack_summary))) and $entry.callsite_trailing_bytes : "?*")) or
(process.thread.Ext.call_stack_summary regex """ntdll.dll\|wow64.dll\|wow64cpu.dll\|wow64.dll\|ntdll.dll\|apphelp.dll\|ntdll.dll\|kernelbase.dll\|ws2_32.dll\|[a-z]+\.dll""" and
_arraysearch(process.thread.Ext.call_stack, $entry,
stringcontains~($entry.symbol_info, substring(process.thread.Ext.call_stack_summary, 101, length(process.thread.Ext.call_stack_summary))) and $entry.callsite_trailing_bytes : "?*"))
) and
not _arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info like "c:\\windows\\syswow64\\rapi.dll*" and $entry.callsite_trailing_bytes like "8b450c8b0850ff5108eb1066837f50027509ff77548b0656ff500cb9a0725e67e8b23a0000eb0e8b0656*")
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.thread.Ext.call_stack | array_any | excludes:process.thread.Ext.call_stack |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
process.Ext.api.metadata.target_address_name | eq |
| field:"process.Ext.api.metadata.target_address_name" kind:eq value:"mswsock.dll" |
process.Ext.api.name | eq |
| field:"process.Ext.api.name" kind:eq value:"VirtualProtect" |
process.thread.Ext.call_stack_summary | regex_match |
| field:"process.thread.Ext.call_stack_summary" kind:regex_match |