Detection rules › Elastic

Execution of a Windows Script File Written by a Suspicious Process

Time window
5m
Sequence by
user.id
Source
github.com/elastic/protections-artifacts

Identifies the execution of a script file written by a suspicious application. Script interpreters are often launched during exploitation of Office applications or from documents containing malicious macros.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies the execution of a script file written by a suspicious application. Script interpreters are often launched
during exploitation of Office applications or from documents containing malicious macros.
"""
id = "dc9c8c7c-f398-401f-804a-325570a5f167"
license = "Elastic License v2"
name = "Execution of a Windows Script File Written by a Suspicious Process"
os_list = ["windows"]
version = "1.0.34"

query = '''
sequence by user.id with maxspan=5m

 [file where event.action == "creation" and file.path : "C:\\*" and

   file.extension : ("hta", "vbs", "js", "wsf", "vbe", "jse") and not user.id : "S-1-5-18" and

   not (process.code_signature.subject_name :
            ("AUTO/MATE, INC.", "TeamViewer*", "KOBIL Systems GmbH", "Ratiborus MSFree Inc.",
             "Canon Electronics Inc.", "Johannes Schindelin", "Bomgar Corporation", "PFU LIMITED",
             "Learnpulse", "Azul Systems, Inc.") and
        process.code_signature.trusted == true) and
   not process.executable :
              ("?:\\ProgramData\\Microsoft\\VisualStudio\\Packages\\*.exe",
               "?:\\Program Files\\SWSetup\\SP100309\\Lexus FW Upgrade 0007.exe", 
               "?:\\Program Files (x86)\\Imprivata\\OneSign Agent\\x64\\ISXAgent.exe") and

   not (process.executable : "?:\\Users\\*\\AppData\\Roaming\\zozi-rpa-engine\\openjdk\\bin\\java.exe" and
        file.path : "C:\\Project\\*.vbs") and

   not file.path : "C:\\WINDOWS\\TEMP\\*.vbs" and

   not file.Ext.header_bytes :
                 ("0d0a272d2d2d2d2d2d2d2d2d2d2d2d2d", "272a2a2a2a2a2a2a2a2a2a2a2a2a2a2a",
                  "4966204e6f742049734f626a65637428", "4f6e204572726f7220526573756d6520",
                  "53657420554143203d20437265617465", "53006500740020006f0062006a004600",
                  "53006500740020005500410043002000", "4f4e204552524f5220524553554d4520",
                  "4372656174654f626a65637428225773") and

   (
     process.name : ("winword.exe", "excel.exe", "outlook.exe", "powerpnt.exe", "eqnedt32.exe", "fltldr.exe",
                     "mspub.exe", "msaccess.exe", "certutil.exe", "tar.exe", "CertReq.exe", "xcopy.exe", 
                     "cmd.exe", "powershell.exe", "mshta.exe", "curl.exe", "pwsh.exe", "rundll32.exe", 
                     "regsvr32.exe") or

     (process.code_signature.trusted == false or process.code_signature.exists == false) or

     process.executable : ("?:\\Users\\*\\AppData\\*", "?:\\ProgramData\\*", "?:\\Users\\Public\\*")
   )] as event0

 [process where event.action == "start" and
  process.name : ("wscript.exe", "mshta.exe") and
  startswith~(process.args, event0.file.path) and
  not (process.args : ("?:\\Program Files\\*", "?:\\Program Files (x86)\\*") and process.args_count <= 3) and
  not (process.name : "wscript.exe" and process.parent.name : "cmd.exe" and
       process.parent.command_line : ("*Desktop\\PROTECTAgentInstaller.bat*", "*cleanupSetup.vbs Shell_*.log*")) and
  not process.parent.executable :
                    ("?:\\Program Files (x86)\\Virus Chaser\\pcms\\patch\\_incomming_files\\KDB_Trellix_Agent_BG.sfx.exe",
                     "?:\\Program Files (x86)\\UPS\\CrossWare\\CrossWare.exe",
                     "?:\\Program Files\\UPS\\CrossWare\\CrossWare.exe",
                     "?:\\Program Files (x86)\\Common Files\\InstallShield\\Driver\\8\\Intel 32\\IDriver.exe") and
  not (process.parent.args : "-no_selfdeleter" and process.parent.args : "-IS_temp") and
  not (process.parent.args : "-removeonly" and process.parent.args : "-runfromtemp") and
  not (process.name : "wscript.exe" and process.parent.name : "cmd.exe" and
       process.parent.args : ("?:\\PROGRA~2\\Baxter\\*\\REGIST~1.BAT", "PrepStation\\registerCameraStand.bat", "?:\\Program Files (x86)\\Baxter\\*")) and
  not (process.parent.args : "http*://*:8282/dataloader/*" and process.args : "?:\\Windows\\TEMP\\Spiceworks\\spiceworks_upload.vbs") and
  not (process.parent.args : "C:\\XperCon\\_Xtra\\PDF_Rename\\pdf_rename.bat" and process.args : "C:\\XperCon\\_Xtra\\PDF_Rename\\transform.vbs") and
  not (process.parent.args : "C:\\CSM Infopath Templates\\Register CSM InfoPath Templates.exe" and process.args : "C:\\CSM Infopath Templates\\installAllTemplates.vbs") and
  not (process.parent.name : "cmd.exe" and process.parent.args : "%TEMP%\\Spiceworks\\*") and
  not (process.name : "mshta.exe" and process.parent.name : "mshta.exe"  and process.parent.args : "\\\\*\\netlogon\\ADSelfService_Enroll.hta") and
  not (process.parent.name : "JustWareSmartClient.exe" and process.executable : "C:\\Windows\\SysWOW64\\wscript.exe") and

  /* FP - contentACCESS (TECH-ARROW) Outlook email archiving add-in */
  not process.args : "?:\\Users\\*\\AppData\\Local\\Temp\\contentACCESSForm\\RunAction.vbs" and

  /* FP - domain login scripts dropping uacinstall.vbs via netlogon */
  not (process.parent.name : "cmd.exe" and process.parent.args : "\\\\*\\netlogon\\*" and
       process.args : "*\\uacinstall.vbs")
  ]
'''

min_endpoint_version = "8.4.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 1

[[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.001"
name = "PowerShell"
reference = "https://attack.mitre.org/techniques/T1059/001/"

[[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 = "T1218"
name = "System Binary Proxy Execution"
reference = "https://attack.mitre.org/techniques/T1218/"
[[threat.technique.subtechnique]]
id = "T1218.005"
name = "Mshta"
reference = "https://attack.mitre.org/techniques/T1218/005/"



[threat.tactic]
id = "TA0005"
name = "Defense Evasion"
reference = "https://attack.mitre.org/tactics/TA0005/"

[internal]
min_endpoint_version = "8.4.0"

Stages and Predicates

Ordered sequence: each step below must occur in order within 5m, correlated by user.id.

Stage 1: file

[file where event.action == "creation" and file.path : "C:\\*" and

   file.extension : ("hta", "vbs", "js", "wsf", "vbe", "jse") and not user.id : "S-1-5-18" and

   not (process.code_signature.subject_name :
            ("AUTO/MATE, INC.", "TeamViewer*", "KOBIL Systems GmbH", "Ratiborus MSFree Inc.",
             "Canon Electronics Inc.", "Johannes Schindelin", "Bomgar Corporation", "PFU LIMITED",
             "Learnpulse", "Azul Systems, Inc.") and
        process.code_signature.trusted == true) and
   not process.executable :
              ("?:\\ProgramData\\Microsoft\\VisualStudio\\Packages\\*.exe",
               "?:\\Program Files\\SWSetup\\SP100309\\Lexus FW Upgrade 0007.exe", 
               "?:\\Program Files (x86)\\Imprivata\\OneSign Agent\\x64\\ISXAgent.exe") and

   not (process.executable : "?:\\Users\\*\\AppData\\Roaming\\zozi-rpa-engine\\openjdk\\bin\\java.exe" and
        file.path : "C:\\Project\\*.vbs") and

   not file.path : "C:\\WINDOWS\\TEMP\\*.vbs" and

   not file.Ext.header_bytes :
                 ("0d0a272d2d2d2d2d2d2d2d2d2d2d2d2d", "272a2a2a2a2a2a2a2a2a2a2a2a2a2a2a",
                  "4966204e6f742049734f626a65637428", "4f6e204572726f7220526573756d6520",
                  "53657420554143203d20437265617465", "53006500740020006f0062006a004600",
                  "53006500740020005500410043002000", "4f4e204552524f5220524553554d4520",
                  "4372656174654f626a65637428225773") and

   (
     process.name : ("winword.exe", "excel.exe", "outlook.exe", "powerpnt.exe", "eqnedt32.exe", "fltldr.exe",
                     "mspub.exe", "msaccess.exe", "certutil.exe", "tar.exe", "CertReq.exe", "xcopy.exe", 
                     "cmd.exe", "powershell.exe", "mshta.exe", "curl.exe", "pwsh.exe", "rundll32.exe", 
                     "regsvr32.exe") or

     (process.code_signature.trusted == false or process.code_signature.exists == false) or

     process.executable : ("?:\\Users\\*\\AppData\\*", "?:\\ProgramData\\*", "?:\\Users\\Public\\*")
   )] as event0

Stage 2: process

[process where event.action == "start" and
  process.name : ("wscript.exe", "mshta.exe") and
  startswith~(process.args, event0.file.path) and
  not (process.args : ("?:\\Program Files\\*", "?:\\Program Files (x86)\\*") and process.args_count <= 3) and
  not (process.name : "wscript.exe" and process.parent.name : "cmd.exe" and
       process.parent.command_line : ("*Desktop\\PROTECTAgentInstaller.bat*", "*cleanupSetup.vbs Shell_*.log*")) and
  not process.parent.executable :
                    ("?:\\Program Files (x86)\\Virus Chaser\\pcms\\patch\\_incomming_files\\KDB_Trellix_Agent_BG.sfx.exe",
                     "?:\\Program Files (x86)\\UPS\\CrossWare\\CrossWare.exe",
                     "?:\\Program Files\\UPS\\CrossWare\\CrossWare.exe",
                     "?:\\Program Files (x86)\\Common Files\\InstallShield\\Driver\\8\\Intel 32\\IDriver.exe") and
  not (process.parent.args : "-no_selfdeleter" and process.parent.args : "-IS_temp") and
  not (process.parent.args : "-removeonly" and process.parent.args : "-runfromtemp") and
  not (process.name : "wscript.exe" and process.parent.name : "cmd.exe" and
       process.parent.args : ("?:\\PROGRA~2\\Baxter\\*\\REGIST~1.BAT", "PrepStation\\registerCameraStand.bat", "?:\\Program Files (x86)\\Baxter\\*")) and
  not (process.parent.args : "http*://*:8282/dataloader/*" and process.args : "?:\\Windows\\TEMP\\Spiceworks\\spiceworks_upload.vbs") and
  not (process.parent.args : "C:\\XperCon\\_Xtra\\PDF_Rename\\pdf_rename.bat" and process.args : "C:\\XperCon\\_Xtra\\PDF_Rename\\transform.vbs") and
  not (process.parent.args : "C:\\CSM Infopath Templates\\Register CSM InfoPath Templates.exe" and process.args : "C:\\CSM Infopath Templates\\installAllTemplates.vbs") and
  not (process.parent.name : "cmd.exe" and process.parent.args : "%TEMP%\\Spiceworks\\*") and
  not (process.name : "mshta.exe" and process.parent.name : "mshta.exe"  and process.parent.args : "\\\\*\\netlogon\\ADSelfService_Enroll.hta") and
  not (process.parent.name : "JustWareSmartClient.exe" and process.executable : "C:\\Windows\\SysWOW64\\wscript.exe") and
  not process.args : "?:\\Users\\*\\AppData\\Local\\Temp\\contentACCESSForm\\RunAction.vbs" and
  not (process.parent.name : "cmd.exe" and process.parent.args : "\\\\*\\netlogon\\*" and
       process.args : "*\\uacinstall.vbs")
  ]

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
file.pathwildcardC:\Project\*.vbsexcludes:file.path field:"file.path" value:"C:\Project\*.vbs"
process.executablewildcard?:\Users\*\AppData\Roaming\zozi-rpa-engine\openjdk\bin\java.exeexcludes:process.executable field:"process.executable" value:"?:\Users\*\AppData\Roaming\zozi-rpa-engine\openjdk\bin\java.exe"
process.code_signature.subject_namewildcardAUTO/MATE, INC., TeamViewer*, KOBIL Systems GmbH, Ratiborus MSFree Inc., Canon Electronics Inc., Johannes Schindelin, Bomgar Corporation, PFU LIMITED, Learnpulse, Azul Systems, Inc.excludes:process.code_signature.subject_name
process.code_signature.trustedeqtrueexcludes:process.code_signature.trusted field:"process.code_signature.trusted" value:"true"
file.Ext.header_byteseq0d0a272d2d2d2d2d2d2d2d2d2d2d2d2d, 272a2a2a2a2a2a2a2a2a2a2a2a2a2a2a, 4966204e6f742049734f626a65637428, 4f6e204572726f7220526573756d6520, 53657420554143203d20437265617465, 53006500740020006f0062006a004600, 53006500740020005500410043002000, 4f4e204552524f5220524553554d4520, 4372656174654f626a65637428225773excludes:file.Ext.header_bytes
file.pathwildcardC:\WINDOWS\TEMP\*.vbsexcludes:file.path field:"file.path" value:"C:\WINDOWS\TEMP\*.vbs"
process.executablewildcard?:\ProgramData\Microsoft\VisualStudio\Packages\*.exe, ?:\Program Files\SWSetup\SP100309\Lexus FW Upgrade 0007.exe, ?:\Program Files (x86)\Imprivata\OneSign Agent\x64\ISXAgent.exeexcludes:process.executable field:"process.executable" value:"?:\ProgramData\Microsoft\VisualStudio\Packages\*.exe" field:"process.executable" value:"?:\Program Files\SWSetup\SP100309\Lexus FW Upgrade 0007.exe" field:"process.executable" value:"?:\Program Files (x86)\Imprivata\OneSign Agent\x64\ISXAgent.exe"
user.ideqS-1-5-18excludes:user.id field:"user.id" value:"S-1-5-18"
process.argsends_with\uacinstall.vbsexcludes:process.args field:"process.args" value:"\uacinstall.vbs"
process.parent.argswildcard\\*\netlogon\*excludes:process.parent.args field:"process.parent.args" value:"\\*\netlogon\*"
process.parent.nameeqcmd.exeexcludes:process.parent.name field:"process.parent.name" value:"cmd.exe"
process.argseq?:\Windows\TEMP\Spiceworks\spiceworks_upload.vbsexcludes:process.args field:"process.args" value:"?:\Windows\TEMP\Spiceworks\spiceworks_upload.vbs"
process.parent.argswildcardhttp*://*:8282/dataloader/*excludes:process.parent.args field:"process.parent.args" value:"http*://*:8282/dataloader/*"
process.argseqC:\CSM Infopath Templates\installAllTemplates.vbsexcludes:process.args field:"process.args" value:"C:\CSM Infopath Templates\installAllTemplates.vbs"
process.parent.argseqC:\CSM Infopath Templates\Register CSM InfoPath Templates.exeexcludes:process.parent.args field:"process.parent.args" value:"C:\CSM Infopath Templates\Register CSM InfoPath Templates.exe"
process.argseqC:\XperCon\_Xtra\PDF_Rename\transform.vbsexcludes:process.args field:"process.args" value:"C:\XperCon\_Xtra\PDF_Rename\transform.vbs"
process.parent.argseqC:\XperCon\_Xtra\PDF_Rename\pdf_rename.batexcludes:process.parent.args field:"process.parent.args" value:"C:\XperCon\_Xtra\PDF_Rename\pdf_rename.bat"
process.argsstarts_with?:\Program Files\, ?:\Program Files (x86)\excludes:process.args field:"process.args" value:"?:\Program Files\" field:"process.args" value:"?:\Program Files (x86)\"
process.args_countle3excludes:process.args_count field:"process.args_count" value:"3"
process.executableeqC:\Windows\SysWOW64\wscript.exeexcludes:process.executable field:"process.executable" value:"C:\Windows\SysWOW64\wscript.exe"
process.parent.nameeqJustWareSmartClient.exeexcludes:process.parent.name field:"process.parent.name" value:"JustWareSmartClient.exe"
process.nameeqmshta.exeexcludes:process.name field:"process.name" value:"mshta.exe"
process.parent.argswildcard\\*\netlogon\ADSelfService_Enroll.htaexcludes:process.parent.args field:"process.parent.args" value:"\\*\netlogon\ADSelfService_Enroll.hta"
process.parent.nameeqmshta.exeexcludes:process.parent.name field:"process.parent.name" value:"mshta.exe"
process.nameeqwscript.exeexcludes:process.name field:"process.name" value:"wscript.exe"
process.parent.argswildcard?:\PROGRA~2\Baxter\*\REGIST~1.BAT, PrepStation\registerCameraStand.bat, ?:\Program Files (x86)\Baxter\*excludes:process.parent.args field:"process.parent.args" value:"?:\PROGRA~2\Baxter\*\REGIST~1.BAT" field:"process.parent.args" value:"PrepStation\registerCameraStand.bat" field:"process.parent.args" value:"?:\Program Files (x86)\Baxter\*"
process.parent.command_linewildcard*Desktop\PROTECTAgentInstaller.bat*, *cleanupSetup.vbs Shell_*.log*excludes:process.parent.command_line field:"process.parent.command_line" value:"*Desktop\PROTECTAgentInstaller.bat*" field:"process.parent.command_line" value:"*cleanupSetup.vbs Shell_*.log*"
process.parent.argseq-IS_tempexcludes:process.parent.args field:"process.parent.args" value:"-IS_temp"
process.parent.argseq-no_selfdeleterexcludes:process.parent.args field:"process.parent.args" value:"-no_selfdeleter"
process.parent.argseq-removeonlyexcludes:process.parent.args field:"process.parent.args" value:"-removeonly"
process.parent.argseq-runfromtempexcludes:process.parent.args field:"process.parent.args" value:"-runfromtemp"
process.parent.argsstarts_with%TEMP%\Spiceworks\excludes:process.parent.args field:"process.parent.args" value:"%TEMP%\Spiceworks\"
process.argswildcard?:\Users\*\AppData\Local\Temp\contentACCESSForm\RunAction.vbsexcludes:process.args field:"process.args" value:"?:\Users\*\AppData\Local\Temp\contentACCESSForm\RunAction.vbs"
process.parent.executableeq?:\Program Files (x86)\Virus Chaser\pcms\patch\_incomming_files\KDB_Trellix_Agent_BG.sfx.exe, ?:\Program Files (x86)\UPS\CrossWare\CrossWare.exe, ?:\Program Files\UPS\CrossWare\CrossWare.exe, ?:\Program Files (x86)\Common Files\InstallShield\Driver\8\Intel 32\IDriver.exeexcludes:process.parent.executable

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • creation corpus 58 (elastic 58)
  • start corpus 391 (elastic 391)
field:"EventType" kind:eq
file.extensionwildcard
  • hta corpus 20 (elastic 20)
  • js corpus 23 (elastic 23)
  • jse corpus 18 (elastic 18)
  • vbe corpus 18 (elastic 18)
  • vbs corpus 19 (elastic 19)
  • wsf corpus 10 (elastic 10)
field:"file.extension" kind:wildcard
file.pathwildcard
  • C:\* corpus 2 (elastic 2)
field:"TargetFilename" kind:wildcard value:"C:\*"
process.argsstarts_with
  • event0.file.path (field reference) corpus 2 (elastic 2)
field:"process.args" kind:starts_with value:"event0.file.path"
process.code_signature.existseq
  • false transforms: boolean corpus 119 (elastic 119)
field:"process.code_signature.exists" kind:eq value:"false"
process.code_signature.trustedeq
  • false transforms: boolean corpus 115 (elastic 115)
field:"process.code_signature.trusted" kind:eq value:"false"
process.executablewildcard
  • ?:\ProgramData\* corpus 17 (elastic 17)
  • ?:\Users\*\AppData\* corpus 12 (elastic 12)
  • ?:\Users\Public\* corpus 4 (elastic 4)
field:"Image" kind:wildcard
process.namewildcard
  • CertReq.exe corpus 20 (elastic 20)
  • certutil.exe corpus 44 (elastic 38, splunk 6)
  • cmd.exe corpus 121 (elastic 92, splunk 29)
  • curl.exe corpus 34 (elastic 31, splunk 3)
  • eqnedt32.exe corpus 8 (elastic 8)
  • excel.exe corpus 34 (elastic 34)
  • fltldr.exe corpus 8 (elastic 8)
  • msaccess.exe corpus 19 (elastic 19)
  • mshta.exe corpus 84 (elastic 79, splunk 5)
  • mspub.exe corpus 15 (elastic 15)
  • outlook.exe corpus 9 (elastic 7, splunk 2)
  • powerpnt.exe corpus 31 (elastic 31)
  • powershell.exe corpus 184 (elastic 140, splunk 44)
  • pwsh.exe corpus 77 (elastic 48, splunk 29)
  • regsvr32.exe corpus 73 (elastic 68, splunk 5)
  • rundll32.exe corpus 126 (elastic 100, splunk 26)
  • tar.exe corpus 6 (elastic 6)
  • winword.exe corpus 35 (elastic 35)
  • wscript.exe corpus 83 (elastic 82, splunk 1)
  • xcopy.exe corpus 10 (elastic 10)
field:"process_name" kind:wildcard