Execve调用中OS X x86_64中的总线错误

时间:2016-05-06 23:52:25

标签: macos assembly x86-64 execve

我试图在64位Asm中模仿安全管执行教程(http://hackoftheday.securitytube.net/2013/04/demystifying-execve-shellcode-stack.html)。我不确定总线错误来自哪里。我在GDB中逐步完成了应用程序,但直到我失去框架之后才出现错误。如果有人知道发生了什么,我很乐意听取您的意见。

.section __DATA,__data
.section __TEXT,__text
.globl _start
_start:
    xor %rax, %rax
    push %rax
    movabsq $0x68732f6e69622f2f, %rdi
    push %rax
    mov %rsp, %rsi
    push %rdi
    mov %rsp, %rdx
    mov $0x2000059, %rax
    syscall

1 个答案:

答案 0 :(得分:2)

以下应该会更好,但我没有测试osx:

.globl _start
_start:
    xor %edx, %edx                    ; NULL for env
    movabsq $0x0068732f6e69622f, %rax ; /bin/sh<0>
    push %rax
    mov %rsp, %rdi                    ; filename
    push %rdx                         ; NULL for argv terminator
    push %rdi                         ; argv[0] = filename
    mov %rsp, %rsi                    ; argv
    mov $0x200003b, %eax              ; I think 59 is decimal
    syscall