Shellcode mov指令错误

时间:2015-08-24 08:48:29

标签: assembly shellcode

我最近一直在研究shellcode。我编写了一个shellcode来使用execve系统调用来生成shell。

这是汇编代码:

global _start

section .text

_start:

        jmp Shellcode

Execve:

        xor rax, rax

        ; Get the address of the string
        pop rdi

        ; Convert the A -> 0x0 to null terminate the string
        mov [rdi +7], byte ah

        ; Copy the address of the string in RDI to BBBBBBBB
        mov [rdi +8], rdi

        ; Copy the NULL 0x0000000000000000 -> CCCCCCCC
        mov [rdi +16], rax

        ; Setup the addresses
        lea rsi, [rdi +8]
        lea rdx, [rdi +16]

        add rax, 59
        syscall


Shellcode:

        call Execve

        shell_string : db "/bin/shABBBBBBBBCCCCCCCC"

我用这个编译了这段代码。

  •   

    nasm -f elf64 execve-jmp-call-pop.nasm -o execve-jmp-call-pop.o

  •   

    ld execve-jmp-call-pop.o -o execve-jmp-call-pop

当我运行这个程序时,它给了我分段错误。我在gdb中加载了这个程序,它在* mov [rdi +7],byte ah *指令上给出了分段错误。我试着看看rax和啊注册值,但gdb说它无法访问。我在虚拟框中使用Ubuntu 14.04 64位操作系统。我是新来的。我不知道如何解决它。

0 个答案:

没有答案
相关问题