skyle17
Global moderator
Posts : 16 Anonymous Points : 37 Reputation : 1 Join date : 2013-01-23 Location : Anonymous UnderGround
| Subject: My Vb6 Port Scanner Tue Jan 29, 2013 10:34 am | |
| Here my Design and Code - Spoiler:
- Spoiler:
3 command=cmdScan,cmdStop,cmdClear 3 text=txtFrom,txtTo,txtIp 1 winsock.wCock 1 timer=tScan 1 progBar=prgScan - Code:
-
Private Sub cmdStop_Click() tScan.Enabled = False End Sub
Private Sub cmdClear_Click() lstPorts.Clear End Sub
Private Sub wSock_Connect() lstPorts.AddItem wSock.RemotePort End Sub
Private Sub txtFrom_KeyPress(KeyAscii As Integer) If InStr("1234567890" & Chr$(8), Chr$(KeyAscii)) = 0 Then KeyAscii = 0 End If End Sub
Private Sub txtIp_KeyPress(KeyAscii As Integer) If InStr("1234567890." & Chr$(8), Chr$(KeyAscii)) = 0 Then KeyAscii = 0 End If End Sub
Private Sub txtTo_KeyPress(KeyAscii As Integer) If InStr("1234567890" & Chr$(8), Chr$(KeyAscii)) = 0 Then KeyAscii = 0 End If End Sub
Private Sub cmdScan_Click() On Error Resume Next iPortcount = CInt(txtTo.Text) - CInt(txtFrom.Text) iScancount = 0 prgScan.Max = iPortcount
If txtIp.Text <> "" Then If txtFrom.Text <> "" And txtTo.Text <> "" Then If CInt(txtFrom.Text) < CInt(txtTo.Text) Then tScan.Enabled = True Else MsgBox "Start port must be higher than the last port", vbCritical, "Error" End If Else MsgBox "Please specify a portrange to scan", vbCritical, "Error" End If Else MsgBox "Please insert an IP to scan", vbCritical, "Error" End If End Sub
Private Sub tScan_Timer() On Error Resume Next Dim iPercent As Integer
wSock.Close
If (iScancount >= iPortcount) Then MsgBox "All ports scanned!", vbInformation, "Success" tScan.Enabled = False Exit Sub End If
txtFrom.Text = txtFrom.Text + 1 wSock.RemoteHost = txtIp.Text wSock.RemotePort = txtFrom.Text wSock.Connect iScancount = iScancount + 1 prgScan.Value = iScancount iPercent = (iScancount / iPortcount) * 100 lblPercent = iPercent & "%" End Sub |
|