Skip to content

Instantly share code, notes, and snippets.

@xremix
Last active January 8, 2018 12:22
Show Gist options
  • Save xremix/824259814270df77afa1f94458042536 to your computer and use it in GitHub Desktop.
Save xremix/824259814270df77afa1f94458042536 to your computer and use it in GitHub Desktop.
Shell TCP Listener
#!/bin/bash
#Make Sure Script Is Ran As Root
if [ $(id -u) != 0 ]; then
echo; echo -e "\e[1;31mScript must be run as sudo. Please Type \"sudo\" To Run As Root \e[0m"; echo
exit 1
fi
echo "Enter port to listen"
read portL
while true;
do
nc -l -p $portL
done
exit 0
# Create Listener (-l) that listens to Port (-p) 9999
nc -l -p 9999
# Run in infinite loop
while :; do nc -l -p 999; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment