Thursday, December 16, 2010

Using an HTA to launch an .exe (be very afraid)


Turns out you can script a .HTA to launch just about anything. Which likely is why even the BPOS site for my RnD project blocks saving them by default.
The example below will launch an executable with a button click. One use I am considering using this for is to launch some of my legacy .exe code inside of a Share Point Web Part.
Of course if I allow access to HTA's on a production server I am just begging for the script-kiddies to turn my life into a living hell. But if I can get it into a Web Part that cannot be modified expect by me it might be worth trying.
Meanwhile here is the launcher bits for running remote desktop:
'<'INPUT style="background-color:transparent; width:160;height:25"
TYPE="button" VALUE="Terminal Svcs" ID="essctermsvcs">

essctermsvcs.onclick = function runtermsvcs()
{
var shell = new ActiveXObject("WScript.shell");
if (shell)
{
shell.run("mstsc.exe");
}
else
{
alert("Terminal Services Not available");
}
}

No comments: