Cannot pass argument in execve

21 Views Asked by At

I am having a problem where I cannot pass an argument in the execve syscall. If I set the argv as null, execve is executed and my program also is executed. But if I run it setting an argument, the program is not executed. My code in x64 where the error happen:

section .data
    str: db '/usr/games/cowsay'
    arg1: db 'aaa'

section .text
    global _main

_main:
    mov rax, 0x3b
    mov rdi, str
    mov rsi, arg1
    xor rdx, rdx
    syscall
    call exit
exit:
    mov rax, 0x3c
    mov rdi, 0
    syscall

But if I run this way, cowsay is executed nornally:

section .data
    str: db '/usr/games/cowsay'

section .text
    global _main

_main:
    mov rax, 0x3b
    mov rdi, str
    xor rsi, rsi
    xor rdx, rdx
    syscall
    call exit
exit:
    mov rax, 0x3c
    mov rdi, 0
    syscall


0

There are 0 best solutions below