- 19 Marzo 2010
- 446
- 0
- Miglior risposta
- 0
Eccovi una semplice guida su come fare un Port Scanner, programmino che vi individua le porte del Pc aperte.
Abbiamo bisogno di :
-1 Bottone
-1 Timer
-2 TextBox
-1 CheckBox
-1 ProgressBar
-2 Label
-1 Listview
Copiamo & Incolliamo questo codice :
. Fatto.
Debuggate, e troverete le vostre porte che sono aperte
Credits: Neaples Fonte IH
Abbiamo bisogno di :
-1 Bottone
-1 Timer
-2 TextBox
-1 CheckBox
-1 ProgressBar
-2 Label
-1 Listview
Copiamo & Incolliamo questo codice :
Imports System
Imports System.Net
Imports System.Net.Sockets
Imports System.Threading
Public Class Form1
Dim porta As Integer = 1
Dim percentuale As Integer
Dim num As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Timer1.Interval = Val(Me.TextBox2.Text)
If Button1.Text = "Parti" Then
Timer1.Enabled = True
Me.Button1.Text = "Stop"
Else
Me.Button1.Text = "Stop"
Me.Timer1.Enabled = False
Button1.Text = "Parti"
End If
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
End
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Me.porta = 65536 Then Me.Button1.PerformClick()
Dim a As New dati
a.form = Me
a.port = Me.porta
a.ip = Me.TextBox1.Text
If Me.CheckBox1.Checked Then
a.chk = True
End If
Me.ProgressBar1.Value += 1
If num = Int(65536 / 100) Then
Me.percentuale += 1
num = 0
Else
num += 1
End If
Label2.Text = Me.percentuale & "%"
Dim thr As New Thread(AddressOf a.connect)
thr.Start()
Me.porta += 1
End Sub
End Class
Public Class dati
Public port As Integer
Public Delegate Sub k(ByVal data As ListViewItem)
Public form As Form
Public ip As String
Public chk As Boolean = False
Public Sub connect()
Try
Dim sock As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
Dim iep As New IPEndPoint(Net.IPAddress.Parse(ip), port)
sock.Connect(iep)
sock.Close()
Dim item(2) As String
item(0) = ip
item(1) = port
item(2) = "Yes****"
Dim list As New ListViewItem(item)
form.Invoke(New k(AddressOf add), list)
Catch
If chk = False Then
Dim item(2) As String
item(0) = ip
item(1) = port
item(2) = "No"
Dim list As New ListViewItem(item)
form.Invoke(New k(AddressOf add), list)
End If
End Try
End Sub
Sub add(ByVal list As ListViewItem)
Form1.ListView1.Items.Add(list)
End Sub
End Class
Imports System.Net
Imports System.Net.Sockets
Imports System.Threading
Public Class Form1
Dim porta As Integer = 1
Dim percentuale As Integer
Dim num As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Timer1.Interval = Val(Me.TextBox2.Text)
If Button1.Text = "Parti" Then
Timer1.Enabled = True
Me.Button1.Text = "Stop"
Else
Me.Button1.Text = "Stop"
Me.Timer1.Enabled = False
Button1.Text = "Parti"
End If
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
End
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Me.porta = 65536 Then Me.Button1.PerformClick()
Dim a As New dati
a.form = Me
a.port = Me.porta
a.ip = Me.TextBox1.Text
If Me.CheckBox1.Checked Then
a.chk = True
End If
Me.ProgressBar1.Value += 1
If num = Int(65536 / 100) Then
Me.percentuale += 1
num = 0
Else
num += 1
End If
Label2.Text = Me.percentuale & "%"
Dim thr As New Thread(AddressOf a.connect)
thr.Start()
Me.porta += 1
End Sub
End Class
Public Class dati
Public port As Integer
Public Delegate Sub k(ByVal data As ListViewItem)
Public form As Form
Public ip As String
Public chk As Boolean = False
Public Sub connect()
Try
Dim sock As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
Dim iep As New IPEndPoint(Net.IPAddress.Parse(ip), port)
sock.Connect(iep)
sock.Close()
Dim item(2) As String
item(0) = ip
item(1) = port
item(2) = "Yes****"
Dim list As New ListViewItem(item)
form.Invoke(New k(AddressOf add), list)
Catch
If chk = False Then
Dim item(2) As String
item(0) = ip
item(1) = port
item(2) = "No"
Dim list As New ListViewItem(item)
form.Invoke(New k(AddressOf add), list)
End If
End Try
End Sub
Sub add(ByVal list As ListViewItem)
Form1.ListView1.Items.Add(list)
End Sub
End Class
Debuggate, e troverete le vostre porte che sono aperte
Credits: Neaples Fonte IH