Programming languages such as Python, PHP, Perl, and Ruby are commonly available in Linux distributions but can also be installed on Windows. We can use on Windows default applications, such as cscript and mshta, to execute JavaScript or VBScript code.
The following JavaScript code is based on this post, and we can download a file using it. We'll create a file called wget.js and save the following content:
var WinHttpReq =newActiveXObject("WinHttp.WinHttpRequest.5.1");WinHttpReq.Open("GET",WScript.Arguments(0),/*async=*/false);WinHttpReq.Send();BinStream =newActiveXObject("ADODB.Stream");BinStream.Type =1;BinStream.Open();BinStream.Write(WinHttpReq.ResponseBody);BinStream.SaveToFile(WScript.Arguments(1));
Then, from a Windows command prompt or PowerShell terminal to execute our JavaScript code and download a file ->
VBScript is a Scripting language developed by Microsoft that is modeled on Visual Basic and installed on every microsoft windows since 98
We'll create a file called wget.vbs and save the following content:
dim xHttp: Set xHttp = createobject("Microsoft.XMLHTTP")
dim bStrm: Set bStrm = createobject("Adodb.Stream")
xHttp.Open "GET", WScript.Arguments.Item(0), False
xHttp.Send
with bStrm
.type = 1
.open
.write xHttp.responseBody
.savetofile WScript.Arguments.Item(1), 2
end with
And use the following command from a Windows command prompt or PowerShell terminal to execute our VBScript code and download a file.