繁体   English   中英

程序集执行失败-14

[英]Assembly execve failure -14

程序将可执行文件写入磁盘的第二部分,解密(进入/ tmp / decbd),然后执行(按计划)文件decbd出现在磁盘上,并且可以通过外壳执行,最后execve调用return eax = -14 ,并且在程序结束后,执行将在数据上继续进行,并出现段错误。 http://pastebin.com/KywXTB0X

在使用hexdump和dd编译后的第二段中,我手动放置了通过openssl加密的回显二进制文件,当我在上一个int 0x80命令之前停止执行时,我已经能够使用另一个终端在decbd中运行我的“ echo”了。

man execve在“错误”部分中针对返回码-14( -EFAULT )说道:

        EFAULT filename points outside your accessible address space.

您将错误的指针传递给execve()

  1. 您应该将其范围缩小到一个最小的示例。 请参阅MCVE
  2. 如果您希望其他人提供帮助,则应注释您的代码。
  3. 您应该学习使用调试器和/或其他工具。

对于第一点,您可能会下降到:

section .text
    global _start   ;must be declared for linker (ld)
_start:
    mov eax,11             ; execve syscall
    mov ebx,program        ; name of program
    mov ecx,[esp+4]        ; pointer to argument array
    mov ebp,[esp]          ; number of arguments
    lea edx,[esp+4*ebp+2]  ; pointer to environ array
    int 0x80
section .data
    program db '/bin/echo',0

对于第3点,使用调试器可以看到:

  • ebx还行
  • ebp还可以
  • ecx是错误的
  • edx是错误的

这很容易解决。 ecx应该加载地址,而不是值,并且edx应该跳过2个指针,每个指针均为4个字节,因此偏移量应为8而不是2 固定代码如下所示:

section .text
    global _start   ;must be declared for linker (ld)
_start:
    mov eax,11             ; execve syscall
    mov ebx,program        ; name of program
    lea ecx,[esp+4]        ; pointer to argument array
    mov ebp,[esp]          ; number of arguments
    lea edx,[esp+4*ebp+8]  ; pointer to environ array (skip argc and NULL)
    int 0x80
section .data
    program db '/bin/echo',0

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM