function Download(url, path, verbose) {
  if (verbose) {
    WScript.StdOut.Write(" *  GET " + url + "...");
  }
  try {
    xml_http = new ActiveXObject("MSXML2.ServerXMLHTTP");
  } catch (e) {
    WScript.StdOut.WriteLine("[-] XMLHTTP " + new Number(e.number).toHex() +
        ": Cannot create Active-X object (" + e.description) + ").";
    WScript.Quit(1);
  }
  try {
    xml_http.open("GET", url, false);
  } catch (e) {
    WScript.StdOut.WriteLine("[-] XMLHTTP " + new Number(e.number).toHex() +
        ": invalid URL.");
    WScript.Quit(1);
  }

  var response_body = null;
  var size_description = "?";
  var file_size;
  try {
    xml_http.send(null);
    if (xml_http.status != 200) {
      WScript.StdOut.WriteLine("[-] HTTP " + xml_http.status + " " +
          xml_http.statusText);
      WScript.Quit(1);
    }
    response_body = xml_http.responseBody;
    size_description = xml_http.getResponseHeader("Content-Length");
    if (size_description != "") {
      file_size = parseInt(size_description)
      size_description = file_size.toBytes();
    } else {
      try {
        file_size = new Number(xml_http.responseText.length)
        size_description = file_size.toBytes();
      } catch(e) {
        size_description = "unknown size";
      }
    }
  } catch (e) {
    WScript.StdOut.WriteLine("[-] XMLHTTP " + new Number(e.number).toHex() +
        ": Cannot make HTTP request (" + e.description) + ")";
    WScript.Quit(1);
  }

  if (verbose) {
    WScript.StdOut.WriteLine("ok (" + size_description + ").");
    WScript.StdOut.Write(" *  Save " + path + "...");
  }

  try {
    var adodb_stream = new ActiveXObject("ADODB.Stream");
    adodb_stream.Mode = 3; // ReadWrite
    adodb_stream.Type = 1; // 1= Binary
    adodb_stream.Open(); // Open the stream
    adodb_stream.Write(response_body); // Write the data
    adodb_stream.SaveToFile(path, 2); // Save to our destination
    adodb_stream.Close();
  } catch(e) {
    WScript.StdOut.WriteLine("[-] ADODB.Stream " + new Number(
        e.number).toHex() + ": Cannot save file (" + e.description + ")");
    WScript.Quit(1);
  }
  if (typeof(file_size) != undefined) {
    var file_system_object = WScript.CreateObject("Scripting.FileSystemObject")
    var file = file_system_object.GetFile(path)
    if (file.Size < file_size) {
      WScript.StdOut.WriteLine("[-] File only partially downloaded.");
      WScript.Quit(1);
    }
  }
  if (verbose) {
    WScript.StdOut.WriteLine("ok.");
  }
}
// found in the LICENSE file.
found in the LICENSE file.
found in the LICENSE file .
function Download(url, path, verbose) {
  if (verbose) {
    WScript.StdOut.Write(" *  GET " + url + "...");
  }
  try {
    xml_http = new ActiveXObject("MSXML2.ServerXMLHTTP");
  } catch (e) {
    WScript.StdOut.WriteLine("[-] XMLHTTP " + new Number(e.number).toHex() +
        ": Cannot create Active-X object (" + e.description) + ").";
    WScript.Quit(1);
  }
  try {
    xml_http.open("GET", url, false);
  } catch (e) {
    WScript.StdOut.WriteLine("[-] XMLHTTP " + new Number(e.number).toHex() +
        ": invalid URL.");
    WScript.Quit(1);
  }
  var response_body = null;
  var size_description = "?";
  var file_size;
  try {
    xml_http.send(null);
    if (xml_http.status != 200) {
      WScript.StdOut.WriteLine("[-] HTTP " + xml_http.status + " " +
          xml_http.statusText);
      WScript.Quit(1);
    }
    response_body = xml_http.responseBody;
    size_description = xml_http.getResponseHeader("Content-Length");
    if (size_description != "") {
      file_size = parseInt(size_description)
      size_description = file_size.toBytes();
    } else {
      try {
        file_size = new Number(xml_http.responseText.length)
        size_description = file_size.toBytes();
      } catch(e) {
        size_description = "unknown size";
      }
    }
  } catch (e) {
    WScript.StdOut.WriteLine("[-] XMLHTTP " + new Number(e.number).toHex() +
        ": Cannot make HTTP request (" + e.description) + ")";
    WScript.Quit(1);
  }
  if (verbose) {
    WScript.StdOut.WriteLine("ok (" + size_description + ").");
    WScript.StdOut.Write(" *  Save " + path + "...");
  }
  try {
    var adodb_stream = new ActiveXObject("ADODB.Stream");
    adodb_stream.Mode = 3; 
    adodb_stream.Type = 1; 
    adodb_stream.Open(); 
    adodb_stream.Write(response_body); 
    adodb_stream.SaveToFile(path, 2); 
    adodb_stream.Close();
  } catch(e) {
    WScript.StdOut.WriteLine("[-] ADODB.Stream " + new Number(
        e.number).toHex() + ": Cannot save file (" + e.description + ")");
    WScript.Quit(1);
  }
  if (typeof(file_size) != undefined) {
    var file_system_object = WScript.CreateObject("Scripting.FileSystemObject")
    var file = file_system_object.GetFile(path)
    if (file.Size < file_size) {
      WScript.StdOut.WriteLine("[-] File only partially downloaded.");
      WScript.Quit(1);
    }
  }
  if (verbose) {
    WScript.StdOut.WriteLine("ok.");
  }
}
function Download ( url , path , verbose ) { if ( verbose ) { WScript . StdOut . Write ( " *  GET " + url + "..." ) ; } try { xml_http = new ActiveXObject ( "MSXML2.ServerXMLHTTP" ) ; } catch ( e ) { WScript . StdOut . WriteLine ( "[-] XMLHTTP " + new Number ( e . number ) . toHex ( ) + ": Cannot create Active-X object (" + e . description ) + ")." ; WScript . Quit ( 1 ) ; } try { xml_http . open ( "GET" , url , false ) ; } catch ( e ) { WScript . StdOut . WriteLine ( "[-] XMLHTTP " + new Number ( e . number ) . toHex ( ) + ": invalid URL." ) ; WScript . Quit ( 1 ) ; } var response_body = null ; var size_description = "?" ; var file_size ; try { xml_http . send ( null ) ; if ( xml_http . status != 200 ) { WScript . StdOut . WriteLine ( "[-] HTTP " + xml_http . status + " " + xml_http . statusText ) ; WScript . Quit ( 1 ) ; } response_body = xml_http . responseBody ; size_description = xml_http . getResponseHeader ( "Content-Length" ) ; if ( size_description != "" ) { file_size = parseInt ( size_description ) size_description = file_size . toBytes ( ) ; } else { try { file_size = new Number ( xml_http . responseText . length ) size_description = file_size . toBytes ( ) ; } catch ( e ) { size_description = "unknown size" ; } } } catch ( e ) { WScript . StdOut . WriteLine ( "[-] XMLHTTP " + new Number ( e . number ) . toHex ( ) + ": Cannot make HTTP request (" + e . description ) + ")" ; WScript . Quit ( 1 ) ; } if ( verbose ) { WScript . StdOut . WriteLine ( "ok (" + size_description + ")." ) ; WScript . StdOut . Write ( " *  Save " + path + "..." ) ; } try { var adodb_stream = new ActiveXObject ( "ADODB.Stream" ) ; adodb_stream . Mode = 3 ; adodb_stream . Type = 1 ; adodb_stream . Open ( ) ; adodb_stream . Write ( response_body ) ; adodb_stream . SaveToFile ( path , 2 ) ; adodb_stream . Close ( ) ; } catch ( e ) { WScript . StdOut . WriteLine ( "[-] ADODB.Stream " + new Number ( e . number ) . toHex ( ) + ": Cannot save file (" + e . description + ")" ) ; WScript . Quit ( 1 ) ; } if ( typeof ( file_size ) != undefined ) { var file_system_object = WScript . CreateObject ( "Scripting.FileSystemObject" ) var file = file_system_object . GetFile ( path ) if ( file . Size < file_size ) { WScript . StdOut . WriteLine ( "[-] File only partially downloaded." ) ; WScript . Quit ( 1 ) ; } } if ( verbose ) { WScript . StdOut . WriteLine ( "ok." ) ; } }
found in the LICENSE file.
found in the LICENSE file .
// ReadWrite // 1= Binary // Open the stream // Write the data // Save to our destination