Last active
December 27, 2018 14:45
-
-
Save hoangdh/23dd850b2d073049610416b9626a974d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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