这是一个简单的“端口扫描的程序”的源代码
一. 控件说明:
窗 口: frmScan
** frmScan 中的控件 **
* TextBox :
txtIP (对方的IP)
txtLowerBound (起始端口)
txtUpperBound (结束端口)
txtMaxConnections (最多使用的连接数量)
lstOpenPorts (列出开放的端口)
* CommandButton :
cmdScan (开始扫描)
cmdStop (结束扫描)
cmdClearList (清除开放端口的列表)
* Winsock:
wskSocket (TCP协议)
* Timer:
timTimer (超时设置)
**********************
二. 程序源代码:
=========================================
Option Explicit
Dim lngNextPort As Long
Private Sub cmdClearList_Click()
Me.lstOpenPorts.Clear
End Sub
Private Sub cmdScan_Click()
Dim intI As Integer
lngNextPort = Val(Me.txtLowerBound)
For intI = 1 To Val(Me.txtMaxConnections)
Load Me.wskSocket(intI)
lngNextPort = lngNextPort + 1
Me.wskSocket(intI).Connect Me.txtIP, lngNextPort
Next intI
End Sub
Private Sub cmdStop_Click()
Dim intI As Integer
For intI = 1 To Val(Me.txtMaxConnections)
Me.wskSocket(intI).Close
Unload Me.wskSocket(intI)
Next intI
End Sub
Private Sub timTimer_Timer()
Me.sbMain.Panels(1).Text = "Current Port: " + Str(lngNextPort)
End Sub
Private Sub wskSocket_Connect(Index As Integer)
Me.lstOpenPorts.AddItem "Port: " + Str(Me.wskSocket(Index).RemotePort)
Try_Next_Port (Index)
End Sub
Private Sub wskSocket_Error(Index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
Try_Next_Port (Index)
End Sub
Private Sub Try_Next_Port(Index As Integer)
Me.wskSocket(Index).Close
If lngNextPort < Val(Me.txtUpperBound) Then
Me.wskSocket(Index).Connect , lngNextPort
lngNextPort = lngNextPort + 1
Else
Unload Me.wskSocket(Index)
End If
End Sub
=========================================
代码其实很简单,相信大家很容易就看懂了!
最近没什么时间,所以上次的UPD协议迟了两天才写出来。
不过我还是会陆续将一些程序源代码帖出来以供大家参考。
--------------------------------------------------
接下来我将帖出一些程序的源代码供大家参考!
如果你感兴趣的请到 http://NetIs.126.com
本文地址:http://com.8s8s.com/it/it41779.htm