Detection rules › Elastic

Suspicious API Call via Windows Script Interpreter

Source
github.com/elastic/protections-artifacts

Identifies a suspicious managed code hosting process which could indicate code injection or other form of suspicious code execution via Windows scripts.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies a suspicious managed code hosting process which could indicate code injection or other form of suspicious
code execution via Windows scripts.
"""
id = "58adbf08-73bd-4bd3-a74c-6b0f82d23a82"
license = "Elastic License v2"
name = "Suspicious API Call via Windows Script Interpreter"
os_list = ["windows"]
reference = ["https://github.com/med0x2e/GadgetToJScript", "https://github.com/mdsecactivebreach/SharpShooter"]
version = "1.0.5"

query = '''
api where
  process.name : ("wscript.exe", "cscript.exe", "mshta.exe", "cmstp.exe", "msxsl.exe", "mmc.exe") and
  process.Ext.api.name : ("VirtualAlloc", "MapViewOfFile*") and
  process.Ext.api.metadata.target_address_name : "?*" and process.Ext.api.parameters.protection == "RWX" and
  process.thread.Ext.call_stack_final_user_module.name in ("clr.dll", "mscoreei.dll") and
  process.thread.Ext.call_stack_summary : ("*|clr.dll|jscript*", "*|clr.dll|vbscript.dll|msxml?.dll|*") and
  not process.Ext.api.metadata.target_address_name in ("clr.dll", "gdi32full.dll") and
  process.Ext.api.parameters.size != 296 and
  not process.parent.executable :
               ("?:\\IPeople\\Script\\IPScriptDirector.exe",
                "?:\\Program Files\\Microsoft System Center\\Operations Manager\\Server\\MonitoringHost.exe",
                "?:\\Program Files\\Microsoft System Center\\Operations Manager\\Server\\MonitoringHost.exe",
                "C:\\Program Files (x86)\\DarkWebAdvisorsAgent\\PCPitstopScheduleService.exe",
                "C:\\Program Files (x86)\\TelesystemAgent\\PCPitstopScheduleService.exe") and
  not (process.executable : "C:\\Windows\\SysWOW64\\cscript.exe" and process.parent.executable : "C:\\Windows\\SysWOW64\\cmd.exe" and
       process.command_line like "cscript  //B scan.wsf *" and user.id == "S-1-5-18") and
  not (process.executable : "C:\\Windows\\System32\\mmc.exe" and
       process.thread.Ext.call_stack_summary like "ntdll.dll|*|mswb7.dll|clr.dll|jscript.dll|mmcndmgr.dll|mmc.exe*") and
  not process.command_line :
             ("\"C:\\Windows\\System32\\cscript.exe\" //B //Nologo C:\\Windows\\Options\\SWD\\MapHomeDrive_1_0_0.vbs",
              "C:\\WINDOWS\\System32\\WScript.exe \"M:\\DOH\\Data Exchange\\OCFS\\Severe Maternal Morbidity\\EGScript1.vbs\" ",
              "cscript.exe  //T:120 //U //Nologo \"C:\\Program Files (x86)\\Site24x7\\WinAgent\\monitoring\\conf\\scripts\\topprocess.vbs\" 2 ")
'''

min_endpoint_version = "8.10.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0

[[optional_actions]]
action = "rollback"
field = "process.entity_id"
state = 0

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1059"
name = "Command and Scripting Interpreter"
reference = "https://attack.mitre.org/techniques/T1059/"
[[threat.technique.subtechnique]]
id = "T1059.005"
name = "Visual Basic"
reference = "https://attack.mitre.org/techniques/T1059/005/"

[[threat.technique.subtechnique]]
id = "T1059.007"
name = "JavaScript"
reference = "https://attack.mitre.org/techniques/T1059/007/"



[threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1055"
name = "Process Injection"
reference = "https://attack.mitre.org/techniques/T1055/"

[[threat.technique]]
id = "T1220"
name = "XSL Script Processing"
reference = "https://attack.mitre.org/techniques/T1220/"


[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.name : ("wscript.exe", "cscript.exe", "mshta.exe", "cmstp.exe", "msxsl.exe", "mmc.exe") and
  process.Ext.api.name : ("VirtualAlloc", "MapViewOfFile*") and
  process.Ext.api.metadata.target_address_name : "?*" and process.Ext.api.parameters.protection == "RWX" and
  process.thread.Ext.call_stack_final_user_module.name in ("clr.dll", "mscoreei.dll") and
  process.thread.Ext.call_stack_summary : ("*|clr.dll|jscript*", "*|clr.dll|vbscript.dll|msxml?.dll|*") and
  not process.Ext.api.metadata.target_address_name in ("clr.dll", "gdi32full.dll") and
  process.Ext.api.parameters.size != 296 and
  not process.parent.executable :
               ("?:\\IPeople\\Script\\IPScriptDirector.exe",
                "?:\\Program Files\\Microsoft System Center\\Operations Manager\\Server\\MonitoringHost.exe",
                "?:\\Program Files\\Microsoft System Center\\Operations Manager\\Server\\MonitoringHost.exe",
                "C:\\Program Files (x86)\\DarkWebAdvisorsAgent\\PCPitstopScheduleService.exe",
                "C:\\Program Files (x86)\\TelesystemAgent\\PCPitstopScheduleService.exe") and
  not (process.executable : "C:\\Windows\\SysWOW64\\cscript.exe" and process.parent.executable : "C:\\Windows\\SysWOW64\\cmd.exe" and
       process.command_line like "cscript  //B scan.wsf *" and user.id == "S-1-5-18") and
  not (process.executable : "C:\\Windows\\System32\\mmc.exe" and
       process.thread.Ext.call_stack_summary like "ntdll.dll|*|mswb7.dll|clr.dll|jscript.dll|mmcndmgr.dll|mmc.exe*") and
  not process.command_line :
             ("\"C:\\Windows\\System32\\cscript.exe\" //B //Nologo C:\\Windows\\Options\\SWD\\MapHomeDrive_1_0_0.vbs",
              "C:\\WINDOWS\\System32\\WScript.exe \"M:\\DOH\\Data Exchange\\OCFS\\Severe Maternal Morbidity\\EGScript1.vbs\" ",
              "cscript.exe  //T:120 //U //Nologo \"C:\\Program Files (x86)\\Site24x7\\WinAgent\\monitoring\\conf\\scripts\\topprocess.vbs\" 2 ")

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.command_linestarts_withcscript //B scan.wsf excludes:process.command_line field:"process.command_line" value:"cscript //B scan.wsf "
process.executableeqC:\Windows\SysWOW64\cscript.exeexcludes:process.executable field:"process.executable" value:"C:\Windows\SysWOW64\cscript.exe"
process.parent.executableeqC:\Windows\SysWOW64\cmd.exeexcludes:process.parent.executable field:"process.parent.executable" value:"C:\Windows\SysWOW64\cmd.exe"
user.ideqS-1-5-18excludes:user.id field:"user.id" value:"S-1-5-18"
process.executableeqC:\Windows\System32\mmc.exeexcludes:process.executable field:"process.executable" value:"C:\Windows\System32\mmc.exe"
process.thread.Ext.call_stack_summarywildcardntdll.dll|*|mswb7.dll|clr.dll|jscript.dll|mmcndmgr.dll|mmc.exe*excludes:process.thread.Ext.call_stack_summary field:"process.thread.Ext.call_stack_summary" value:"ntdll.dll|*|mswb7.dll|clr.dll|jscript.dll|mmcndmgr.dll|mmc.exe*"
process.Ext.api.metadata.target_address_nameinclr.dll, gdi32full.dllexcludes:process.Ext.api.metadata.target_address_name field:"process.Ext.api.metadata.target_address_name" value:"clr.dll" field:"process.Ext.api.metadata.target_address_name" value:"gdi32full.dll"
process.command_lineeq"C:\Windows\System32\cscript.exe" //B //Nologo C:\Windows\Options\SWD\MapHomeDrive_1_0_0.vbs, C:\WINDOWS\System32\WScript.exe "M:\DOH\Data Exchange\OCFS\Severe Maternal Morbidity\EGScript1.vbs" , cscript.exe //T:120 //U //Nologo "C:\Program Files (x86)\Site24x7\WinAgent\monitoring\conf\scripts\topprocess.vbs" 2 excludes:process.command_line
process.parent.executableeq?:\IPeople\Script\IPScriptDirector.exe, ?:\Program Files\Microsoft System Center\Operations Manager\Server\MonitoringHost.exe, ?:\Program Files\Microsoft System Center\Operations Manager\Server\MonitoringHost.exe, C:\Program Files (x86)\DarkWebAdvisorsAgent\PCPitstopScheduleService.exe, C:\Program Files (x86)\TelesystemAgent\PCPitstopScheduleService.exeexcludes:process.parent.executable

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
process.Ext.api.metadata.target_address_namewildcard
  • ?* corpus 3 (elastic 3)
field:"process.Ext.api.metadata.target_address_name" kind:wildcard value:"?*"
process.Ext.api.namewildcard
  • MapViewOfFile* corpus 5 (elastic 5)
  • VirtualAlloc
field:"process.Ext.api.name" kind:wildcard
process.Ext.api.parameters.protectioneq
  • RWX corpus 8 (elastic 8)
field:"process.Ext.api.parameters.protection" kind:eq value:"RWX"
process.Ext.api.parameters.sizene
  • 296 transforms: number
field:"process.Ext.api.parameters.size" kind:ne value:"296"
process.namewildcard
  • cmstp.exe corpus 25 (elastic 25)
  • cscript.exe corpus 67 (elastic 65, splunk 2)
  • mmc.exe corpus 12 (elastic 7, splunk 5)
  • mshta.exe corpus 84 (elastic 79, splunk 5)
  • msxsl.exe corpus 23 (elastic 22, splunk 1)
  • wscript.exe corpus 83 (elastic 82, splunk 1)
field:"process_name" kind:wildcard
process.thread.Ext.call_stack_final_user_module.namein
  • clr.dll
  • mscoreei.dll
field:"process.thread.Ext.call_stack_final_user_module.name" kind:in
process.thread.Ext.call_stack_summarywildcard
  • *|clr.dll|jscript*
  • *|clr.dll|vbscript.dll|msxml?.dll|*
field:"process.thread.Ext.call_stack_summary" kind:wildcard