I'm not really sure where to start. I'm supposed to use netcat to allow anyone to access my shell remotely in C. I know I need to need to use sockets, but not sure what else. Can anyone point me in the right direction. Basically when I execute the program, I want it to open "nc -l 1234", take in commands from the client and respond. Thanks.
2 Answers
you can try
$nc -l 1234 -e /bin/bash -i (server)
$nc x.x.x.x 1234 (client)
We have created a netcat server and indicated it to run /bin/bash command when connection is successful.
This is a good reference for it . (using c)
http://www.cs.swarthmore.edu/~aviv/classes/f12/cs43/labs/lab4/lab4.pdf
Try something like
mkfifo temp
nc -l 1234 < temp 2>&1 | /bin/sh > temp 2>&1
7 Comments
bjamin
when I replace sh with ./shell (my executable) it doesn't work. What do I need to change?
randomusername
Try
nc -l 1234 < temp 2>&1 | ./shell > temp 2>&1bjamin
so do I need to read from a socket or something in my server shell? is that how that works. or is this just more of a hack and I should go another route?
bjamin
because I'm getting this error: write error: Bad file descriptor
randomusername
Huh? Are you sure that your
netcat program is error free and that you're correctly creating the named pipe? |