Detection rules › Elastic

Script Execution via Microsoft HTML Application

Source
github.com/elastic/protections-artifacts

Identifies the execution of scripts via HTML applications using Windows utilities rundll32.exe or mshta.exe. Adversaries may bypass process and/or signature-based defenses by proxying execution of malicious content with signed binaries.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies the execution of scripts via HTML applications using Windows utilities rundll32.exe or mshta.exe. Adversaries
may bypass process and/or signature-based defenses by proxying execution of malicious content with signed binaries.
"""
id = "f0630213-c4c4-4898-9514-746395eb9962"
license = "Elastic License v2"
name = "Script Execution via Microsoft HTML Application"
os_list = ["windows"]
version = "1.0.38"

query = '''
process where event.action == "start" and
 (process.name : ("rundll32.exe", "mshta.exe") or
  process.pe.original_file_name in ("MSHTA.EXE", "RUNDLL32.EXE")) and
  (
     (process.command_line :
        (
        "*script*eval(*",
         "*script*GetObject*",
         "*.regread(*",
         "*WScript.Shell*",
         "*.run(*",
         "*).Exec()*",
         "*mshta*http*",
         "*mshtml*RunHTMLApplication*",
         "*mshtml*,#135*",
         "*StrReverse*",
         "*.RegWrite*",
         /* Issue #379 */
         "*window.close(*",
         "* Chr(*"
         )
     /* FPs observed in telemetry */
     and not process.parent.executable :
                  ("?:\\Program Files (x86)\\Citrix\\System32\\wfshell.exe",
                   "?:\\Program Files (x86)\\Microsoft Office\\Office*\\MSACCESS.EXE",
                   "?:\\Program Files\\Quokka.Works GTInstaller\\GTInstaller.exe")
     and not (process.name : "mshta.exe" and process.parent.name : "cscript.exe" and process.parent.command_line : "*GTInstaller.vbs*")
     ) or
    /* Issue #379 */
    (process.pe.original_file_name : "mshta.exe" and
     not process.command_line : ("*.hta*", "*.htm*", "-Embedding") and process.args_count >=2) or

     /* Execution of HTA file downloaded from the internet */
     (process.pe.original_file_name : "mshta.exe" and process.command_line : "*\\Users\\*\\Downloads\\*.hta*") or

     /* Execution of HTA file from archive */
     (process.pe.original_file_name : "mshta.exe" and
      process.args : ("?:\\Users\\*\\Temp\\7z*", "?:\\Users\\*\\Temp\\Rar$*", "?:\\Users\\*\\Temp\\Temp?_*", "?:\\Users\\*\\Temp\\BNZ.*")) or

     /* Execution of HTA file from mounted ISO files */
     (process.pe.original_file_name : "mshta.exe" and
      process.parent.name : ("explorer.exe", "cmd.exe", "powershell.exe") and process.working_directory : "?:\\") or

     /* Webdav */
     (process.name : "mshta.exe" and process.args : "\\\\*@*\\*")
   ) and

  /* FPs */
  not (process.parent.executable : "C:\\Windows\\SysWOW64\\runonce.exe" and
       process.args : "\"& 'C:\\System.sav\\util\\HpseuHostLauncher.ps1'\"\", 0 : window.close)") and
  not (process.name : "mshta.exe" and
       process.args : ("*\\Support\\AzureVirtualDesktop\\ImageSources\\DisableTeamsAutoStart.ps1*",
                       "*C:\\Program Files (x86)\\combit\\*\\ServicePackNotification.ps1*")) and
  not process.command_line :  ("*encodeURIComponent*", "*.Popup*", "*C:\\PROGRA~2*", "*\\Downloads\\download*.hta*", "*Readme_he-IL.hta*", "*cisco-secure-client-win*") and
  not (process.parent.name : "cmd.exe" and process.name : "mshta.exe" and process.args : "D:\\start.hta") and
  not (process.name : "mshta.exe" and process.parent.executable : "C:\\Windows\\SysWOW64\\cmd.exe" and
       process.parent.args : "C:\\HP Universal Print Driver\\*\\Installer\\Install.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 = "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.technique.subtechnique]]
id = "T1218.011"
name = "Rundll32"
reference = "https://attack.mitre.org/techniques/T1218/011/"



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

[internal]
min_endpoint_version = "7.15.0"

Stages and Predicates

Stage 1: process

process where event.action == "start" and
 (process.name : ("rundll32.exe", "mshta.exe") or
  process.pe.original_file_name in ("MSHTA.EXE", "RUNDLL32.EXE")) and
  (
     (process.command_line :
        (
        "*script*eval(*",
         "*script*GetObject*",
         "*.regread(*",
         "*WScript.Shell*",
         "*.run(*",
         "*).Exec()*",
         "*mshta*http*",
         "*mshtml*RunHTMLApplication*",
         "*mshtml*,#135*",
         "*StrReverse*",
         "*.RegWrite*",
         "*window.close(*",
         "* Chr(*"
         )
     and not process.parent.executable :
                  ("?:\\Program Files (x86)\\Citrix\\System32\\wfshell.exe",
                   "?:\\Program Files (x86)\\Microsoft Office\\Office*\\MSACCESS.EXE",
                   "?:\\Program Files\\Quokka.Works GTInstaller\\GTInstaller.exe")
     and not (process.name : "mshta.exe" and process.parent.name : "cscript.exe" and process.parent.command_line : "*GTInstaller.vbs*")
     ) or
    (process.pe.original_file_name : "mshta.exe" and
     not process.command_line : ("*.hta*", "*.htm*", "-Embedding") and process.args_count >=2) or
     (process.pe.original_file_name : "mshta.exe" and process.command_line : "*\\Users\\*\\Downloads\\*.hta*") or
     (process.pe.original_file_name : "mshta.exe" and
      process.args : ("?:\\Users\\*\\Temp\\7z*", "?:\\Users\\*\\Temp\\Rar$*", "?:\\Users\\*\\Temp\\Temp?_*", "?:\\Users\\*\\Temp\\BNZ.*")) or
     (process.pe.original_file_name : "mshta.exe" and
      process.parent.name : ("explorer.exe", "cmd.exe", "powershell.exe") and process.working_directory : "?:\\") or
     (process.name : "mshta.exe" and process.args : "\\\\*@*\\*")
   ) and
  not (process.parent.executable : "C:\\Windows\\SysWOW64\\runonce.exe" and
       process.args : "\"& 'C:\\System.sav\\util\\HpseuHostLauncher.ps1'\"\", 0 : window.close)") and
  not (process.name : "mshta.exe" and
       process.args : ("*\\Support\\AzureVirtualDesktop\\ImageSources\\DisableTeamsAutoStart.ps1*",
                       "*C:\\Program Files (x86)\\combit\\*\\ServicePackNotification.ps1*")) and
  not process.command_line :  ("*encodeURIComponent*", "*.Popup*", "*C:\\PROGRA~2*", "*\\Downloads\\download*.hta*", "*Readme_he-IL.hta*", "*cisco-secure-client-win*") and
  not (process.parent.name : "cmd.exe" and process.name : "mshta.exe" and process.args : "D:\\start.hta") and
  not (process.name : "mshta.exe" and process.parent.executable : "C:\\Windows\\SysWOW64\\cmd.exe" and
       process.parent.args : "C:\\HP Universal Print Driver\\*\\Installer\\Install.bat")

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.argseqD:\start.htaexcludes:process.args field:"process.args" value:"D:\start.hta"
process.nameeqmshta.exeexcludes:process.name field:"process.name" value:"mshta.exe"
process.parent.nameeqcmd.exeexcludes:process.parent.name field:"process.parent.name" value:"cmd.exe"
process.argseq"& 'C:\System.sav\util\HpseuHostLauncher.ps1'"", 0 : window.close)excludes:process.args
process.parent.executableeqC:\Windows\SysWOW64\runonce.exeexcludes:process.parent.executable field:"process.parent.executable" value:"C:\Windows\SysWOW64\runonce.exe"
process.argswildcard*\Support\AzureVirtualDesktop\ImageSources\DisableTeamsAutoStart.ps1*, *C:\Program Files (x86)\combit\*\ServicePackNotification.ps1*excludes:process.args field:"process.args" value:"*\Support\AzureVirtualDesktop\ImageSources\DisableTeamsAutoStart.ps1*" field:"process.args" value:"*C:\Program Files (x86)\combit\*\ServicePackNotification.ps1*"
process.parent.argswildcardC:\HP Universal Print Driver\*\Installer\Install.batexcludes:process.parent.args field:"process.parent.args" value:"C:\HP Universal Print Driver\*\Installer\Install.bat"
process.parent.executableeqC:\Windows\SysWOW64\cmd.exeexcludes:process.parent.executable field:"process.parent.executable" value:"C:\Windows\SysWOW64\cmd.exe"
process.command_linewildcard*encodeURIComponent*, *.Popup*, *C:\PROGRA~2*, *\Downloads\download*.hta*, *Readme_he-IL.hta*, *cisco-secure-client-win*excludes:process.command_line

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
  • ?:\Users\*\Temp\7z* corpus 4 (elastic 4)
  • ?:\Users\*\Temp\BNZ.* corpus 3 (elastic 3)
  • ?:\Users\*\Temp\Rar$* corpus 4 (elastic 4)
  • ?:\Users\*\Temp\Temp?_* corpus 4 (elastic 4)
  • \\*@*\* corpus 3 (elastic 3)
field:"process.args" kind:wildcard
process.args_countge
  • 2 transforms: number corpus 18 (elastic 18)
field:"process.args_count" kind:ge value:"2"
process.command_linewildcard
  • * Chr(*
  • *).Exec()*
  • *.RegWrite*
  • *.regread(*
  • *.run(*
  • *StrReverse*
  • *WScript.Shell*
  • *\Users\*\Downloads\*.hta* corpus 2 (elastic 2)
  • *mshta*http* corpus 2 (elastic 2)
  • *mshtml*,#135* corpus 2 (elastic 2)
  • *mshtml*RunHTMLApplication* corpus 2 (elastic 2)
  • *script*GetObject* corpus 2 (elastic 2)
  • *script*eval(* corpus 2 (elastic 2)
  • *window.close(*
field:"CommandLine" kind:wildcard
process.namewildcard
  • mshta.exe corpus 84 (elastic 79, splunk 5)
  • rundll32.exe corpus 126 (elastic 100, splunk 26)
field:"process_name" kind:wildcard
process.parent.namewildcard
  • cmd.exe corpus 36 (elastic 31, splunk 4, kusto 1)
  • explorer.exe corpus 51 (elastic 50, splunk 1)
  • powershell.exe corpus 39 (elastic 36, kusto 2, splunk 1)
field:"parent_process_name" kind:wildcard
process.pe.original_file_namein
  • MSHTA.EXE corpus 40 (elastic 21, sigma 13, splunk 6)
  • RUNDLL32.EXE corpus 78 (sigma 35, elastic 22, splunk 21)
field:"OriginalFileName" kind:in
process.pe.original_file_namewildcard
  • mshta.exe corpus 40 (elastic 21, sigma 13, splunk 6)
field:"OriginalFileName" kind:wildcard value:"mshta.exe"
process.working_directorywildcard
  • ?:\ corpus 8 (elastic 8)
field:"CurrentDirectory" kind:wildcard value:"?:\"