hi whats up ??
before 2 days ago i was so board so i started to write a port scanner her it is :
tell me what you think about my scanner and what to improveCode:#include <stdio.h> #include <string.h> #include <netinet/in.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <netdb.h> #include <sys/types.h> #include <sys/socket.h> int main(int argc, char *argv[]) { int sockfd, port; struct hostent *host; printf("welcome to Fast-scanner 1.4 \n"); if (argc != 2) { fprintf(stderr,"ip or hostname\n"); exit(1); } if ((host=gethostbyname(argv[1])) == NULL) { perror("gproblem finding victim :("); exit(1); } for(port=0; port<=65000; port++) { struct sockaddr_in host_addr; if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { perror("problem in socket"); exit(1); } host_addr.sin_family = AF_INET; host_addr.sin_port = htons(port); host_addr.sin_addr = *((struct in_addr *)host->h_addr); memset(&(host_addr.sin_zero), '\0', 8); if (connect(sockfd, (struct sockaddr *)&host_addr, sizeof(struct sockaddr)) == -1) { //printf("."); close(sockfd); } else { printf("*****this port %i is open*****\n", port); close(sockfd); } } printf("for more info on port numbers :http://www.iana.org/assignments/port-numbers\n"); printf("Mr-Unix Tm [email protected] \n"); }![]()
tnx




Reply With Quote