openPort.bash

This is a simple bash script you can run at home or local network and show you all IP address with open ports.

This script is going to run through IP range 1 to 254 through address 192.168.0.x

The ports that will be checked are:
SSH – 22
HTTP – 80
HTTPS – 443
MYSQL – 3306
RDP – 3389
PRINTER – 137
PRINTER – 161
POSTGRESQL – 5432
SCANNER – 54925
PC-FAX – 54926


#!/usr/bin/env bash
#
for ip in {1..254}
do 
	for port in {22,80,137,161,443,3306,3389,5432,54925,54926};
	do 
		(echo >/dev/tcp/192.168.0.$ip/$port) >& /dev/null && \
		if [[ $port == 22 ]];then
			echo "192.168.0.$ip:$port - SSH port is open";
		elif [[ $port == 80 ]];then
			echo "192.168.0.$ip:$port - HTML port is open";
		elif [[ $port == 137 ]];then
			echo "192.168.0.$ip:$port - PRINTER port is open";
		elif [[ $port == 161 ]];then
			echo "192.168.0.$ip:$port - PRINTER port is open";
		elif [[ $port == 443 ]];then
			echo "192.168.0.$ip:$port - HTTPS port is open";
		elif [[ $port == 3306 ]];then
			echo "192.168.0.$ip:$port - MYSQL port is open";
		elif [[ $port == 3389 ]];then
			echo "192.168.0.$ip:$port - RDP port is open";
		elif [[ $port == 5432 ]];then
			echo "192.168.0.$ip:$port - POSTGRESQL port is open";
		elif [[ $port == 54925 ]];then
			echo "192.168.0.$ip:$port - SCANNER port is open";
		elif [[ $port == 54926 ]];then
			echo "192.168.0.$ip:$port - PC-FAX port is open";
		fi
	done;
done

Enjoy it!