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 Segmentation fault
error for the following 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
Does somebody know what I'm doing wrong here?
I compile, link and run it in the following way
$ nasm -f elf64 -o shell.o shell.asm
$ ld -o shell shell.o
$ ./shell