Skip to content

Instantly share code, notes, and snippets.

@SIMULATAN
Created October 19, 2022 14:10
Show Gist options
  • Save SIMULATAN/08646687042a6ef60a376a6e3b3a6032 to your computer and use it in GitHub Desktop.
Save SIMULATAN/08646687042a6ef60a376a6e3b3a6032 to your computer and use it in GitHub Desktop.
Get all ports you can access from inside of a network to the outside. Useful if ports are blocked by your sysadmin and you need to find out what ports you can put your services on to access them.
#!/bin/bash
function scan() {
# stdin will be parsed by the script
# stderr is just for debugging purposes and to see the process while running the script
curl "http://portquiz.net:$1" &>/dev/null && echo "$i" && echo "$i" >&2
}
function scanAll() {
for i in {0..69420}; do
scan $i &
done
# wait for the started subshells to exit
wait
}
RESULT="$(echo "$(scanAll)" | sort -n | tr '\n' ',')"
echo ${RESULT::-1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment