这个方法很鸡肋,需要服务器有编程环境,mswinsck属于VB控件,装了VC或者VS也行,否则是没有注册的。作为一种思路吧。

MSWINSCK.OCX里的方法可以用来主动连接,但是可能由于本人的ASP功底不够吧,始终没有实现使用Connect方法探测任意IP地址的端口,希望有高人能够写出来代码并能共享出来。

测试环境:Windows 2003 企业版 SP2 IIS 6.0

测试代码:

<%
Function CheckLocalPort(intPort)
On Error Resume Next

Set WinSock = Server.CreateObject("MSWinsock.Winsock.1")
WinSock.Bind intPort, "127.0.0.1"

If Err.Number <> 0 Then CheckLocalPort = True Else CheckLocalPort = False

Set WinSock = Nothing
End Function

Sub CheckLocalPortList(PortList)
PortListArr = Split(Replace(Trim(PortList), " ", ""), ",")
PortListCnt = Ubound(PortListArr)
For i = 0 To PortListCnt
Response.Write "Check Port " & PortListArr(i) & " ............ "
If CheckLocalPort(PortListArr(i)) = True Then Response.Write "Open" Else Response.Write "Closed"
Response.Write "<br />"
Next
End Sub
%>

<%
Call CheckLocalPortList("88, 3389, 1433, 4444, 562, 110, 1028")
%>

 

转载请注明来自WebShell'S Blog,本文地址:https://www.webshell.cc/789.html