Detection rules › Elastic

Suspicious Image Load via Windows Scripts

Source
github.com/elastic/protections-artifacts

Identifies when a Windows script interpreter loads an unsigned or untrusted external library. This may indicate an attempt to evade detection by executing malicious code via uncommon methods.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies when a Windows script interpreter loads an unsigned or untrusted external library. This may indicate an
attempt to evade detection by executing malicious code via uncommon methods.
"""
id = "23e29d07-7584-465e-8a6d-912d9ea254a6"
license = "Elastic License v2"
name = "Suspicious Image Load via Windows Scripts"
os_list = ["windows"]
reference = [
    "https://gist.github.com/code-scrap/d7f152ffcdb3e0b02f7f394f5187f008",
    "https://www.elastic.co/security-labs/Hunting-for-Suspicious-Windows-Libraries-for-Execution-and-Evasion",
]
version = "1.0.23"

query = '''
library where process.name : ("wscript.exe", "cscript.exe", "mshta.exe", "wmic.exe", "cmstp.exe", "msxsl.exe") and

 dll.Ext.relative_file_creation_time <= 500 and

 (dll.code_signature.trusted == false or dll.code_signature.exists == false) and 
 
 not dll.code_signature.status : ("errorChaining", "errorExpired") and 
 
 not dll.path :
       ("?:\\Windows\\assembly\\NativeImages*", 
        "?:\\Windows\\System32\\*",
        "?:\\Windows\\SysWOW64\\*",
        "?:\\Program Files\\*",
        "?:\\Program Files (x86)\\*",
        "?:\\Windows\\WinSxS\\*") and
 not startswith~(process.name, dll.name)
'''

min_endpoint_version = "8.4.0"
optional_actions = []
[[actions]]
action = "kill_process"
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/"

[internal]
min_endpoint_version = "8.4.0"

Stages and Predicates

Stage 1: library

library where process.name : ("wscript.exe", "cscript.exe", "mshta.exe", "wmic.exe", "cmstp.exe", "msxsl.exe") and

 dll.Ext.relative_file_creation_time <= 500 and

 (dll.code_signature.trusted == false or dll.code_signature.exists == false) and 
 
 not dll.code_signature.status : ("errorChaining", "errorExpired") and 
 
 not dll.path :
       ("?:\\Windows\\assembly\\NativeImages*", 
        "?:\\Windows\\System32\\*",
        "?:\\Windows\\SysWOW64\\*",
        "?:\\Program Files\\*",
        "?:\\Program Files (x86)\\*",
        "?:\\Windows\\WinSxS\\*") and
 not startswith~(process.name, dll.name)

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
dll.code_signature.statuseqerrorChaining, errorExpiredexcludes:dll.code_signature.status field:"dll.code_signature.status" value:"errorChaining" field:"dll.code_signature.status" value:"errorExpired"
dll.pathstarts_with?:\Windows\assembly\NativeImages, ?:\Windows\System32\, ?:\Windows\SysWOW64\, ?:\Program Files\, ?:\Program Files (x86)\, ?:\Windows\WinSxS\excludes:dll.path
process.namestarts_withdll.nameexcludes:process.name field:"process.name" value:"dll.name"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
dll.Ext.relative_file_creation_timele
  • 500 transforms: number corpus 11 (elastic 11)
field:"dll.Ext.relative_file_creation_time" kind:le value:"500"
dll.code_signature.existseq
  • false transforms: boolean corpus 22 (elastic 22)
field:"dll.code_signature.exists" kind:eq value:"false"
dll.code_signature.trustedeq
  • false transforms: boolean corpus 21 (elastic 21)
field:"dll.code_signature.trusted" kind:eq value:"false"
process.namewildcard
  • cmstp.exe corpus 25 (elastic 25)
  • cscript.exe corpus 67 (elastic 65, splunk 2)
  • mshta.exe corpus 84 (elastic 79, splunk 5)
  • msxsl.exe corpus 23 (elastic 22, splunk 1)
  • wmic.exe corpus 66 (elastic 39, splunk 27)
  • wscript.exe corpus 83 (elastic 82, splunk 1)
field:"process_name" kind:wildcard