-
Notifications
You must be signed in to change notification settings - Fork 0
/
nmap-auto.sh
2 lines (2 loc) · 1.06 KB
/
nmap-auto.sh
1
2
#!/usr/bin/bash -
r='\033[0m';g='\033[32m';m='\033[35m';b='\033[34m';if [[ $(echo $EUID) != '0' ]]; then echo -e "$b- I wish I were$g sudo$b :($r";exit;fi; export IP=$1; echo -e "$b- Starting Port Scan on $m$IP$b..$r\n"; { ports=$(nmap -p- --min-rate=1000 -T4 $IP -v | grep --line-buffered Discovered |tee /dev/fd/3 | cut -d '/' -f 1 | cut -d ' ' -f 4 | tr '\n' ',' | sed s/,$//); } 3>&1; export PORTS=$ports; if [[ $ports == '' ]]; then echo -e "\n$b- Sorry, All ports are Closed\n\n- Try Smarter, Man! Bye ;)";exit;else echo -e "$b- Open ports: $m$ports";fi; echo -e "\n$b- Initializing$m Service Scan$b..$r";filename=$IP\_scan_result_tcp.txt; echo -e "$b- Scan results will be saved to $g$filename$b upon completion$r\n";nmap -p$ports -sSCV $IP | tee $filename; echo -e "$g- TCP Scan completed.\n\n$b-$m UDP Scan$b Starting.. (only top 100 ports)$r";filename1=$IP\_scan_result_udp.txt; echo -e "$b- Scan results will be saved to $g$filename1$b upon completion$r\n"; nmap -sU --top-ports 100 $IP -Pn | tee $filename1; echo -e "$g- UDP Scan completed.\n\n$b- Happy Hacking, Bye.$r";