Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does execve() do?

Tags:

c++

c

linux

execve

What exactly does execve() do? I've tried looking at the documentation (http://linux.die.net/man/2/execve) but given that I'm very new to linux and this sort of programming it doesn't make a lot of sense. What I want to do is be able to execute this command:

nc -l -p someport -e /bin/sh

Can I do something like the following (where someport is a number such as 4444)

char *command[2];
command[0] = "nc -l -p someport -e /bin/sh"
execve(command[0], name, NULL);
like image 954
Nosrettap Avatar asked Nov 29 '22 17:11

Nosrettap


1 Answers

execve asks the operating system to start executing a different program in the current process.

Chances are pretty decent that you want execvp or execlp instead -- you haven't mentioned anything about wanting to provide the environment for the child, but from the looks of things you probably do want the path searched to find the executable you're using.

like image 84
Jerry Coffin Avatar answered Dec 06 '22 09:12

Jerry Coffin