728x90
/*
The Lord of the BOF : The Fellowship of the BOF
- vampire
- check 0xbfff
*/
#include <stdio.h>
#include <stdlib.h>
main(int argc, char *argv[])
{
char buffer[40];
if(argc < 2){
printf("argv error\n");
exit(0);
}
if(argv[1][47] != '\xbf')
{
printf("stack is still your friend.\n");
exit(0);
}
// here is changed!
if(argv[1][46] == '\xff')
{
printf("but it's not forever\n");
exit(0);
}
strcpy(buffer, argv[1]);
printf("%s\n", buffer);
}
보아하니 주소 옵션에 46번째에 \xff 가 올 수 없다.
그러면 bash2도 할 필요가 없겠군
1 /*
2 The Lord of the BOF : The Fellowship of the BOF
3 - vampire
4 - check 0xbfff
5 */
6 #include <stdio.h>
7 #include <stdlib.h>
8 main(int argc, char *argv[])
9 {
10 char buffer[40];
11 if(argc < 2){
12 printf("argv error\n");
13 exit(0);
14 }
15 if(argv[1][47] != '\xbf')
16 {
17 printf("stack is still your friend.\n");
18 exit(0);
19 }
20 // here is changed!
21 if(argv[1][46] == '\xff')
22 {
23 printf("but it's not forever\n");
24 exit(0);
25 }
26
27 strcpy(buffer, argv[1]);
28 printf("%x\n", buffer);
29 printf("%x\n", argv[2]);
30 printf("%s\n", buffer);
31 }
다음은 vampire.c 를 bampire.c 로 복사하여 수정한 코드고, buffer 와 argv[2]주소를 읽어오게 하였다.
생각을 해보면, buffer주소를 변하게 하는것보단 인자를 많이 넣어서 argv[2]의 주소를 변화시키는게 좋을것 같다.
이제 46번째 값이 fe이므로 해결된듯
비교적 간단했던 문제
728x90