Open ports searching using N map
The Nmap tool. Nmap is a powerful open-source network scanner that's widely used for network discovery and security auditing. It allows you to discover hosts and services on a computer network, thus creating a map of the network #!/bin/bash # Check if nmap is installed if ! command -v nmap &> /dev/null; then echo "Please install nmap to use this script." exit 1 fi # Check for correct usage if [ $# -ne 1 ]; then echo "Usage: $0 <IP_Address>" exit 1 fi # Retrieve IP address from command line argument ip_address= $1 # Perform port scan using nmap echo "Scanning ports for $ip_address ..." nmap_output=$(nmap -p- --open $ip_address ) # Check if any open ports found if [[ $nmap_output == * "0 hosts up" * ]]; then echo "No hosts found at $ip_address ." exit 1 fi # Extract open ports open_ports=$( echo " $nmap_output " | grep "^ *[0-9]" | awk