Cool C programming trick, run /bin/sh with the C execve() function.

This programming trick is pretty cool, you can run the /bin/sh shell with a C program. The execve() function is useful for running a command within a C program and passing arguments to it, but I have replaced the arguments with NULL instead, that is what you put when you do not need arguments.

#include <stdlib.h>
#include <unistd.h>

int main(void)
{
        execve("/bin/sh", NULL, NULL);
        return 0;
}
1 responses to “Cool C programming trick, run /bin/sh with the C execve() function.

Leave a Reply