Results 1 to 8 of 8

Thread: creating a port listener

  1. #1

    Thread Starter
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    What the best way to go about creating a port listener and can someone please provide me with some code to get started?

    Thanks,
    Psyrus

    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  2. #2
    Guest
    Here is a few samples from planet-source-code.com of Port Listeners

  3. #3

    Thread Starter
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    Thanks Matthew I'll give it a look.


    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  4. #4

    Thread Starter
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    Does this look about right?
    What I really want to do is to find out
    if any files are either being sent from my computer
    or received by my computer.
    (Yes possible trojan)

    CODE:


    Private Sub Form_Load()

    Winsock1.Listen
    With txtInfo
    .Text = .Text & "Local Port:" & Winsock1.LocalPort & " " & _
    "LocalHost: " & Winsock1.LocalHostName
    End With

    txtStatus.Text = Winsock1.State

    End Sub


    Private Sub Form_Unload(Cancel As Integer)

    Winsock1.Close

    End Sub


    Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)

    If Winsock1.State <> sckClosed Then Winsock1.Close
    Winsock.Accept requestID

    With txtInfo
    .Text = .Text & "ID: " & requestID & vbNewLine
    .Text = .Text & "RemoteHost: " & Winsock1.RemoteHost & vbNewLine & _
    "RemotePort: " & Winsock1.RemotePort
    End With

    txtStatus.Text = Winsock1.State

    End Sub

    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)

    Dim strData As String
    txtStatus.Text = Winsock1.State
    Winsock1.GetData strData, vbString
    txtInfo.Text = txtInfo.Text & strData & vbNewLine & "Data Received!"

    End Sub

    Private Sub Winsock1_SendComplete()

    txtStatus.Text = Winsock1.State
    txtInfo.Text = txtInfo.Text & vbNewLine & "Illegal Data has been sent!"

    End Sub
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  5. #5
    Guest
    Here is an example on how to check 32000 ports to see if any of them are in use.

    Code:
    'Required:  2 textboxes, command button, listbox, Winsock
    'txtport1 = Text1
    'txtport2 = Text2
    
    Private Sub Command1_Click()
        On Error Resume Next
        Dim i As Long
    
    
        For i = txtport1 To txtport2 Step 1 ' Set counter to start and End at a specified number.
            Winsock1.Connect txtip, i ' connect To the ip and port
    
    
            If Winsock1.State <> sckConnected Then 'if it could Not connect then its closed.
                List1.AddItem i & " - closed"
            End If
    
    
            If Winsock1.State = sckConnected Then 'if it could connect its open.
                List1.AddItem i & " - OPEN"
                MsgBox "Open port!", vbCritical, "Port Scanner"
            End If
        Next i
    End Sub
    
    
    Private Sub Form_Load()
        txtport1.Text = 1 'set default port values.
        txtport2.Text = 32000
        Winsock1.Protocol = sckTCPProtocol 'set protocol
    End Sub
    
    
    Private Sub Form_Unload(Cancel As Integer)
        Set form1 = Nothing 'clear memory
    End Sub

  6. #6

    Thread Starter
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    Thanks again.
    No message box popped up. I guess this means that there are no open ports? Is that all there are 32,000 ports to listen to?

    I did get one error. The txtip wasn't defined anywhere so I set it to my computers name. Was that right?

    Shouldn't port # 80 have been open since I am online?

    Thanks,


    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  7. #7
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Hmm, it should display some boxes, because I'm sure that one of your ports are open.

    In a dosBox type:
    netstat -a
    and check which ports are open.

    BTW: I think you should put txtIP to your own ip.
    (you can find your ip by pressing START, RUN, then typing
    winipcfg, you'll see your IP somewhere there

    [Edited by Jop on 08-27-2000 at 09:41 PM]
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  8. #8

    Thread Starter
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    The DOSPrompt shows 15 active connections with a STATE of either LISTENING or TIME_WAITING. Some local Addresses show nbsession, nbname or nbdatagram instead of the port number. There are three foreign addresses. one all 0's, and two normal ones. The protocols are either TCP or UDP.

    Is this normal?




    [Edited by psyrus on 08-27-2000 at 10:02 PM]
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

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