Script - Nmap Scans
Simple bash script to automate nmap scans on multiple hosts
#!/bin/bash
declare -A domains=(
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
    ["redacted.com.my"]="0.0.0.0"
)
# Loop through each domain in the associative array
for domain in "${!domains[@]}"; do
    ip="${domains[$domain]}"
    if [[ -n "$ip" && "$ip" != "NONEXISTENT" ]]; then
        echo "Scanning $domain ($ip)"
        
        # Run nmap scan and output it to a file
        nmap -F "$ip" > "${domain}.txt"
        
        echo "Scan result for $domain saved to ${domain}.txt"
    else
        echo "Skipping $domain: IP address is not valid"
    fi
doneLast updated
Was this helpful?