用vbs来探测端口的代码 不用注册winsock
程序员文章站
2022-04-10 08:13:32
复制代码 代码如下: 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