|
★ 1.8 演示八
Don't stay static
/* abo8.c * * specially crafted to feed your brain by gera@core-sdi.com */
/* spot the difference */
char buf[256];
int main(int argv,char **argc) { strcpy(buf,argc[1]); }
[alert7@redhat]$ gcc -o test test.c -g [alert7@redhat]$ objdump --dynamic-reloc test
test: file format elf32-i386
DYNAMIC RELOCATION RECORDS OFFSET TYPE VALUE 0804947c R_386_GLOB_DAT __gmon_start__ 0804946c R_386_JUMP_SLOT __register_frame_info 08049470 R_386_JUMP_SLOT __deregister_frame_info 08049474 R_386_JUMP_SLOT __libc_start_main 08049478 R_386_JUMP_SLOT strcpy [alert7@redhat]$ gdb test -q (gdb) l 1 2 char buf[256]; 3 4 int main(int argv,char **argc) { 5 strcpy(buf,argc[1]); 6 } 7 (gdb) b 5 Breakpoint 1 at 0x80483cb: file test.c, line 5. (gdb) r 11 Starting program: /home/alert7/test 11
Breakpoint 1, main (argv=2, argc=0xbffffbc4) at test.c:5 5 strcpy(buf,argc[1]); (gdb) p & buf $1 = (char (*)[256]) 0x8049540 (gdb) q The program is running. Exit anyway? (y or n) y [alert7@redhat]$ objdump -s -j .dtors test
test: file format elf32-i386
Contents of section .dtors: 8049458 ffffffff 00000000 ........ [alert7@redhat]$ gcc -o test test.c -g -static [alert7@redhat]$ gdb test -q (gdb) l 1 2 char buf[256]; 3 4 int main(int argv,char **argc) { 5 strcpy(buf,argc[1]); 6 } 7 (gdb) b 5 Breakpoint 1 at 0x804819b: file test.c, line 5. (gdb) r 11 Starting program: /home/alert7/test 11
Breakpoint 1, main (argv=2, argc=0xbffffc14) at test.c:5 5 strcpy(buf,argc[1]); (gdb) p &buf $1 = (char (*)[256]) 0x807bb60 (gdb) p __exit_funcs $2 = (struct exit_function_list *) 0x807b160 [alert7@redhat62 alert7]$ objdump -s -j .dtors test
test: file format elf32-i386
Contents of section .dtors: 807b100 ffffffff 00000000 ........ buf的地址都比其他的地址要大,所以覆盖不到他们。 这个例子还不知道如何得到控制权呢?用超长字符串覆盖main函数的 返回地址是不现实的,并且在还没有覆盖到main函数返回地址之前就会 Segmentation fault,原因是访问了一个没有映射的地址(地址 映射是不连续的) 。 这个演示程序让我郁闷了好久,在我的linux上还真的无法成功溢出这个 程序,还是qera又一次专门为windows设计的!?(如果您有好的idea, 记得mailto:alert7@xfocus.org)。在windows下成功溢出这个演示程 序是没有问题的。
|