#!/bin/bash
# Define the directory for storing scan results
SCANDIR="$(pwd)/nmap_scans"
# Get the target as a parameter or prompt the user
if [ -z "$1" ]; then
read -p "Enter a target: " TARGET
else
TARGET=$1
fi
# Confirm the target
if [ -z "$TARGET" ]; then
echo "No target specified. Exiting."
exit 1
fi
# Inform the user of the scanning process
echo "Scanning ${TARGET}..."
# Create the scan directory if it doesn't exist
mkdir -p "$SCANDIR"
# Initial scan (TCP SYN scan, service version detection, and common scripts)
sudo nmap -sS -sV -sC -oN "$SCANDIR/initial-scan" -v "$TARGET"
# Full port scan (TCP ports 1-65535) & disown
sudo nmap -sS -p- -oN "$SCANDIR/allports" -v0 "$TARGET" & disown
# UDP port scan & disown
sudo nmap -sU -oN "$SCANDIR/udpports" -v0 "$TARGET" & disown
# Notify user that scans are running in the background
echo "Full TCP and UDP scans are running in the background. Results will be saved in $SCANDIR."