V6scan is an ipv6 port scanner. Checks 14 different tcp ports which are commonly used by attackers.
f20f7d41f2f3d780f5e643237d1cde9cdee372b9796b8c4d71e3dd02efc239b0
/*
v6scan.c
by phased
phased@snosoft.com
ipv6 port scanner
06/02
"there be some deepmagic going on"
*/
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h> /* sockaddr_in6 structure */
#include <netdb.h> /* gethostbyname2 */
#define VERSION "1.0"
int ports[] = {
21,
22,
23,
25,
79,
80,
110,
113,
139,
143,
515,
1433,
5000,
6000};
/* add more */
int main(int argc, char *argv[]) {
int delay, port, i;
printf ("v6scan version %s\n", VERSION);
if (argc < 3) {
usage(argv[0]);
}
delay = atoi(argv[2]);
printf(" scanning %s\n", argv[1]);
printf(" using %i second delay\n", delay);
printf(" checking %d ports\n", sizeof(ports)/sizeof(ports[0]));
for(i=0;i<sizeof(ports)/sizeof(ports[0]);i++) {
checkhost(argv[1], i, delay);
sleep(delay);
}
}
checkhost(char *host, int port) {
int sock;
struct sockaddr_in6 target;
struct hostent *hostname;
if (( sock = socket(AF_INET6, SOCK_STREAM, 0)) < 0 ) {
printf("error creating socket ipv6 may not be supported\n");
exit(0);
}
memset((char *)&target, 0, sizeof(target));
if ((hostname = gethostbyname2(host, AF_INET6)) == NULL) {
printf("error gethostbyname2\n");
exit(0);
}
target.sin6_port = htons(port);
target.sin6_family = AF_INET6;
memcpy((char *)&target.sin6_addr, hostname->h_addr, hostname->h_length);
if ((connect(sock,(struct sockaddr *)&target,
sizeof(struct sockaddr_in6))) < 0) {
close(sock);
return(0);
}
else {
printf (" connected to port %d\n", ports[port]);
}
close(sock);
}
int usage(char *progname) {
printf("%s <host> <delay>\n", progname);
exit(0);
}