Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
VB.NET Port Scanner [TUT]
#1
Note: I take no credit for the coding of this port scanner..
Credits go to David Kramer for posting it on Code Project

Ok so first off create a new Windows Application Form
You will need to add:

- TextBox X2
- ListBox X2
- Button X2
- Labels
- Timer


Add a label next to TextBox1 saying 'Host:'
And add 1 next to TextBox2 saying 'Port:'
Change the text on Button1 to 'start'
Change Button2 to 'stop'
Add a label for ListBox1 saying 'Ports being scanned:'
Add 1 for ListBox2 saying 'Open ports:'

----------------------------------------------------

Ok now for the coding...

First off declare the variables

Code:
Dim host As String
Dim port As Integer
Dim counter As Integer

Add the following to Form_load

Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Button2.Enabled = False
        TextBox2.Text = "0"
        'set counter explained before to 0
        counter = 0
    End Sub

Add the following to Timer_tick

Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
      'Set the host and port and counter
        counter = counter + 1 'counter is for the timer
        TextBox2.Text = counter
        host = TextBox1.Text
        port = TextBox2.Text
        ' Next part creates a socket to try and connect on with the given user information.
    
        Dim hostadd As System.Net.IPAddress = System.Net.Dns.GetHostEntry(host).AddressList(0)
        Dim EPhost As New System.Net.IPEndPoint(hostadd, port)
        Dim s As New System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, _
        System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp)
        Try
            s.Connect(EPhost)
        Catch
        End Try
        If Not s.Connected Then
            ListBox1.Items.Add("Port " + port.ToString + " is not open")
        Else
            ListBox1.Items.Add("Port " + port.ToString + " is open")
            ListBox2.Items.Add(port.ToString)
        End If
        Label3.Text = "Open Ports: " + ListBox2.Items.Count.ToString
    End Sub

Add the following to the Start button_click

Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ListBox1.Items.Add("Scanning: " + TextBox1.Text)
        ListBox1.Items.Add("-------------------")
        Button2.Enabled = True
        Button1.Enabled = False
        Timer1.Enabled = True
        Timer1.Start()
    End Sub

Add the following to Button2_click (stop)

Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        'stop button
        Timer1.Stop()
        Timer1.Enabled = False
        Button1.Enabled = True
        Button2.Enabled = False
    End Sub

Hope this helps. Blackhat
Reply


Messages In This Thread
VB.NET Port Scanner [TUT] - by Fragma - 04-12-2010, 01:13 PM
RE: VB.NET Port Scanner [TUT] - by Fragma - 04-13-2010, 07:59 AM
RE: VB.NET Port Scanner [TUT] - by Kewlz - 04-15-2010, 09:25 AM
RE: VB.NET Port Scanner [TUT] - by phire nuk3r - 04-15-2010, 09:30 AM
RE: VB.NET Port Scanner [TUT] - by RaZoR03 - 04-18-2010, 12:24 AM
RE: VB.NET Port Scanner [TUT] - by Fragma - 04-18-2010, 03:39 AM
RE: VB.NET Port Scanner [TUT] - by Julie - 04-18-2010, 02:24 PM
RE: VB.NET Port Scanner [TUT] - by SouR'D - 04-20-2010, 03:34 PM
RE: VB.NET Port Scanner [TUT] - by Fragma - 04-20-2010, 04:26 PM
RE: VB.NET Port Scanner [TUT] - by flAmingw0rm - 04-23-2010, 12:29 PM
RE: VB.NET Port Scanner [TUT] - by trubufo - 04-28-2010, 04:26 PM
RE: VB.NET Port Scanner [TUT] - by TurB0 - 04-29-2010, 07:34 AM
RE: VB.NET Port Scanner [TUT] - by Julie - 04-30-2010, 04:07 PM
RE: VB.NET Port Scanner [TUT] - by NathanE - 05-09-2010, 06:16 PM
RE: VB.NET Port Scanner [TUT] - by Control - 05-15-2010, 01:12 AM
RE: VB.NET Port Scanner [TUT] - by //Pretext™ - 05-18-2010, 09:16 AM
RE: VB.NET Port Scanner [TUT] - by James Ford - 09-03-2011, 11:46 PM
RE: VB.NET Port Scanner [TUT] - by Injection - 09-04-2011, 12:17 PM
RE: VB.NET Port Scanner [TUT] - by яeborn - 09-19-2011, 01:38 PM
RE: VB.NET Port Scanner [TUT] - by iRun - 09-29-2011, 04:06 PM
RE: VB.NET Port Scanner [TUT] - by jingo - 10-04-2011, 05:59 PM
RE: VB.NET Port Scanner [TUT] - by John. - 10-04-2011, 06:00 PM
RE: VB.NET Port Scanner [TUT] - by Arron XR - 10-05-2011, 01:07 PM
RE: VB.NET Port Scanner [TUT] - by ChromeWolf - 10-05-2011, 03:06 PM
RE: VB.NET Port Scanner [TUT] - by Tony Montana - 10-08-2011, 10:13 AM
RE: VB.NET Port Scanner [TUT] - by Greyersting - 10-10-2011, 11:56 AM
RE: VB.NET Port Scanner [TUT] - by Genuine - 10-11-2011, 04:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to hook the keyboard. [VB.NET] [TuT] Vorfin 92 54,234 09-23-2019, 11:55 AM
Last Post: Jamimartin
  Free Advanced Port Scanner SOURCE [ VB.NET ] Filefinder 6 5,276 01-22-2013, 04:27 AM
Last Post: TalishHF
  [TUT] MD5 Encrypter & Finder [VB.NET] Fragma 12 6,931 11-25-2012, 10:36 PM
Last Post: ƃu∀ ıʞƃu∀
  [TUT] How to make a simple WebBrowser in VB 2010! [TUT] - [ Pictures] Statics 95 55,112 10-07-2012, 06:56 AM
Last Post: a99
  [TUT]Auto-Update System[TUT] HB Virus 3 2,135 01-07-2012, 02:21 PM
Last Post: Mastermrz

Forum Jump:


Users browsing this thread: 2 Guest(s)