📄 frmnettools.frm
字号:
' cmdLogClear.Top = txtLog.Top + txtLog.Height + 108
End If
End If
End If
If SimpScan Then
Remb.LastScanPortOpt = chkPortAdv.Value
ElseIf MultiScan Then
Remb.LastMultiScanPortOpt = chkPortAdv.Value
End If
End Sub
Private Sub cmdLogClear_Click()
'Clear the log
txtLog = ""
End Sub
Private Sub cmdNext_Click()
'Here we have a next and back button:
If cmdNext.Caption = "Next >>" Then
'If it's in general menu:
Dim i As Byte
'Use a for loop to get the position selected
For i = 0 To optAction.UBound
'When you get it it's of no use proceding with the loop
'and we would lost the position
If optAction(i).Value Then Exit For
Next
'Treat user option:
Select Case i
Case 0 'Single\Multi Ping
Action = 1
TabStrip.Tabs(3).Selected = True
Case 1 'Multi Ping
Action = 3
TabStrip.Tabs(4).Selected = True
Case 2 'Single Port Scan
TabStrip.Tabs(2).Selected = True
Action = 2
End Select
Else
TabStrip.Tabs(1).Selected = True
End If
End Sub
Private Sub cmdPingClear_Click()
'Clear inserted addresses
lstAdr.Clear
'Check for delete button (there won't be nothin to delete)
If cmdDel.Enabled = True Then cmdDel.Enabled = False
End Sub
Private Sub cmdPortAdd_Click()
Dim StartPort As Integer, EndPort As Integer
If Not Working Then
'Initialize flag for reconizing when user presses cancel
Working = True
'Change caption on button to let know that it can be stoped
cmdPortAdd.Caption = "Stop"
If IsNumeric(txtStartPort) Then
If (Int(txtStartPort) - Val(txtStartPort)) = 0 Then
'Verify values:
StartPort = CInt(txtStartPort.Text)
If StartPort < 1 Then StartPort = 1
If StartPort >= 32767 Then StartPort = 32766
'check if we're adding an interval of values
If chkPortInterval.Value = 1 And IsNumeric(txtEndPort) Then
'Both values must be integer!
If (Int(txtEndPort) - Val(txtEndPort)) <> 0 Then
MsgBox "Ending port has a non integer value!", vbCritical, "Initialize Error"
Exit Sub
Else
EndPort = CInt(txtEndPort.Text)
If EndPort > 32767 Then EndPort = 32767
If EndPort < 2 Then EndPort = 2
If StartPort >= txtEndPort Then
If MsgBox("Starting Port is bigger than ending Port. Ending Port will be set to a bigger value", vbCritical Or vbOKCancel, "Initialize Error") = vbOK Then
EndPort = StartPort + 1
Else
Exit Sub
End If
End If
End If
Dim i As Integer
For i = StartPort To EndPort
If Not EntryExists(CStr(i), lstPortInterval) Then lstPortInterval.AddItem i
DoEvents
If Not Working Then GoTo CleanUp
Next i
Exit Sub
End If
If Not EntryExists(CStr(StartPort), lstPortInterval) Then lstPortInterval.AddItem StartPort
Else
MsgBox "Starting port has a non integer value!", vbCritical, "Initialize Error"
Exit Sub
End If
Else
MsgBox "Starting port has a non numerical value!", vbCritical, "Initialize Error"
Exit Sub
End If
Else
Working = False
Exit Sub
End If
CleanUp:
cmdPortAdd.Caption = "Add"
End Sub
Private Sub cmdPortClear_Click()
'Clear inserted addresses
lstPortInterval.Clear
'Check for delete button (there won't be nothin to delete)
If cmdPortDel.Enabled = True Then cmdPortDel.Enabled = False
End Sub
Private Sub cmdPortDel_Click()
With lstPortInterval
'Assure error free:
If .ListCount = 0 Then cmdDel.Enabled = False: Exit Sub
'Assure there is somethin selected
If .ListIndex > -1 Then
If .Selected(.ListIndex) Then
.RemoveItem .ListIndex
End If
End If
'If for some reason it's still enabled and
'there's nothin to delete, disable button:
If .ListCount = 0 Then cmdPortDel.Enabled = False
End With
End Sub
Private Sub cmdSkip_Click()
StartScan , True
Working = False
End Sub
Private Sub cmdStart_Click()
If cmdStart.Caption = "Cancel" Then
bolStop = True
Working = False
Else
bolStop = False
Working = False
End If
Select Case Action
Case 1
'Simple ping
StartPing
Case 2
'simple scan
StartScan
Case 3
'ping->scan
Dim i As Integer
For i = 0 To lstAdr.ListCount - 1
StartScan lstAdr.List(i)
Do
If Not Scanning Then Exit Do
If bolStop Then
StartScan , True
StatusBar.SimpleText = "Operation aborted by user!"
Exit Sub
End If
DoEvents
Loop
Next i
End Select
End Sub
Private Sub Form_Load()
'Initialize
Me.Height = 6555
Me.Width = 7425
Dim i As Integer
For i = 0 To fraMain.UBound
fraMain(i).Top = TabStrip.Height
fraMain(i).BorderStyle = 0
fraMain(i).Left = 120
fraMain(i).Visible = False
Next i
StartScan , True
fraScanStatus.Left = fraPortSettings.Left
fraPingStatus.Left = fraPortSettings.Left
LastFrame = 1
'TabStrip_Click
TabStrip.Tabs(2).Selected = True
TabStrip.Tabs(1).Selected = True
lblDesc = "Welcome to Network Tools"
'Refresh check buttons bindings
'buttons are affected by the following procedure thus they must be place under the calls
chkPortAdv_Click
chkHostAdv_Click
fraScanStatus.Top = fraPortSettings.Top + fraPortSettings.Height
cmdStart.Top = fraLog.Top + fraLog.Height + 105
cmdSkip.Top = cmdStart.Top
'Multi-Ping:
'Check if Del button is going to be enabled:
If lstAdr.ListCount = 0 Then cmdDel.Enabled = False
'Clean status label:
lblPingStatus = vbLf & vbLf & "Percentage Done"
'Check if last txtbox is going to be enabled:
If chkTo.Value = 0 Then txtLast.Enabled = False
'Refresh tooltip text:
If lstAdr.ListCount = 0 Then lstAdr.ToolTipText = "No adresses to ping"
End Sub
Private Sub Form_Resize()
Dim i As Byte
For i = 0 To fraMain.UBound
fraMain(i).Width = Me.Width - 120
fraMain(i).Height = Me.Height - TabStrip.Height
Next i
cmdNext.Top = cmdStart.Top + TabStrip.Height
cmdNext.Left = cmdStart.Left + cmdStart.Width + 210
End Sub
Private Sub Form_Unload(Cancel As Integer)
MsgBox "If you liked it or something got buggy or i doesn't work or you hate it please leave a comment.", vbExclamation, "Sorry about the nag screen =)"
End Sub
Private Sub optAction_Click(Index As Integer)
cmdNext.Enabled = True
Const PING_SIMP = 0
Const PING_ADV = 1
Const SCANPORT_SIMP = 2
Const SCANPORT_ADV = 3
Select Case Index
Case PING_SIMP
lblDesc.Caption = "Perform a simple Ping on one or more machines of your network."
Case PING_ADV
lblDesc.Caption = "Perform a Ping on more then one machine and a PortScan on each machine found."
Case SCANPORT_SIMP
lblDesc.Caption = "Perform a simple Port Scan in one machine. Note: the machine will always pinged first."
End Select
End Sub
Private Sub sckScan_Connect()
'Adds to the list current open port
LastOpenPort = sckScan.RemotePort
txtLog = txtLog & "Found open port: " & LastOpenPort & vbNewLine
sckScan.Close
End Sub
Private Sub TabStrip_Click()
If LastFrame <> TabStrip.SelectedItem.Index Then
'Something has changed:
If TabStrip.SelectedItem.Index = 1 Then
'User clicked General
fraMain(0).Visible = True
fraMain(1).Visible = False
Else
'user clicked other 2
fraMain(0).Visible = False
fraMain(1).Visible = True
End If
LastFrame = TabStrip.SelectedItem.Index
'Reset flag for remembering last Ping checked option
'because it is reseted when user makes a port scan
SimpPing = False: SimpScan = False: MultiScan = False
Select Case LastFrame
Case 2 'Simple portscan:
Action = 2
SimpScan = True
'Set to simple mode:
chkHostAdv.Value = 0
'Remember option
chkPortAdv.Value = Remb.LastScanPortOpt
'Refresh frame:
chkHostAdv_Click
'Disable advanced options
chkHostAdv.Visible = False
'Show Port Settings:
If Not fraPortSettings.Visible Then fraPortSettings.Visible = True
fraPingStatus.Visible = False
fraScanStatus.Visible = True
'There is no use of skiping since skiping a port is unnecessary because of it's speed
cmdSkip.Visible = False
Case 3 'Simple Ping
Action = 1
SimpPing = True
'Make sure adv options is visible:
If Not chkHostAdv.Visible Then chkHostAdv.Visible = True
'hide port scan:
If fraPortSettings.Visible Then fraPortSettings.Visible = False
'Remember last option
chkHostAdv.Value = Remb.LastPingHostOpt
fraPingStatus.Visible = True
fraScanStatus.Visible = False
'There is no use of skiping since we can't intercept the ping fucntion
cmdSkip.Visible = False
Case 4 'ping->scan:
Action = 3
MultiScan = True
chkHostAdv.Value = 1
chkHostAdv.Visible = False
fraPingHost.Visible = True
fraPortSettings.Visible = True
fraPingStatus.Visible = False
fraScanStatus.Visible = True
chkHostAdv.Visible = True
fraPingStatus.Visible = False
cmdSkip.Visible = True
'Remember last opt:
chkPortAdv.Value = Remb.LastMultiScanPortOpt
Case 5 'about:
frmAbout.Show
TabStrip.Tabs(5).Selected = False
TabStrip.Tabs(1).Selected = True
End Select
chkHostAdv_Click
chkPortAdv_Click
If LastFrame > 1 Then
cmdNext.Caption = "Back <<"
cmdNext.Cancel = True
cmdNext.Default = False
Else
cmdNext.Caption = "Next >>"
cmdNext.Cancel = False
cmdNext.Default = True
End If
End If
End Sub
Private Sub tmrCheckStatus_Timer()
If sckScan.State <> sckConnected Or sckScan.State <> sckConnecting Or sckScan.State <> sckHostResolved Or sckScan.State <> sckResolvingHost Then 'If the control isn't connected, connecting, resolving it's host, or already resolved it's host then...(in other words, it's hanging)
sckScan.Close 'Stop the control from doing whatever it's doing and close it
If chkPortAdv.Value = 0 Then
'Set the remote port for the next port needed to be scanned
sckScan.RemotePort = CurPort
Else
sckScan.RemotePort = PortInt(CurPort)
End If
sckScan.Connect 'Have it connect
lblStatus.Caption = "Status - Scanning Port:"
Port = sckScan.RemotePort 'Sets the status to the new port
If CurPort < ProgressScan.Max Then
ProgressScan = CurPort
Else
Working = False 'cancel
End If
CurPort = CurPort + 1 'Increment the variable for the next time we ask for a new port
End If
End Sub
Private Sub tmrStats_Timer()
If tmrCheckStatus.Enabled Then
If LastPort <> 0 Then
Rate = 4 * (CurPort - LastPort) - 1
Metrics.Visible = True
Metrics.Left = Rate.Left + Rate.Width
RemPort = ProgressScan.Max - ProgressScan
Dim EstimatedTime As Long
EstimatedTime = RemPort / Rate
If (EstimatedTime / 60) > 1 Then
Dim Secs As Long
'EstimatedTime = EstimatedTime / 60
Secs = (EstimatedTime / 60 - Int(EstimatedTime / 60)) * 60
EstRem = Int(EstimatedTime / 60) & " min " & Secs & " secs"
Else
EstRem = Int(EstimatedTime) & " secs"
End If
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -