| 
		      
                         Windows系统保持着一张已知的路由器列表,我们可以使用route PRINT命令显示路由表,下面是笔者的电脑运行route PRINT命令后的结果: 
  
  列表中到达某目的节点的第一项Gateway为默认路由器,如果默认路由器关闭,则位于列表第二项的路由器成为缺省路由器。缺省路由向发送者报告另一条到特定主机的更短路由,就是ICMP重定向。攻击者可利用ICMP重定向报文破坏路由,并伪装成路由器截获所有到某些目标网络或全部目标网络的IP数据包,进行窃听。 
  显然,前文中我们只是讲解了发送ICMP Ping命令,可以编写更加通用的函数以便发送各种类型的ICMP报文。下面给出了美国北卡罗莱纳大学(University of North Carolina)计算机系的开放源代码的发送各类ICMP报文的程序: 
// icmp:发送各类ICMP报文 icmp(type, code, dst, pa1, pa2) short type, code; IPaddr dst; char *pa1, *pa2; {  struct ep *pep;  struct ip *pip;  struct icmp *pic;  Bool isresp, iserr;  IPaddr src;  int i, datalen;  IcmpOutMsgs++; 
 pep = icsetbuf(type, pa1, &isresp, &iserr);  if (pep == 0)  {   IcmpOutErrors++;   return SYSERR;  } 
 pip = (struct ip*)pep->ep_data;  pic = (struct icmp*)pip->ip_data; 
 datalen = IC_HLEN; 
 /* we fill in the source here, so routing won't break it */ 
 if (isresp)  {   if (iserr)   { 
 
		      
		      
		      
		      
		      
		      
                       
		      
		        
		      共3页: 上一页 1 [2] [3] 下一页 
		     |