title: Shellcode Development - Spawn a shell with NASM assembly in 64 bit [ ERROR ]
body: <p>I'm trying to learn shellcode development and currently trying to implement the stack method in which you push the "/bin/sh" string onto the stack. Most tutorials that I've read so far are focused on 32b whereas I want to implement it for 64b and am currently stuck with a <code>Segmentation fault</code> error for the following code:</p>
  
  <pre><code>section .text
  
    global _start
  
  _start:
  
    ; zero out RAX 
    xor rax, rax
  
    ; push string in reverse order onto the stack
    ; first the nullbyte, then /bin//sh
    push rax         ; nullbyte for string
    push 0x68732f2f 
    push 0x6e69622f
  
    ; stack pointer contains address of string now
    mov ebx, esp ; first argument to execve
    mov ecx, eax ; second argument to execve
    mov al, 0xb  ; 11 := syscall number of execve
    int 0x80
  </code></pre>
  
  <p>Does somebody know what I'm doing wrong here?</p>
  
  <p>I compile, link and run it in the following way</p>
  
  <pre><code>$ nasm -f elf64 -o shell.o shell.asm
  $ ld -o shell shell.o
  $ ./shell
  </code></pre>