Detection rules › Elastic
Suspicious Image Load via Windows Scripts
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.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
dll.code_signature.status | eq | errorChaining, errorExpired | excludes:dll.code_signature.status field:"dll.code_signature.status" value:"errorChaining" field:"dll.code_signature.status" value:"errorExpired" |
dll.path | starts_with | ?:\Windows\assembly\NativeImages, ?:\Windows\System32\, ?:\Windows\SysWOW64\, ?:\Program Files\, ?:\Program Files (x86)\, ?:\Windows\WinSxS\ | excludes:dll.path |
process.name | starts_with | dll.name | excludes:process.name field:"process.name" value:"dll.name" |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
dll.Ext.relative_file_creation_time | le |
| field:"dll.Ext.relative_file_creation_time" kind:le value:"500" |
dll.code_signature.exists | eq |
| field:"dll.code_signature.exists" kind:eq value:"false" |
dll.code_signature.trusted | eq |
| field:"dll.code_signature.trusted" kind:eq value:"false" |
process.name | wildcard |
| field:"process_name" kind:wildcard |