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 '{print $1}') # Display open ports if [ -z "$open_ports" ]; then echo "No open ports found on $ip_address." else echo "Open ports on $ip_address:" echo "$open_ports" fi

Save this script in a file, say port_scanner.sh, then make it executable by running:

chmod +x port_scanner.sh

You can then run this script and provide an IP address as an argument:

bash
./port_scanner.sh <IP_Address>


Replace <IP_Address> with the IP address you want to scan for open ports. This script will use nmap to scan for open ports on the specified IP address and display the results. Ensure you have the necessary permissions to perform port scanning activities on the target IP address.






Comments

Popular posts from this blog

Google Hacking Guide

Sanitizing application text fields