Results 1 to 4 of 4

Thread: Port Scanner

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Posts
    6

    Post

    Hello,

    I am still a newbie, but I was wondering if anybody knows how to use the winsock control to make some kind of a port scanner. Not for hacking, but just for fun.

    Thanks.

  2. #2
    Junior Member
    Join Date
    Mar 2000
    Posts
    29

    Post

    Right... For fun...

    Winsock1.remotehost = [Address to scan]

    Then you loop through the ports you want to scan:

    for i = 1 to [MaxPort]
    Winsock1.remoteport = i

    loop

    Don't forget to set the Error and Connect event. You must specify something like Winsock1.close in the Error & Connect Event so that when the socket connects, it closes itself so it can continue scanning.

    In the Connect Event, you must also put code to specify that you connected successfully to the port.

    And you're done.

    Raggart

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Posts
    6

    Post

    I've come up with the following code:

    Dim i As Integer
    Private Sub Command1_Click()
    For i = 1 To 9000
    Winsock1.RemotePort = i
    Text1.Text = i
    Next i
    End Sub

    Private Sub Form_Load()
    Winsock1.RemoteHost = "127.0.0.1"
    End Sub

    Private Sub Winsock1_Connect()
    Winsock1.Close
    MsgBox "Port :" & i
    End Sub

    Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
    Winsock1.Close
    Text1.Text = "Error"
    End Sub

    The problem is, it doesn't work. The For-Next loop loops fine, but it doesn't detect any open ports.

    Could you tell me what's wrong with this code?
    Thanks.

  4. #4
    Member FirePoweR's Avatar
    Join Date
    Apr 1999
    Posts
    32

    Post Connect

    In the For..Next loop you have to put in the Connect command.

    For i = 1 To 65535
    Winsock1.RemotePort = i
    Text1.Text = i
    Winsock1.Connect
    Next i

    And the highest port number is 65535.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width