|
# cc -mpreferred-stack-boundary=2 -g stack.c -o stack
/tmp/ccgRJGyd.o: In function `return_input':
/root/shellcode/stack.c:7: warning: the `gets' function is dangerous and should not be used.
[root@centos shellcode]# ./stack
AAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDD
AAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDD
段错误
(gdb) disas return_input
Dump of assembler code for function return_input:
0x080483d4 <return_input+0>: push %ebp
0x080483d5 <return_input+1>: mov %esp,%ebp
0x080483d7 <return_input+3>: sub $0x24,%esp
0x080483da <return_input+6>: lea -0x1e(%ebp),%eax
0x080483dd <return_input+9>: mov %eax,(%esp)
0x080483e0 <return_input+12>: call 0x80482c4 <[email=gets@plt]gets@plt[/email]> # 这里调用了 gets() 函数
0x080483e5 <return_input+17>: lea -0x1e(%ebp),%eax
0x080483e8 <return_input+20>: mov %eax,(%esp)
0x080483eb <return_input+23>: call 0x80482e4 <[email=puts@plt]puts@plt[/email]>
0x080483f0 <return_input+28>: leave
0x080483f1 <return_input+29>: ret # 这里 return_input 函数返回
End of assembler dump.
(gdb) break *0x080483e0
Breakpoint 1 at 0x80483e0: file stack.c, line 7.
(gdb) break *0x080483f1
Breakpoint 2 at 0x80483f1: file stack.c, line 9.
(gdb) run
Starting program: /root/shellcode/stack
Breakpoint 1, 0x080483e0 in return_input () at stack.c:7
7 gets (array);
(gdb) disas main
Dump of assembler code for function main:
0x080483f2 <main+0>: push %ebp
0x080483f3 <main+1>: mov %esp,%ebp
0x080483f5 <main+3>: call 0x80483d4 <return_input>
0x080483fa <main+8>: mov $0x0,%eax
0x080483ff <main+13>: pop %ebp
0x08048400 <main+14>: ret
End of assembler dump.
(gdb) x/20x $esp
0xbfffcc8c: 0xbfffcc92 0x0012d175 0xbfffcd4c 0xbfffccb8
0xbfffcc9c: 0x00258ff4 0x00d50600 0x08048420 0x00000000
0xbfffccac: 0x00258ff4 0xbfffccb8 0x080483fa 0xbfffcd18
0xbfffccbc: 0x00116e9c 0x00000001 0xbfffcd44 0xbfffcd4c
0xbfffcccc: 0x00d5e810 0x00000000 0x00000001 0x00000001
(gdb) c
Continuing.
AAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDD
AAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDD
Breakpoint 2, 0x080483f1 in return_input () at stack.c:9
9 }
(gdb) x/20x 0xbfffcc8c
0xbfffcc8c: 0xbfffcc92 0x4141d175 0x41414141 0x41414141
0xbfffcc9c: 0x42424242 0x42424242 0x43434242 0x43434343
0xbfffccac: 0x43434343 0x44444444 0x44444444 0xbf004444
0xbfffccbc: 0x00116e9c 0x00000001 0xbfffcd44 0xbfffcd4c
0xbfffcccc: 0x00d5e810 0x00000000 0x00000001 0x00000001
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |