Potential Shellcode Injection via a WebShell
Description
Identifies the call of code injection related Windows API with suspicious parameters that align with shellcode execution and where the call stack is pointing to an IIS Web application as the source of the injection.
Query · eql
api where process.name : "w3wp.exe" and
(
(process.Ext.api.name in ("MapViewOfFile", "MapViewOfFile2", "VirtualAlloc", "VirtualAllocEx", "VirtualProtect", "VirtualProtectEx", "WriteProcessMemory") and
_arraysearch(process.thread.Ext.call_stack, $entry, $entry.protection_provenance like "app_web_*.dll" and $entry.symbol_info == "Unbacked")) or
(process.Ext.api.behaviors in ("shellcode", "allocate_shellcode", "execute_shellcode") and
process.thread.Ext.call_stack_final_user_module.name == "Unbacked" and process.Ext.api.metadata.target_address_name == "Unbacked" and
process.parent.executable : "C:\\Windows\\System32\\svchost.exe" and
process.Ext.api.name in ("MapViewOfFile", "MapViewOfFile2", "VirtualAlloc", "VirtualAllocEx", "VirtualProtect", "VirtualProtectEx", "WriteProcessMemory", "connect") and
(process.thread.Ext.call_stack_final_user_module.protection_provenance_path like "c:\\windows\\microsoft.net\\framework*\\clr.dll" or
process.thread.Ext.call_stack_final_user_module.protection_provenance == "clr.dll") and
process.Ext.api.parameters.size != 5 and process.Ext.api.parameters.size != 10 and process.Ext.api.parameters.size != 40 and
process.Ext.api.behaviors != "hook_api" and
process.thread.Ext.call_stack_summary in
("ntdll.dll|kernelbase.dll|Unbacked",
"ntdll.dll|Unbacked",
"ntdll.dll|mswsock.dll|ws2_32.dll|Unbacked",
"ntdll.dll|kernelbase.dll|kernel32.dll|Unbacked"))
) and
not _arraysearch(process.thread.Ext.call_stack, $entry,
$entry.callsite_trailing_bytes like "41c6470c01833d*88bc641c6470c01488b559049895710488d65c85b5e5f415c415d415e415f5dc3001910")