Harun Mansor
  • ⭕About ME
  • Writeups
    • 3108 CTF (2024)
  • Projects
    • SSH Architecure using IDS, IPS, Port Knocking and SIEM System
    • Active Directory Attack SImulation Lab
    • THM - Shellcode
    • Script - Gather Emails
    • Script - Nmap Scans
    • Script - Bash
  • NOTES
    • Docker Guides
    • Web Security Under-the-hoods
Powered by GitBook
On this page
  1. Projects

Script - Nmap Scans

Simple bash script to automate nmap scans on multiple hosts

PreviousScript - Gather EmailsNextScript - Bash

Last updated 8 months ago

Was this helpful?

CtrlK

Was this helpful?

#!/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
done