Skip to content

Instantly share code, notes, and snippets.

@hoangdh
Last active December 27, 2018 14:45
Show Gist options
  • Save hoangdh/23dd850b2d073049610416b9626a974d to your computer and use it in GitHub Desktop.
Save hoangdh/23dd850b2d073049610416b9626a974d to your computer and use it in GitHub Desktop.
#!/bin/bash
check_port() {
sort $1 | uniq -c | sort -nr | awk {'print $2'} | while read -r ip;
do
if ping -c 1 -w 1 $ip > /dev/null 2>&1;
then
if nc -vz -w 3 $ip 25 > /dev/null 2>&1;
then
echo $ip - Port 25 Opened;
else
echo $ip
fi
fi;
done
}
if [ -f $1 ]
then
check_port $1
else
echo "$1 - File not found."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment