标题: all2vbs
[打印本页]
作者: 3742668
时间: 2006-11-13 06:42
标题: all2vbs
主要用来在vbs中"夹带"exe,dll以及ocx。支持拖放,参数。
'***********************************************************************************
'恢复exe文件的代码
'***********************************************************************************
sCode = "sFile = InputBox(""输入要生成的文件名,包括扩展名:"")" + vbCrLf + _
" if Len(Trim(sFile)) = 0 Then Wscript.Quit" + vbCrLf + _
"Set oStream = Createobject(""Adodb.Stream"")" + vbCrLf + _
"Set oXML = Createobject(""Microsoft.XMLDOM"")" + vbCrLf + _
"Set oElement = oXML.CreateElement(""oTmpElement"")" + vbCrLf + _
" oElement.DataType = ""bin.hex""" + vbCrLf + _
" oElement.NodeTypedValue = str" + vbCrLf + _
"With oStream" + vbCrLf + _
" .Type = 1" + vbCrLf + _
" .Mode = 3" + vbCrLf + _
" .Open" + vbCrLf + _
" .Write oElement.NodeTypedValue" + vbCrLf + _
" .SaveToFile sFile" + vbCrLf + _
"End With" + vbCrLf + _
" oStream.Close" + vbCrLf + _
"Set oStream = Nothing" + vbCrLf + _
"Set oXML = Nothing" + vbCrLf + _
"Set oElement = Nothing"
'***********************************************************************************
'开始
'***********************************************************************************
sFile = GetFile()
Set oStream = CreateObject("Adodb.Stream")
Set oFso = CreateObject("Scripting.FileSystemObject")
Set oFile = oFso.OpenTextFile(sFile & ".vbs",2,True)
oFile.WriteLine "str= _"
With oStream
.Type = 1
.Open
.LoadFromFile sFile
End With
Do Until oStream.EOS
'生成的vbs文件每一行的长度由oStream.Read()中的参数来控制
oFile.WriteLine Space(4) + "+" + Chr(34) + _
Bin2Str(oStream.Read(20)) + chr(34) + " _"
Loop
'由于上一行结束有"_",所以要空一行
oFile.WriteLine Space(1)
oFile.Write sCode
oStream.Close
oFile.Close
Set oStream = Nothing
Set oFile = Nothing
Set oFso = Nothing
'***********************************************************************************
'2进制转换为16进制字符串
'***********************************************************************************
Function Bin2Str(bin)
Dim i,str
For i = 1 To Lenb(bin)
If Ascb(Midb(bin,i,1)) < 16 Then str = str + "0"
str = str & Hex(Ascb(Midb(bin,i,1)))
Next
Bin2Str = str
End Function
'***********************************************************************************
'获得要操作的文件
'***********************************************************************************
Function GetFile()
On Error Resume Next
Dim strFile,objFso,objFile
If WScript.Arguments.Count < 1 Then
Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "exe 文件|*.exe|dll 文件|*.dll|ocx 文件|*.ocx|所有 文件|*.*"
objDialog.ShowOpen
strFile = objDialog.FileName
Set objDialog = Nothing
Else
strFile = WScript.Arguments(0)
end if
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objFile = objFso.GetFile(strFile)
If Err Then
If Err.Number = 5 Then WScript.Quit
WScript.Echo Err.Description
Err.Clear
WScript.Quit
Else
GetFile = strFile
End If
Set objFile = Nothing
Set objFso = Nothing
End Function
请大家帮忙测试。
作者: electronixtar
时间: 2006-11-13 06:49
狂顶!加分!
试了一下,编码效率是原文件大小的 2-3倍之间。太厉害了!
想想有法用base64来编码,个人觉得更好。可以只扩大体积1/3
[
Last edited by electronixtar on 2006-11-13 at 06:57 AM ]
作者: 3742668
时间: 2006-11-13 06:56
下面是夹带的一个exe例子:
str= _
+"4D5A90000300000004000000FFFF0000B80000000000000040000000000000000000000000000000" _
+"0000000000000000000000000000000000000000C00000000E1FBA0E00B409CD21B8014CCD215468" _
+"69732070726F6772616D2063616E6E6F742062652072756E20696E20444F53206D6F64652E0D0D0A" _
+"2400000000000000EC1E1D1CA87F734FA87F734FA87F734F2660604FBF7F734F545F614FA97F734F" _
+"52696368A87F734F000000000000000000000000000000000000000000000000504500004C010300" _
+"A1A456450000000000000000E0000F010B01050C000400000008000000000000D111000000100000" _
+"00200000000040000010000000020000040000000400000004000000000000000040000000040000" _
+"AF0F0000020000000000100000100000000010000010000000000000100000000000000000000000" _
+"4C200000500000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"0000000000000000002000004C000000000000000000000000000000000000000000000000000000" _
+"2E746578740000004A02000000100000000400000004000000000000000000000000000020000060" _
+"2E726461746100001A02000000200000000400000008000000000000000000000000000040000040" _
+"2E64617461000000600200000030000000020000000C0000000000000000000000000000400000C0" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"000000000000000000000000000000000000000000000000558BEC83C4AC535657837D0C02750C6A" _
+"00E810020000E9D5000000817D0C1101000075438B45106683F8010F85BF000000C1E810660BC075" _
+"2968000200006860304000FF355C304000E8C60100006A056A006A0068603040006A006A00E8E201" _
+"0000E989000000837D0C01756B6A00FF35543040006A02FF75086A19685E0100006A236A0A688000" _
+"8050680530400068483040006800020000E85E010000A35C3040006A00FF35543040006A01FF7508" _
+"6A196A646A46688C0000006801000050684D30400068413040006A00E82B010000A358304000EB18" _
+"FF7514FF7510FF750CFF7508E8190100005F5E5BC9C2100033C05F5E5BC9C21000558BEC83C4B06A" _
+"308D45D050E8EC00000068007F00006A00E8040100008945EC68057F00006A00E8FB0000008945E8" _
+"FF35543040008F45E4C745F006000000C745D800104000C745D030000000C745D403000000C745F8" _
+"393040008D45D050E8CF0000006A00FF35543040006A006A0068A0000000687C010000682C010000" _
+"682C01000068FFBF0E00680030400068393040006A00E8690000008945B06A01FF75B0E892000000" _
+"FF75B0E8960000006A006A006A008D45B450E8570000000BC074148D45B450E8740000008D45B450" _
+"E83B000000EBD9C9C36A00E818000000A354304000E817FFFFFF6A00E801000000CCFF2508204000" _
+"FF2500204000FF2504204000FF2540204000FF2524204000FF2518204000FF251C204000FF252020" _
+"4000FF2544204000FF2528204000FF252C204000FF2530204000FF2534204000FF2538204000FF25" _
+"3C204000FF2510204000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"0000000000000000F62000000A210000E820000000000000FE210000000000004C21000060210000" _
+"6E2100003A2100008E2100009A210000AC210000C0210000CE210000E22100002821000080210000" _
+"000000009C20000000000000000000001A21000000200000B42000000000000000000000F2210000" _
+"18200000AC20000000000000000000000E2200001020000000000000000000000000000000000000" _
+"00000000F62000000A210000E820000000000000FE210000000000004C210000602100006E210000" _
+"3A2100008E2100009A210000AC210000C0210000CE210000E2210000282100008021000000000000" _
+"80004578697450726F636573730009014765744D6F64756C6548616E646C654100000B0252746C5A" _
+"65726F4D656D6F7279006B65726E656C33322E646C6C0000540043726561746557696E646F774578" _
+"41007E0044656657696E646F7750726F634100008C0044697370617463684D657373616765410000" _
+"19014765744D65737361676541004A0147657457696E646F775465787441000080014C6F61644375" _
+"72736F72410084014C6F616449636F6E4100BF01506F7374517569744D65737361676500C8015265" _
+"676973746572436C61737345784100002D0253686F7757696E646F77000042025472616E736C6174" _
+"654D65737361676500004E0255706461746557696E646F7700007573657233322E646C6C00006700" _
+"5368656C6C4578656375746541007368656C6C33322E646C6C000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"0000000000000000000000000000000000000000000000000000000000000000D4CBD0D000687474" _
+"703A2F2F7777772E636E2D646F732E6E65742F666F72756D2F666F72756D646973706C61792E7068" _
+"703F6669643D3233004D79436C61737300425554544F4E004544495400D4CBD0D000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"00000000000000000000000000000000000000000000000000000000000000000000000000000000" _
+"000000000000000000000000000000000000000000000000" _
sFile = InputBox("输入要生成的文件名,包括扩展名:")
if Len(Trim(sFile)) = 0 Then Wscript.Quit
Set oStream = Createobject("Adodb.Stream")
Set oXML = Createobject("Microsoft.XMLDOM")
Set oElement = oXML.CreateElement("oTmpElement")
oElement.DataType = "bin.hex"
oElement.NodeTypedValue = str
With oStream
.Type = 1
.Mode = 3
.Open
.Write oElement.NodeTypedValue
.SaveToFile sFile
End With
oStream.Close
Set oStream = Nothing
Set oXML = Nothing
Set oElement = Nothing
作者: electronixtar
时间: 2006-11-13 06:59
3742668版主果然强悍,用 MASM32 / TASM32 写的exe!再次拜!
作者: 3742668
时间: 2006-11-13 07:11
Quote: |
想想有法用base64来编码,个人觉得更好。可以只扩大体积1/3 |
|
Microsoft.XMLDOM支持base64编码,可以指定oElement.DataType = "bin.base64"。
Quote: |
...,用 MASM32 / TASM32 写的exe |
|
汗一个,初学masm32,入门级水平。
作者: ccwan
时间: 2006-11-13 07:17
斑竹不愧是高手!佩服!
作者: lxmxn
时间: 2006-11-13 10:49
版主果然强悍啊。佩服得没话说了。。
加分顶一个~
作者: vkill
时间: 2006-11-16 03:55
看不懂~
作者: hdzc
时间: 2007-10-24 15:36
佩服得没话说了高高高
作者: gyfhgyfh
时间: 2007-11-8 22:54
好棒,不过,体积是大了点。