Author: xiaolu [BST]
Source: evil baboons Information Security Team (www.eviloctal.com)
This is not an exe2vbs file of all types that can be converted, but it is limited to the size of the string file. It cannot be too large. I have tested 3 M files.
Save the following code as: file2vbs. vbsCopy codeThe Code is as follows: 'program By xiaolu
'Name: file2vbs. vbs
On error resume next
Do while 1
Fname = InputBox ("enter the name of the file to be converted (including the path):", "input file name", "f: \ hhh.exe ")
If fname = "" then Wscript. quit
Err. number = 0
Set Ado = createObject ("adodb. stream ")
With Ado
. Type = 1
. Open
. Loadfromfile fname
Ss =. read
End
If err. number <> 0 then
If msgbox ("file opening error! ", 1," File2VBS ") = 2 then Wscript. quit
Else
Exit do
End if
Loop
Fname = InputBox ("Enter the vbs name (including the path):", "input file name", "f: \ hhh. vbs ")
If fname = "" then Wscript. quit
Set Fso = createObject ("Scripting. FileSystemObject ")
Set File = fso. OpenTextFile (fname, 2, True)
Lens = lenB (ss) mod 500.
For j = 0 to int (lenB (ss)/500)-1
If j = 0 then
File. writeline "ss =" "& Bin2Str (midb (ss, 500 * j + 1,500 ))&"""_"
Else
File. writeline "+" "& Bin2Str (midb (ss, 500 * j + 1,500 ))&"""_"
End if
Next
If lens> 0 then
File. writeline "+" "& Bin2Str (rightb (ss, lens ))&""""
Else
File. writeline "+" & chr (34) & chr (34)
End if
File. writeline ""
File. writeline "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 )"
File. writeline "Set s = createObject (" "ADODB. stream ""): with s :. mode = 3 :. type = 1 :. open ():. write ss :. saveToFile wscript. arguments (0), 2: end"
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 <16 Then Bin2Str = Bin2Str & "0"
Bin2Str = Bin2Str & Hex (bt)
Next
End Function
File Generation Method
Copy codeThe Code is as follows: cscript file2vbs. vbs c: \ test.exe