关闭

利用vb写的扫描本机开放端口的小程序.

427人阅读 评论(0) 收藏 举报

利用vb写的扫描本机开放端口的小程序.

4个text   两个按钮.和一个Winsock1控件

Dim portnum As Long
Dim start As String
Sub scanningports()
    Dim porttwo As Long
    portnum = Text1.Text
    porttwo = Text2.Text
    Command2.Enabled = True
    On Error GoTo viriio
    Do
    portnum = portnum + 1
    DoEvents
    If start = True Then
    Winsock1.Close
    DoEvents
    Winsock1.LocalPort = portnum
    DoEvents
    Text3.Text = portnum
    Winsock1.Listen
    DoEvents
    Else
    portnum = 0
    Command1.Enabled = True
    Text1.Locked = False
    Text2.Locked = False
    Exit Sub
    End If
    Winsock1.Close
    DoEvents
       Loop Until portnum >= porttwo
    portnum = 0
    Command1.Enabled = True
    logport.Text = logport.Text & vbCrLf & "Scanning Ports Done!" & vbCrLf
    Text1.Locked = False
    Text2.Locked = False
viriio:
    If Err.Number = 10048 Then
    logport.Text = logport.Text & vbCrLf & "端口" & Winsock1.LocalPort & " 开启中"
    Resume Next
    End If

End Sub

Private Sub Command1_Click()
Command2.Enabled = True
If Text1.Text = "" Then
MsgBox "你必须指定开始端口号!"
Exit Sub
End If
If Text2.Text = "" Then
MsgBox "你必须指定一个结束端口号"
Exit Sub
End If

Text1.Locked = True
Text2.Locked = True
Command1.Enabled = False
Winsock1.Close
start = True
Call scanningports
logport.Text = logport.Text & vbCrLf & "端口" & Text1.Text & "- " & Text3.Text & "  已经成功扫描!"

End Sub

Private Sub Command2_Click()
Command2.Enabled = False
start = False
End Sub
 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:97669次
    • 积分:2064
    • 等级:
    • 排名:第18653名
    • 原创:108篇
    • 转载:22篇
    • 译文:0篇
    • 评论:27条
    最新评论