Skip to content

Instantly share code, notes, and snippets.

@SecurityForUs
Created December 31, 2012 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SecurityForUs/4422216 to your computer and use it in GitHub Desktop.
Save SecurityForUs/4422216 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Code is swipped from http://legroom.net/2010/05/02/port-testing-and-scanning-bash
#
# Usage: ./portscan.sh <ip>
#
# Change range in {...} block as you please.
function port() {
(echo > /dev/tcp/$1/$2) &> /dev/null
if [ $? -eq 0 ]; then
echo "$1:$2 open"
else
echo "$1:$2 closed"
fi
}
for i in {22..80}; do
port $1 $i
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment