|
http://www.hackerschool.org/HS_Boards/zboard.php?AllArticle=true&no=4392 [복사]
간단한 BOF에 대한 강의자료를 만들기 위해서, ftz서버의 guest계정으로 로그인하여 테스트 중인데요.
컴파일시에 걸 수 있는 옵션은 모두 건 상태이구요. (-z execstack -fno-builtin -mpreferred-stack-boundary=2)
bof공격으로 스택의 return address부분에 주소값(\x92\x83\x04\x08)을 넣으려고 하는데 안되길래..
코어덤프를 떠보니, 자꾸 \xc2\x92\xc2\x83\xc2\x04\xc2\x08와 같이, 중간에 \xc2값이 들어가고 있는 상황이네요.
char형 배열 buffer크기는 4이구요.
아래처럼 나옵니다..
[guest@ftz test]$ perl -e 'print "a"x4,"b"x4,"\x92\x83\x04\x08"' | ./test
aaaabbbb혪혘
Segmentation fault (core dumped)
[guest@ftz test]$ gdb test core.9330
GNU gdb Red Hat Linux (5.3post-0.20021129.18rh)
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...
Core was generated by `./test'.
Program terminated with signal 11, Segmentation fault.
Cannot access memory at address 0x400160b0
#0 0x83c292c2 in ?? ()
혹시 스택쪽에 헥사코드를 넣으면 중간에 쓰레기값이 들어가도록 의도하신건가요?
예전에는 분명히 됬던 방식인데... 이상하네요.. 작년인가 제작년인가는 분명히 ftz서버에서도 됬던 것 같은데 왜 갑자기 안되죠?ㅠㅠ
+
아래와 같이, BOF원정대 서버에서는 잘 동작합니다. (제가 guest계정을 따로 만들어뒀습니다.)
[guest@localhost test]$ perl -e 'print "a"x4,"b"x4,"\x38\x84\x04\x08"' | ./test
aaaabbbb8?
bof success!
|
Hit : 3676 Date : 2015/01/23 04:38
|