I am very new to assembly and I am trying to call:
/bin/bash -c "echo hello; ls -la"
I store the "/bin/bash" command as a string and its address in RBX and RDI. 59 on RAX for the execve syscall that I perform at the end. -c on RSI as the second argument with the echo line on the third. Here's what gdb sees on the registers before the syscall line.
RBX: 0x4000b3 ("/bin/bash")
RCX: 0x0
RDX: 0x4000c8 ("\"echo hello; ls -la\"")
RSI: 0x4000c5 --> 0x6f6863652200632d ('-c')
RDI: 0x4000b3 ("/bin/bash")
RBP: 0x0
RSP: 0x7fffffffe0e0 --> 0x1
RIP: 0x4000a7 --> 0xe8050f0000003bb8
But when I start the executable nothing happens. I thought the registers are used for the argv[] arguments.
I debugged the program and I honestly can't tell what's going wrong but then again I am really new so maybe I am not actually giving the arguments to the syscall?
argvarray. That should be an array of pointers to the individual arguments. And make sure thatargv[0]contains"bash"or"/bin/bash"envarray./bin/bash -c "echo hello; ls -la"in bash or sh, the quotes protect that part of the command line from word-splitting, but quote-removal happens before passing that string to argv of the child process. Try it yourself withprintf "%s\n" -c "hello world" 'hi mom' "quotes 'inside' quotes aren't removed"on a bash command line.const char *pathname, RSI ischar *const argv[], a pointer to an array of pointers.printf "%s\n" ...... "quotes 'inside' quotes aren't removed" 'same "for dbls" inside singles'Good luck to all.