Results 1 to 9 of 9

Thread: How to check open ports on a computer, and their connection state

  1. #1
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 05
    Location
    California, USA
    Posts
    1,035

    How to check open ports on a computer, and their connection state

    As the above says, basicly after alot of research I have been doing lately, alot of trojans, mostly remote adminstraition trojans connect to your computer via an open port that the server opens when the server side is ran.

    Well I am attempting to stop some of the more basic trojans that script kiddie's would use from getting into your computer, by constantly checking for new sockets being opened, and possibly prompting the user and closing them.

    So my first step towards this would be how to get the current computers socket status, and going from there. Any idea?
    Age - 15 ::: Level - Advanced
    If you find my post useful please ::Rate It::


  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 02
    Location
    Other side of town from si_the_geek
    Posts
    7,171

    Re: How to check open ports on a computer, and their connection state



    Has someone helped you? Then you can Rate their helpful post.

  3. #3
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 05
    Location
    California, USA
    Posts
    1,035

    Re: How to check open ports on a computer, and their connection state

    In a way, but I am looking for more of a list, that's just a port scanner, which scans your ports and try's to connect to them and gives you the ports that it succesfully connected to.

    I remember something in one of the lessons I was reading, about going to Dos and typing in something like "stats -AN" and all your open connections would come up. Mabye get something like that. Then from there I could simply just have it's own basic firewall, and list everything that it should bypass and everything else it should prompt the user that's it's happened.
    Age - 15 ::: Level - Advanced
    If you find my post useful please ::Rate It::


  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 04
    Location
    Center of it all
    Posts
    17,901

    Re: How to check open ports on a computer, and their connection state

    Try NETSTAT /?
    It depends on your OS, but with XP SP2, you can use NETSTAT -ano

  5. #5
    Frenzied Member Inuyasha1782's Avatar
    Join Date
    May 05
    Location
    California, USA
    Posts
    1,035

    Re: How to check open ports on a computer, and their connection state

    Yes, that's what I ment, could not remember it. So, how would I get a list like that in Vb? Im still kind of beta on exactly how I am doing this, but basicly I am thinking of having a list of ports to bypass, and anything not on it that has an established connection will be closed and the user prompted.
    Age - 15 ::: Level - Advanced
    If you find my post useful please ::Rate It::


  6. #6

    Re: How to check open ports on a computer, and their connection state

    You've probably solved this by now, but what you could do is shell a dos command

    netstat -an >ports.txt

    this would save the list created by netstat to a text file, then you would write code to interpret the data found.

  7. #7
    Banned dglienna's Avatar
    Join Date
    Jun 04
    Location
    Center of it all
    Posts
    17,901

    Re: How to check open ports on a computer, and their connection state

    Like this:

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.   Shell ("C:\Windows\System32\cmd.exe /c  C:\Windows\System32\netstat -n >> C:\myfile.txt"), vbNormalFocus
    5. End Sub

    then you could read it in and display it, or use shellexecute to open the file in notepad.

  8. #8
    Junior Member
    Join Date
    Oct 04
    Posts
    26

    Re: How to check open ports on a computer, and their connection state

    there are two ways to do this :

    1. make a device driver so that all conections and all data will pass thru it.
    2. using :
    VB Code:
    1. Private Declare Function GetTcpTable Lib "IPhlpAPI" (pTcpTable As MIB_TCPTABLE, pdwSize As Long, bOrder As Long) As Long
    2.  
    3.           Private Declare Function SetTcpEntry Lib "IPhlpAPI" (pTcpRow As MIB_TCPROW) As Long

    some examples you could find on planet source code.
    U`ll Never Get To HEAVEN If U`re Scared Of Gettin` HIGH

  9. #9
    Frenzied Member
    Join Date
    Aug 00
    Location
    O!
    Posts
    1,177

    Re: How to check open ports on a computer, and their connection state

    Take a look at http://www.freevbcode.com/ShowCode.A...etstat&ID=3759. The listed download file is called netstat.zip.

    About 4 years ago I downloaded a file from this site called netstats.zip. Not sure if they are the same. I had to tweak that code a bit to get what I wanted.

Posting Permissions

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