Search code examples
assemblyx86shellcode

Mistake in x86 shellcode


I want to write assembly code that should run the following c function:

execv("/bin/sh", ["/bin/sh", 0])

I therefore wrote the following assembly code:

start:
    call main
    db '/bin/sh',7
main:
    xor edx, edx
    mov eax, 11    
    pop ebx
    push edx
    push ebx
    mov ecx, esp
    int 0x80

But somehow this does not work at all.. What exactly is wrong with it? I think I messed up something with the zerobyte of the array, but nor sure though.


Solution

  • change the line with the string to:

    db '/bin/sh', 0