// Scan 1.0 (C) // Coded by Anonymous // A simple port scanner in C #include #include #include #include #include #include #include #include int main() { char host[42]; int start_port, end_port, i; printf("[ Scan 1.0 by Anonymous ]\n"); printf("\n"); printf("[+] Host: "); scanf("%s", &host); printf("[+] Start port: "); scanf("%d", &start_port); printf("[+] End port: "); scanf("%d", &end_port); printf("\n"); // The scanning engine for (i = start_port; i <= end_port; i++) { struct sockaddr_in addr; struct hostent *ip; int sockfd = socket(PF_INET, SOCK_STREAM, 0); ip = gethostbyname(host); addr.sin_family = AF_INET; addr.sin_port = htons(i); addr.sin_addr.s_addr = inet_addr(ip); if ((connect(sockfd, &addr, sizeof(addr))) >= 0) { printf("[*] Port %d is open.\n", i); close(sockfd); } } return 0; }