I am trying to call '/bin/bash' using the syscall and execve system call. At first I was worried I was not correctly loading my command ('/bin/bash') into the register.. but I think I am doing that right. I have to follow specific requirements with the register useage
.section .text
.global _start
_start:
# Push an 8-byte 0 to the stack
push $0x0000000000000000
# Use the stack pointer to set the 2nd parameter
movl %esp, %ecx
# Use the same address to set the 3rd parameter
movl %esp, %edx
# Write the 8-byte hex value for "/bin/sh" to %rax register
movq $0x0068732f6e69622f, %rax
# Push the %rax register to the stack
push %rax
# Use the stack pointer to set the 1st parameter
movl %esp, %ebx
# Write the syscall number to the register
movl $59, %eax
# Execute the syscall
syscall
Currently this code segmentation faults, which I think because I am not returning anything from _start. I know if I called the syscall command %60, which is just system exit.. I would not segmentation fault.
Does anyone have any idea what I am doing wrong?