Detection rules › Elastic

Execution of a Windows Script with Unusual File Extension

Source
github.com/elastic/protections-artifacts

Identifies the execution of a script with an unusual file extension by Windows Script Host processes (cscript or wscript).

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies the execution of a script with an unusual file extension by Windows Script Host processes (cscript or
wscript).
"""
id = "b76c0a04-b504-4a2f-a0cf-b4175a2f3eea"
license = "Elastic License v2"
name = "Execution of a Windows Script with Unusual File Extension"
os_list = ["windows"]
version = "1.0.36"

query = '''
process where event.action == "start" and
 (process.pe.original_file_name :"wscript.exe" or process.name : "wscript.exe") and process.parent.name != null and
 process.args : ("-e:*", "/e:*", "//e:*") and
 not process.command_line : ("*.js*", "*.vb*", "*.wsf*", "*.wsh*", "*.wsc*", "*.tmp*") and
 /* Issue #286 */
 not process.parent.executable : ("?:\\Program Files\\*.exe", "?:\\Program Files (x86)\\*.exe") and 
 not process.command_line : ("*:\\Program Files\\*", "*:\\Program Files (x86)\\*", "*\\Windows\\system32\\spool\\DRIVERS\\*") and
 not (process.name : "cscript.exe" and process.args : "C:\\PGM_TC~1\\DHL_FR~1\\xls2csv.bat") and
 not (process.args : "\\\\*" and process.args_count >= 3) and
 not (process.args : "/mts/wav/adf" and process.args : "/emf") and
 not (process.parent.args : "D:\\*.cmd" and process.args : "https://app.*:444/api/Banner") and
 not (process.parent.name : "cmd.exe" and process.parent.command_line : ("\"C:\\windows\\system32\\cmd.exe\" ", "cmd ")) and
 not (process.parent.name : "cmd.exe" and
       process.parent.args :
            ("C:\\ProgramData\\NinjaRMMAgent\\scripting\\customscript_gen_?.bat-ninjascript.bat",
             "C:\\Storage\\VisualStudioProjects\\connect_wise_script\\install_speerity.bat",
             "C:\\PGM_TC~1\\DHL_FR~1\\xls2csv.bat",
             "C:\\MBS\\UTIL\\repl.bat",
             "C:\\MBS\\UTIL\\PBSCOVER.BAT",
             "M:\\sendkeys.bat Mayer",
             "F:\\wamp64\\www\\centralstores\\cronjobs\\*.bat"))
'''

min_endpoint_version = "7.15.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/"

[internal]
min_endpoint_version = "7.15.0"

Stages and Predicates

Stage 1: process

process where event.action == "start" and
 (process.pe.original_file_name :"wscript.exe" or process.name : "wscript.exe") and process.parent.name != null and
 process.args : ("-e:*", "/e:*", "//e:*") and
 not process.command_line : ("*.js*", "*.vb*", "*.wsf*", "*.wsh*", "*.wsc*", "*.tmp*") and
 not process.parent.executable : ("?:\\Program Files\\*.exe", "?:\\Program Files (x86)\\*.exe") and
 not process.command_line : ("*:\\Program Files\\*", "*:\\Program Files (x86)\\*", "*\\Windows\\system32\\spool\\DRIVERS\\*") and
 not (process.name : "cscript.exe" and process.args : "C:\\PGM_TC~1\\DHL_FR~1\\xls2csv.bat") and
 not (process.args : "\\\\*" and process.args_count >= 3) and
 not (process.args : "/mts/wav/adf" and process.args : "/emf") and
 not (process.parent.args : "D:\\*.cmd" and process.args : "https://app.*:444/api/Banner") and
 not (process.parent.name : "cmd.exe" and process.parent.command_line : ("\"C:\\windows\\system32\\cmd.exe\" ", "cmd ")) and
 not (process.parent.name : "cmd.exe" and
       process.parent.args :
            ("C:\\ProgramData\\NinjaRMMAgent\\scripting\\customscript_gen_?.bat-ninjascript.bat",
             "C:\\Storage\\VisualStudioProjects\\connect_wise_script\\install_speerity.bat",
             "C:\\PGM_TC~1\\DHL_FR~1\\xls2csv.bat",
             "C:\\MBS\\UTIL\\repl.bat",
             "C:\\MBS\\UTIL\\PBSCOVER.BAT",
             "M:\\sendkeys.bat Mayer",
             "F:\\wamp64\\www\\centralstores\\cronjobs\\*.bat"))

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.argseq/emfexcludes:process.args field:"process.args" value:"/emf"
process.argseq/mts/wav/adfexcludes:process.args field:"process.args" value:"/mts/wav/adf"
process.argseqC:\PGM_TC~1\DHL_FR~1\xls2csv.batexcludes:process.args field:"process.args" value:"C:\PGM_TC~1\DHL_FR~1\xls2csv.bat"
process.nameeqcscript.exeexcludes:process.name field:"process.name" value:"cscript.exe"
process.argsstarts_with\\excludes:process.args field:"process.args" value:"\\"
process.args_countge3excludes:process.args_count field:"process.args_count" value:"3"
process.argswildcardhttps://app.*:444/api/Bannerexcludes:process.args field:"process.args" value:"https://app.*:444/api/Banner"
process.parent.argswildcardD:\*.cmdexcludes:process.parent.args field:"process.parent.args" value:"D:\*.cmd"
process.parent.argswildcardC:\ProgramData\NinjaRMMAgent\scripting\customscript_gen_?.bat-ninjascript.bat, C:\Storage\VisualStudioProjects\connect_wise_script\install_speerity.bat, C:\PGM_TC~1\DHL_FR~1\xls2csv.bat, C:\MBS\UTIL\repl.bat, C:\MBS\UTIL\PBSCOVER.BAT, M:\sendkeys.bat Mayer, F:\wamp64\www\centralstores\cronjobs\*.batexcludes:process.parent.args
process.parent.nameeqcmd.exeexcludes:process.parent.name field:"process.parent.name" value:"cmd.exe"
process.parent.command_lineeq"C:\windows\system32\cmd.exe" , cmd excludes:process.parent.command_line
process.command_linematch.js, .vb, .wsf, .wsh, .wsc, .tmpexcludes:process.command_line
process.command_linematch:\Program Files\, :\Program Files (x86)\, \Windows\system32\spool\DRIVERS\excludes:process.command_line field:"process.command_line" value:":\Program Files\" field:"process.command_line" value:":\Program Files (x86)\" field:"process.command_line" value:"\Windows\system32\spool\DRIVERS\"
process.parent.executablewildcard?:\Program Files\*.exe, ?:\Program Files (x86)\*.exeexcludes:process.parent.executable field:"process.parent.executable" value:"?:\Program Files\*.exe" field:"process.parent.executable" value:"?:\Program Files (x86)\*.exe"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • start corpus 391 (elastic 391)
field:"EventType" kind:eq value:"start"
process.argswildcard
  • -e:*
  • //e:*
  • /e:*
field:"process.args" kind:wildcard
process.namewildcard
  • wscript.exe corpus 83 (elastic 82, splunk 1)
field:"process_name" kind:wildcard value:"wscript.exe"
process.parent.nameis_not_null
  • (no value, null check)
field:"parent_process_name" kind:is_not_null
process.pe.original_file_namewildcard
  • wscript.exe corpus 38 (elastic 21, sigma 17)
field:"OriginalFileName" kind:wildcard value:"wscript.exe"