-
Notifications
You must be signed in to change notification settings - Fork 2
/
scriptNmap.sh
44 lines (34 loc) · 858 Bytes
/
scriptNmap.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#! /bin/bash
ip="${1}"
portL=""
#First scan to detecte all the open TCP ports
echo "Scanning open TCP ports"
nmap -p- --min-rate 800 $ip > firstScan
while read line
do
if [[ ${line:0:1} =~ [0-9] ]]
then
portL="${portL}${line%%/*},"
fi
done < firstScan
echo $portL
#Second scan to scan with default and version scans only the open ports
echo "Scanning protocols and versions on open TCP ports"
nmap -p $portL -sC -sV $ip
rm firstScan
portL=""
#Third scan to detecte all the UDP open ports
echo "Scanning open UDP ports"
nmap --min-rate 500 -sU $ip > secondScan
while read line
do
if [[ ${line:0:1} =~ [0-9] ]]
then
portL="${portL}${line%%/*},"
fi
done < secondScan
echo $portL
#Fourth scan to scan with default scans only the open ports
echo "Scanning protocols and versions on open UDP ports"
nmap -p $portL -sU -sC -sV $ip
rm secondScan