AlbWarez. Mundėsuar nga phpBB
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Port scanner ne C++

Shko poshtė

Port scanner ne C++ Empty Port scanner ne C++

Mesazh nga icodder Sat Sep 06, 2008 9:58 am

Port scanner ne C++ :

Kodi:
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
 
int main(int argc,char *argv[])
{
    int sock, port;
    struct sockaddr_in host;
    struct hostent *server;
    if(argc != 2){
        printf("Keni 0c\'s port scanner\nUsage: %s [host address]\n",argv[0]);
        return 1;
    }
    if((sock = socket(AF_INET,SOCK_STREAM,0)) == -1){
        perror("Gabim ne krijimin e socket-it");
        return 1;
    }
    if((server=gethostbyname(argv[1])) == NULL){
        perror("Gabin ne host");
        return 1;
    }
    for(port = 0; port <= 65535; port++){
        host.sin_family = AF_INET;
        host.sin_port = htons(port);
        host.sin_addr = *((struct in_addr *)server->h_addr);
        if(connect(sock,(struct sockaddr *)&host,sizeof(host)) != -1){
            printf("Porti %d eshte i hapur ",port);
            continue;
        }
    }
    return 0;
}

icodder
Little Baby
Little Baby

Numri i postimeve : 22
Join date : 06/09/2008

Mbrapsht nė krye Shko poshtė

Mbrapsht nė krye


 
Drejtat e ktij Forumit:
Ju nuk mund ti pėrgjigjeni temave tė kėtij forumi