系列C++问题请教高手之九:buffer overflow |
---|
|
|
id="Topic_Zone" style="HEIGHT: 4px" marginwidth="0" marginheight="0" src="/u/AD/Topic_Zone.aspx" frameborder="0" width="100%" scrolling="no" height="0">
|
发表于:2007-10-24 16:25:5015楼 得分:0 | 贴个GCC反汇编出来的看看。 ================================== .file "Cpp1.cpp" .section .rodata .LC0: .string "AAAABBBBCCCCDDDDEEEEFFFF/200/020@" .text .align 2 .globl _Z4copyPc .type _Z4copyPc,@function _Z4copyPc: .LFB2: pushl %ebp .LCFI0: movl %esp, %ebp .LCFI1: pushl %edi .LCFI2: pushl %esi .LCFI3: subl $64, %esp .LCFI4: leal -72(%ebp), %edi movl $.LC0, %esi cld movl $7, %eax movl %eax, %ecx rep movsl subl $8, %esp leal -72(%ebp), %eax pushl %eax leal -40(%ebp), %eax pushl %eax .LCFI5: call strcpy addl $16, %esp movl $0, %eax leal -8(%ebp), %esp popl %esi popl %edi leave ret .LFE2: .Lfe1: .size _Z4copyPc,.Lfe1-_Z4copyPc .section .rodata .LC1: .string "Can you see me now?/n" .text .align 2 .globl _Z6hackedv .type _Z6hackedv,@function _Z6hackedv: .LFB4: pushl %ebp .LCFI6: movl %esp, %ebp .LCFI7: subl $8, %esp .LCFI8: subl $12, %esp pushl $.LC1 .LCFI9: call printf addl $16, %esp subl $12, %esp pushl $0 call exit .LFE4: .Lfe2: .size _Z6hackedv,.Lfe2-_Z6hackedv .section .rodata .LC2: .string "Address of function: 0x%08x/n" .text .align 2 .globl main .type main,@function main: .LFB6: pushl %ebp .LCFI10: movl %esp, %ebp .LCFI11: subl $8, %esp .LCFI12: andl $-16, %esp movl $0, %eax subl %eax, %esp subl $12, %esp movl 12(%ebp), %eax addl $4, %eax pushl (%eax) .LCFI13: call _Z4copyPc addl $16, %esp subl $8, %esp pushl $_Z6hackedv pushl $.LC2 call printf addl $16, %esp subl $12, %esp pushl $1 call exit .LFE6: .Lfe3: .size main,.Lfe3-main .ident "GCC: (GNU) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)"
| |
| |
|
发表于:2007-10-29 14:50:0019楼 得分:0 | 我的在linux下面一切正常啊。 ====================== 其怪,今天重新编译又没有问题了。。。。 | |