Thread: Protecting ports via winsock

  1. #1
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607

    Protecting ports via winsock

    Is there a way to protect your ports via winsock?? Sort of like ZoneAlarm does - I'm fairly new to winsock so I don't know much about it.

  2. #2
    sockets mad
    Join Date
    Mar 2002
    Posts
    126
    I think personal firewall software attatches itself to the tcp/ip stack in some way to inspect it. Similar to some virus software with real-time scanners.

    Don't ask me how it's done progmatically though, because I don't have a clue.

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Lookup Layered Service Providers at MSDN

  4. #4
    Registered User BlackBird's Avatar
    Join Date
    Mar 2004
    Posts
    4
    HI am new to the board and winsock too

    i had the same idea for a program; only problem i dont know that much about winsock so i made this last monday it listen on a port when some one connect it print the person ip;
    i think i will work to make it work how i want it to plus i got a win c++ networking ebook;
    and if u put it on a listening port it will not work :-()

    have to include winsock stuff

    #include "stdafx.h"
    WSADATA WD;
    struct sockaddr_in tcpaddr,enemy;
    #include <stdlib.h>



    int main()
    {

    WSAStartup(MAKEWORD(1,1),&WD);
    cout<<" Pleast enter the port you want this I am sillyI am sillyI am sillyI am silly to listen on"<<endl;
    int port;
    cin>>port;
    SOCKET G;
    G=socket (AF_INET,SOCK_STREAM,IPPROTO_TCP);

    tcpaddr.sin_family = AF_INET;
    tcpaddr.sin_port = htons(port);
    tcpaddr.sin_addr.s_addr = htonl(INADDR_ANY);

    bind(G, (SOCKADDR *)&tcpaddr, sizeof(tcpaddr));


    listen(G,SOMAXCONN);
    while (1)
    {

    int A =sizeof(enemy);
    accept (G,(SOCKADDR *)&enemy,&A);
    cout<<"the ip"<<inet_ntoa(enemy.sin_addr)<<"the port"<<ntohs(enemy.sin_port)<<endl;

    }


    return 0;
    }

  5. #5
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    BlackBird, I don't think that's what he's looking for.

    The 'hacker' trying to connect wouldn't be able to connect anyways unless there's a trojan or something listening on that port. If there is, then your call to bind() and listen() will fail anyways, because *surprise* that port has already been taken. Then you will be utterly helpless to do anything while the hacker proceeds to destroy your computer and burn down your house, after murdering your wife and children by programmatically unplugging them from the Matrix.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Winsock issues
    By tjpanda in forum Windows Programming
    Replies: 3
    Last Post: 12-04-2008, 08:32 AM
  2. virtual ports
    By royuco77 in forum Networking/Device Communication
    Replies: 5
    Last Post: 07-02-2005, 10:33 AM
  3. Where do I initialize Winsock and catch messages for it?
    By Lithorien in forum Windows Programming
    Replies: 10
    Last Post: 12-30-2004, 12:11 PM
  4. Winsock and Ports
    By jimboob in forum Networking/Device Communication
    Replies: 4
    Last Post: 06-27-2004, 03:24 AM
  5. Winsock Ports
    By gnu-ehacks in forum Windows Programming
    Replies: 2
    Last Post: 03-18-2002, 09:33 AM