Quick and Simple PortScanner

Posts 1–6 of 6 · Page 1 of 1
Quick and Simple PortScanner
So guys, i was chilling in visual basic when i wanted to make a portscanner.
So i searched on google and found a couple of codes, mixed some parts together and enden up with this


Tutorial:
You Need:
1 Listbox - Show The Scanned Ports
2 Buttons - Start/Stop.
1 Textbox - Which Port It Should Start Scanning From.
1 Timer - The "PortScanner"


Should look like this :

Code:
Imports System.Net.Sockets
Public Class Form1

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Try
            TextBox1.Text = TextBox1.Text + 1
            Dim range As TcpClient = New TcpClient("127.0.0.1", TextBox1.Text)

            If range.Connected = True Then
                ListBox1.Items.Add(TextBox1.Text & " Is Open")
                ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1
            End If
        Catch ex As Exception
            ListBox1.Items.Add(TextBox1.Text & " Is Closed")
            ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1
        End Try
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Timer1.Enabled = True
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Timer1.Enabled = False

    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        ListBox1.Items.Clear()
    End Sub
End Class
Remember if you will ever copy this thread remember to put credits.
PortScanner_mpgh.net_mpgh.net.rar41 KB · 27 downloads 2/62 malicious
Code:
         
   Dim range As TcpClient = New TcpClient("127.0.0.1", TextBox1.Text)
Does that block until the connection is made/rejected?
How long is the timeout / how long does it take to scan all 65,000 of your ports? Maybe on your own box it happens quickly, but I don't think this will scale well to working w/ pc's on the net. ?

Thanks for post.

edit:
Code:
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
    '' The timer is never shut off here
    End Sub
^^ so it keeps going past millions??

If CInt(TextBox1.Text) > UInt16.MaxValue Then
Timer1.Enabled = False
ListBox1.Items.Add("Scan Finished")
ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1
End If
Quote Originally Posted by abuckau907 View Post
Code:
         
   Dim range As TcpClient = New TcpClient("127.0.0.1", TextBox1.Text)
Does that block until the connection is made/rejected?
How long is the timeout / how long does it take to scan all 65,000 of your ports? Maybe on your own box it happens quickly, but I don't think this will scale well to working w/ pc's on the net. ?

Thanks for post.

edit:
Code:
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
    '' The timer is never shut off here
    End Sub
^^ so it keeps going past millions??

If CInt(TextBox1.Text) > UInt16.MaxValue Then
Timer1.Enabled = False
ListBox1.Items.Add("Scan Finished")
ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1
End If
I see what you doing there, thanks for the code.
it doesnt go really fast as it is just an quick and simple portscanner.
how fast is fast? I've never tried, but I'd expect ... < 1 minute, 2 maybe? Or like 10? You mind timing it : P ?

 
Code

Imports System.Net.Sockets
Public Class Form1
Private _startTime As DateTime

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Try
TextBox1.Text = TextBox1.Text + 1
If CInt(TextBox1.Text) > UInt16.MaxValue Then ''65,535
''all done
Timer1.Enabled = False
ListBox1.Items.Add("Scan Complete")
ListBox1.SelectedIndex +=1
MessageBox.Show("Scan Complete. Time elapsed: " & Date.Now.Subtract(_startTime).TotalMinutes & " minutes, " & Date.Now.Subtract(_startTime).TotalSeconds & " seconds.")
Exit sub
End If

Dim range As TcpClient = New TcpClient("127.0.0.1", TextBox1.Text)

If range.Connected = True Then
ListBox1.Items.Add(TextBox1.Text & " Is Open")
ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1
End If

Catch ex As Exception
ListBox1.Items.Add(TextBox1.Text & " Is Closed")
ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1
End Try
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Timer1.Enabled = True
_startTime = Date.Now()
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Timer1.Enabled = False

End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
ListBox1.Items.Clear()
End Sub
End Class
[/code]
I did about 20 scans is 5 sec, im not using it often as im not using ports to anything atm.
But i would rate from 1-10 speed about a good 6.
Binaries removed. Source approved.
Posts 1–6 of 6 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us