欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

用vbs来探测端口的代码 不用注册winsock

程序员文章站 2024-01-01 18:46:58
复制代码 代码如下: on error resume next if (lcase(right(wscript.fullname,11))="wscript.exe") t...
复制代码 代码如下:

on error resume next
if (lcase(right(wscript.fullname,11))="wscript.exe") then
wscript.echo "execute it under the cmd.exe plz! thx."
wscript.quit
end if

if wscript.arguments.count=0 then
usage()
wscript.quit
end if

set arg=wscript.arguments
sport= split(arg(1),",")
for i=0 to ubound(split(arg(1),","))
wsh.echo "scan "&sport(i)&" ing……"
set x=createobject("msxml2.serverxmlhttp")
x.open "post","http://"&arg(0)&":"&sport(i)
x.send("hello")
wsh.echo space(3)&"error.number:"& err.number & space(5)&"err.description:"&err.description
if err.number=0 or err.number=-2147012866 or err.number=-2147012894 or err.number=-2147012744 or err.number=-2147467259 then
wsh.echo space(3)&" the "&sport(i)&" port is open"
end if
next

function usage()
wscript.echo "| 注意查看err.description来判断端口开放,自动探测不一定准确 |"
wscript.echo "| |"
wscript.echo "|useage: |"
wscript.echo "| cscript.exe this.vbs ip port |"
wscript.echo "|ex: |"
wscript.echo "| cscript.exe this.vbs ip 80 or 80,123,445…… |"
wscript.echo "+-------------------------------------------------------------------+"&chr(10)
end function

上一篇:

下一篇: